Sample requests and responses
Looking for Gateway REST API documentation?
Our REST API is documented with a live tester and is available here: Gateway
You can test how the platform works using our live tester or using cURL commands to access REST API. Below you can find example requests you can try and the results that the system should return. The dialog is as simple as possible, just to demonstrate how the requests are sent.
In order to proceed with the conversation, we will need some parameters as mentioned here. To find project id (uuid), let's take a look at the list of projects in SentiOne Automate. You can find uuid on the All projects list:
First request to start conversation
Remember to replace with Base64-encoded string containing your username and password divided by colon, for example: bart-bazinski:barts-password
We will send the request with just "START" in user text, as we just want to start the conversation and receive a welcome message from the bot.
curl --request POST \
--url https://gateway.app.chatbots.sentione.com/gateway \
--header 'Accept: application/json' \
--header 'Authorization: Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "START",
"author": "Bart Bazinski",
"uuid": "e44e41d2-8ffd-4859-b81e-a458aacc8bda",
"suid": "readme_43578943242342959789875",
"source_type": "external"
}
'
The response with first bot welcome message should be as below. The bot will answer with the content of the "Say Hello!" block from the flow showed earlier.
{
"current_state": {
"context": "Context",
"id": "3ea7e383-1ff4-482a-a9f7-3f288b82d385",
"name": "say:Say Hello! Please say something...",
"tags": []
},
"responses": [
{
"quickReplies": [],
"text": "Hello! Please say something, but to anything you will say I will just say \"Great Mate!\".",
"quick_replies": [],
"attachments": []
}
],
"used_states": [
{
"context": "Context",
"id": "3ea7e383-1ff4-482a-a9f7-3f288b82d385",
"name": "say:Say Hello! Please say something...",
"tags": []
}
],
"debug_info": null,
"intent": {
"name": "no_intent",
"score": 1.0
},
"tags": [],
"commands": [],
"process_time": 16,
"nlu_time": 0,
"integrations_time": 0
}
As you can see, there is a lot of information returned here, but for the sake of this example we are only interested in bot response. It can be found inside responses, in the text field: Hello! Please say something, but to anything you will say I will just say "Great Mate!".
Request with example message from the user
We will now send the message to the bot, asking how is he doing.
curl --request POST \
--url https://gateway.app.chatbots.sentione.com/gateway \
--header 'Accept: application/json' \
--header 'Authorization: Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "hey man, how are you doing?",
"author": "Bart Bazinski",
"uuid": "e44e41d2-8ffd-4859-b81e-a458aacc8bda",
"suid": "readme_43578943242342959789875",
"source_type": "external"
}
'
As we can see below, the bot returns the answer as predicted: Great, Mate!
{
"current_state": {
"context": "Context",
"id": "8ca954ff-ce72-4a98-9171-ec1f48d8455b",
"name": "say:Great Mate!",
"tags": []
},
"responses": [
{
"quickReplies": [],
"text": "Great, Mate!",
"quick_replies": [],
"attachments": []
}
],
"used_states": [
{
"context": "Context",
"id": "8ca954ff-ce72-4a98-9171-ec1f48d8455b",
"name": "say:Great Mate!",
"tags": []
}
],
"debug_info": null,
"intent": {
"name": "no_intent",
"score": 1.0
},
"tags": [],
"commands": [],
"process_time": 3,
"nlu_time": 0,
"integrations_time": 0
}
Conversation end
As in our example flow we had the block connected to an End conversation block, after sending the next message the bot will send a disconnect command. Now, we will tell him we love what he is saying and let's see what happens.
curl --request POST \
--url https://gateway.app.chatbots.sentione.com/gateway \
--header 'Accept: application/json' \
--header 'Authorization: Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "I love what you are doing! Can we meet some time?",
"author": "Bart Bazinski",
"uuid": "e44e41d2-8ffd-4859-b81e-a458aacc8bda",
"suid": "readme_43578943242342959789875",
"source_type": "external"
}
'
Afterwards, we will receive a response with a commands section, containg a entry with type disconnect. That tells us the conversation ended and we should disconnect the user from chat or voice session.
{
"current_state": {
"context": "Context",
"id": "a0d60271-efc5-47f3-860a-2ff03288ff7d",
"name": "terminate:End conversation",
"tags": []
},
"responses": [],
"used_states": [
{
"context": "Context",
"id": "a0d60271-efc5-47f3-860a-2ff03288ff7d",
"name": "terminate:End conversation",
"tags": []
}
],
"debug_info": null,
"intent": {
"name": "no_intent",
"score": 1.0
},
"tags": [],
"commands": [
{
"type": "disconnect",
"params": null
}
],
"process_time": 19,
"nlu_time": 0,
"integrations_time": 0
}
In case of any questions, feel free to reach out to us using the chat widget in right bottom corner of this website!
Updated about 2 years ago