Engine API
Requests and responses
Requests to engine are sent over http(s). Both GET and POST requests are allowed, but POST requests are preferred. The Content-Type should be application/x-www-form-urlencoded
.
Request parameters
Requests to engine usually contain the following main URL parameters:
Parameter | Description |
---|---|
userinput | Optional. The natural language utterance of the user. |
viewtype | Required. Tells engine which jsp template to use for the error response. Use value tieapi . |
In addition to the URL parameters above, any other parameter can be included in the request. These can be used to provide additional information to your bot. A pre-processing script in your solution can be used to store them in a variable. More details on that here: Pre-processing.
Response
The engine response is returned in JSON and can consist of the following fields:
Key | Description |
---|---|
status | Always present. Status code. 0 = success, -1 = error, 1 = logout |
input | Optional. Map containing input details included in the request. |
output | Optional. Map containing engine output details. |
message | Optional. String containing message for responses with status other than 0. |
sessionId | Optional. String containing the engine sessionId. See Session Management. |
Input object
Key | Description |
---|---|
text | String containing the input of the user as processed by engine. |
parameters | Map containing the additional parameters that were included in the request. |
Output object
Key | Description |
---|---|
text | String containing the answer text of the output node. |
emotion | String containing the value of the emotion field of the output node. |
link | String containing the output hyperlink field of the output node. |
parameters | Map containing the output node's output parameters. |
Example
Example of a request that contains the following parameters:
Parameter | Value |
---|---|
userinput | What time is it? |
usertimezone | CEST |
viewtype | tieapi |
Request
curl -X POST \
https://some.teneo/engine-url/ \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'userinput=What%20time%20is%20it%3F&usertimezone=CEST&viewtype=tieapi'
Response
json
1{
2 "status": 0,
3 "input": {
4 "text": "What time is it?",
5 "parameters": {
6 "usertimezone": "CEST"
7 }
8 },
9 "output": {
10 "text": "Good afternoon! It's 15:26.",
11 "emotion": "happy",
12 "link": "https://example.com",
13 "parameters": {
14 "displayWidget" : "{\"type\":\"clock\",\"time\":\"15:26\"}"
15 }
16 },
17 "sessionId": "31992FA776A35DABA3291A4EE1031B5F"
18}
19
20
Input and output parameters are strings. If a parameter contains JSON, like the value of the output parameter 'displayWidget' above, the JSON is escaped. When interacting with the Teneo engine directly, you will need to unscape and parse the JSON manually. When using the SDK's, manually parsing the values is not needed as the SDK's handle that for you.
Error response
json
1{
2 "status": -1,
3 "input": {
4 "text": "What time is it?",
5 "parameters": {
6 "usertimezone": "CEST"
7 }
8 },
9 "message": "Teneo backend error",
10 "sessionId": "31992FA776A35DABA3291A4EE1031B5F"
11}
12