Gateway
Looking for Gateway REST API documentation?
Our REST API is documented with a live tester and is available here: Gateway
How to connect end users to SentiOne Automate platform?
All systems communicating with actual end customers can be connected using one, simple Gateway API. Gateway is an application that exposes simple REST API which allows users to talk with bots build on SentiOne Automate platform. It allows external users to connect voice bots or chat bots with our platform and all it's features. Moreover, it takes care of saving transcriptions to database, so later you can review all conversations. Everytime the user writes a message to the bot, just send it to Automate platform through Gateway API and in response you will receive the bot message that should be sent to the user.
Gateway role in the architecture
Gateway is responsible for supporting system use case, where an external system (eg. chat widget) wants to get response for an user event (which can be message sent from: chat, Facebook bot, Twitter bot, just a regular phone call, or any other text or voice channel). The general logic is as follows:
- Gateway takes the user input through HTTP REST request,
- Processes it with SentiOne Automate's Natural Language Understanding Engine,
- Collects any required data from third-party systems integrated through REST APIs,
- Passes it on to Dialog Manager in order to determine the bot reaction (which can be a message or system commands, eg. end the conversation or redirect to human agent),
- Returns the bot reaction as HTTP REST response.
Detailed architecture description can be found in the Architecture chapter
How to create a connector to SentiOne Automate Platform?
- Obtain access. Public API is secured with HTTP Basic Auth. Credentials are available after direct contact with SentiOne Automate Sales Team. Please feel free to email us: [email protected]
- Test API. Visit our Gateway API Rerefence, where you can easily test how it works. Example data to use:
- uuid=dae72147-00ce-46fe-8554-e1281204698a - you can use a very simple EchoBot, that just returns what user said.
- source_type=external - used for all external channels
- author=John Smith - in case of phone connections that could be replaced with phone number of the caller
- suid - represents session identifier, need to be unique for every session, so please use online generator to create an example
- text=Good morning, sir! - elegantly say hello to artificial intelligence
- Copy example code. Fill the example parameters, select your programming language and you will see how to invoke the API from your favourite programming language.
Example code that sends a user message to gateway
Remember to replace with Base64-encoded string containing your username and password divided by colon, for example: bart-bazinski:barts-password
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": "hello there",
"author": "Bart Bazinski",
"uuid": "dae72147-00ce-46fe-8554-e1281204698a",
"suid": "435789543782322959789875",
"source_type": "external"
}
'
# first install requests: python -m pip install requests
import requests
url = "https://gateway.app.chatbots.sentione.com/gateway"
payload = {
"text": "hello there",
"author": "Bart Bazinski",
"uuid": "dae72147-00ce-46fe-8554-e1281204698a",
"suid": "435789543782322959789875",
"source_type": "external"
}
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"text\":\"hello there\",\"author\":\"Bart Bazinski\",\"uuid\":\"dae72147-00ce-46fe-8554-e1281204698a\",\"suid\":\"435789543782322959789875\",\"source_type\":\"external\"}");
Request request = new Request.Builder()
.url("https://gateway.app.chatbots.sentione.com/gateway")
.post(body)
.addHeader("Accept", "application/json")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>")
.build();
Response response = client.newCall(request).execute();
<?php
// first install Guzzle: composer require guzzlehttp/guzzle
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://gateway.app.chatbots.sentione.com/gateway', [
'body' => '{"text":"hello there","author":"Bart Bazinski","uuid":"dae72147-00ce-46fe-8554-e1281204698a","suid":"435789543782322959789875","source_type":"external"}',
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();
// first install RestSharp: dotnet add package RestSharp
var client = new RestClient("https://gateway.app.chatbots.sentione.com/gateway");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>");
request.AddParameter("application/json", "{\"text\":\"hello there\",\"author\":\"Bart Bazinski\",\"uuid\":\"dae72147-00ce-46fe-8554-e1281204698a\",\"suid\":\"435789543782322959789875\",\"source_type\":\"external\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://gateway.app.chatbots.sentione.com/gateway");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"text\":\"hello there\",\"author\":\"Bart Bazinski\",\"uuid\":\"dae72147-00ce-46fe-8554-e1281204698a\",\"suid\":\"435789543782322959789875\",\"source_type\":\"external\"}");
CURLcode ret = curl_easy_perform(hnd);
const options = {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic <PUT YOUR BASE64 ENCODED USERNAME AND PASSWORD HERE>'
},
body: JSON.stringify({
text: 'hello there',
author: 'Bart Bazinski',
uuid: 'dae72147-00ce-46fe-8554-e1281204698a',
suid: '435789543782322959789875',
source_type: 'external'
})
};
fetch('https://gateway.app.chatbots.sentione.com/gateway', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
You can generate access library in any language!
Swagger Codegen can simplify your build process by generating server stubs and client SDKs for SentiOne Automate Gateway API. The API defined with the OpenAPI (formerly known as Swagger) specification. Here you can find the YAML in OpenAPI format and here is Swagger panel for testing the API.
Updated 11 months ago
Everything not clear? Take a look at some samples to get full understanding how Gateway works