Sending and receiving messages with Smartify APIs
Steps
2
Anonymous end-user authentication through APIs
https://panel.smartifyai.in/api/curl -v -X POST -H 'Content-Type:application/json' \
-d '{"id_project":"5e2c35c8f0dbc10017bb3aac", "firstname":"John"}' \
https://panel.smartifyai.in/api/auth/signinAnonymously{
"success":true,
"token":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.XYZ....",
"user":{
"_id":"fc43a0e1-ba85-404e-9a44-bf0050330898",
"firstname":"John",
"id":"fc43a0e1-ba85-404e-9a44-bf0050330898",
"fullName":"John"
}
}3
Sending messages to a conversation
curl -v -X POST -H 'Content-Type:application/json' \
-H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.XYZ...." \
-d '{"text":"hello from anonym user"}' \
https://panel.smartifyai.in/api/<PROJECT_ID>/requests/support-group-<UUID>/messagescurl -v -X POST -H 'Content-Type:application/json' \
-H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.XYZ...." \
-d '{"text":"hello my name is John and I need help"}' \
https://panel.smartifyai.in/api/5e2c35c8f0dbc10017bb3aac/requests/support-group-27df7cbf-3946-4ca4-9b17-dc16114108f8/messages4
Receiving new messages notifications using Webhooks
curl -v -X POST -H 'Content-Type:application/json' \
-u [email protected]:123456 \
-d '{"event":"message.create", "target":"https://tiledesk.requestcatcher.com/test"}' \
https://panel.smartifyai.in/api/5e2c35c8f0dbc10017bb3aac/subscriptions{
"secret":"0fd2a8a1-a3e6-443b-9fe5-49b83612cd72",
"_id":"5e2c6a24f5b11c00175f1705",
"target":"https://tiledesk.requestcatcher.com/test",
"event":"message.create",
"id_project":"5e2c35c8f0dbc10017bb3aac",
"createdBy":"5e2c357af0dbc10017bb3aa7",
"createdAt":"2020-01-25T16:17:40.088Z",
"updatedAt":"2020-01-25T16:17:40.088Z",
"__v":0
}{
"timestamp":1579969429552,
"payload":{
"type":"text",
"status":200,
"_id":"5e2c6b958c9612001716bede",
"sender":"5e2c357af0dbc10017bb3aa7",
"senderFullname":"demo demo",
"recipient":"support-group-27df7cbf-3946-4ca4-9b17-dc16114108f10",
"text":"Hi I'm Rosy. How can help you?",
"id_project":"5e2c35c8f0dbc10017bb3aac",
"createdBy":"5e2c357af0dbc10017bb3aa7",
"metadata":"",
"attributes":{
"client":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
"sourcePage":"https://panel.smartifyai.in/api/chat/index.html",
"userEmail":"[email protected]",
"userFullname":"aaa22 aaa22"
},
"createdAt":"2020-01-25T16:23:49.394Z",
"updatedAt":"2020-01-25T16:23:49.394Z",
"__v":0,
"request":{
....
}
},
"hook":{
"_id":"5e2c6a24f5b11c00175f1705",
"target":"https://tiledesk.requestcatcher.com/test",
"event":"message.create",
"id_project":"5e2c35c8f0dbc10017bb3aac",
"createdBy":"5e2c357af0dbc10017bb3aa7",
"createdAt":"2020-01-25T16:17:40.088Z",
"updatedAt":"2020-01-25T16:17:40.088Z",
"__v":0
}
}Last updated