Conversations
Conversations
In this section we will talk about how to send/receive messages from a Chatbot, the first step is the creation of the conversation
, once you have the conversation
Id
you will be able to send a message to the Chatbot through a POST
and to receive the message through A GET
, while having the capacity to send context information through the body of the POST request as well.
Important: EDDI has a great feature for conversations with chatbots, it's the possibility to go back in time by using the two API endpoints :
/undo
and/redo
!
Creating/initiating a conversation :
Create a Conversation with a Chatbot REST API Endpoint
Element
Tags
HTTP Method
POST
API endpoint
/bots/{environment}/{botId}
{environment}
(Path
parameter):String
Deployment environment (e.g: restricted
,unrestricted
,test
)
{botId}
(Path
parameter):String Id
of the bot that you wish to start conversation with.
Response Model
Description of the Conversation response model
Element
Tags
botId
(String
) The id of the bot that sent the reply.
botVersion
(integer
) The version of the bot that sent the reply.
userId
(String
) The id of the user who interacted with the bot.
environment
(String
) the name of the environment where the bot is deployed
conversationState
(String
) The state of the current conversation, could be:
READY
,
IN_PROGRESS
,
ENDED
,
EXECUTION_INTERRUPTED
,
ERROR
redoCount
(integer
) if undo has been performed, this number indicates how many times redo can be done (=times undo has been triggered)
conversationOutputs
(Array
: <conversationOutput
>) Array of conversationOutput
conversationOutput.input
(String
) The user's input.
conversationOutput.expressions
(Array
: <String
>) an array of the expressions
involved in the creation of this reply (output).
conversationOutput.intents
(Array
: <String
>) an array of the intents
involved in the creation of this reply (output).
conversationOutput.actions
(Array
: <String
>) an array of the actions
involved in the creation of this reply (output).
conversationOutput.httpCalls
(Array
: <JsonObject
>) an array of the httpCalls
objects involved in the creation of this reply (output).
conversationOutput.properties
(Array
: <JsonObject
>) the list of available properties in the current conversation.
conversationOutput.output
(String
) The final bot's output
conversationProperties
(Array
: <>) Array of conversationProperty
, <nameOfProperty
> is a dynamic value that represents the name of the property
<nameOfProperty>.name
(String
) name of the property.
<nameOfProperty>.value
(String
|JsonObject
) value of the property.
<nameOfProperty>.scope
(String
) scope can be
step
(=valid one interaction [user input to user output]),
conversation
(=valid for the entire conversation),
longTerm
(=valid across conversations [based on given userId])
conversationSteps
(Array
: <conversationStep
>) Array of conversationStep
.
conversationStep.key
(String
) the element key in the conversationStep e.g key : input:initial, actions
conversationStep.value
(String
) the element value of the conversationStep e.g in case of actionq
as key
it could be an array string [ "current_weather_in_city" ]
.
timestamp.timestamp
(dateTime
) the timestamp in (ISO 8601) format
Note
conversationProperties
can also be used in output templating e.g:[[${properties.city}]].
Sample Response
The conversationId
will be provided through the location
HTTP Header of the response, you will use that later to submit messages to the Chabot to maintain a conversation.
Example :
Request URL:
http://localhost:7070/bots/unrestricted/5ad2ab182de29719b44a792a
Response Body
no content
Response Code
201
Response Headers
Send/receive messages
Send a message
Send message in a conversation with a Chatbot REST API Endpoint
Element
Tags
HTTP Method
POST
API endpoint
/bots/{environment}/{botId}/{conversationId}
{environment}
(Path
parameter):String
Deployment environment (e.g: restricted
,unrestricted
,test
)
botId
(Path
parameter):String Id
of the bot that you wish to continue a conversation with.
conversationId
(Path
parameter): String Id
of the conversation that you wish to send the message to.
returnDetailed
(Query
parameter):Boolean
- Default : false
returnCurrentStepOnly
(Query
parameter):Boolean
- Default : true
Request Body
JSON Object , example : { "input": "the message", "context": {} }
The context
here is where you pass context variables that can be evaluated by EDDI, we will be explaining this in more details in Passing Context Information
Example :
Request URL
http://localhost:7070/bots/restricted/5aaf90e29f7dd421ac3c7dd4/5add1fe8a081a228a0588d1c?returnDetailed=false&returnCurrentStepOnly=true
Request Body
Response Code
200
Response Body
Response Headers
Receive a message
Receive message in a conversation with a Chatbot REST API Endpoint
Element
Tags
HTTP Method
GET
API endpoint
/bots/{environment}/{botId}/{conversationId}
{environment}
(Path
parameter):String
Deployment environment (e.g: restricted,unrestricted,test
)
{botId}
(Path
parameter):String Id
of the bot that you wish to continue a conversation with.
{conversationId}
(Path
parameter): String Id
of the conversation that you wish to receive a the message from.
returnDetailed
(Query
parameter):Boolean
- Default : false
Example
Request URL:
http://localhost:7070/bots/unrestricted/5aaf90e29f7dd421ac3c7dd4/5add1fe8a081a228a0588d1c?returnDetailed=false
Response Body
Response Code
200
Response Headers
Undo and redo :
The undo and redo methods basically allow you to return a step back in a conversation, this is done by sending a POST
along with bot and conversation ids to /bots/{environment}/
{botId}
/redo/
{conversationId}
endpoint, the GET
call of the same endpoint with the same parameters will allow you to see if the last submitted undo/redo was successful by receiving a true
or false
in the response body.
Undo and redo in a conversation REST API Endpoint
Element
Tags
HTTP Method
POST
API endpoint
/bots/{environment}/{botId}/[undo/redo]/{conversationId}
{environment}
(Path
parameter):String
Deployment environment (e.g: restricted,unrestricted,test
)
{botId}
(Path
parameter):String Id
of the bot that you wish to continue a conversation with.
{conversationId}
(Path
parameter): String Id
of the conversation that you wish to undo/redo the last conversation step.
Example (undo)
Request URL:
http://localhost:7070/bots/restricted/5aaf98e19f7dd421ac3c7de9/undo/5ade58dda081a23418503d6f
Response Body
no content
Response Code
200
Response Headers
Sample bot:
Last updated