ChatBot Client Development Guide
You need the following to implement a Studio ChatBot for your platform or front end.
-
Create a ChatBot task. See Creating Tasks.
-
For the ChatBot task, gather the Task Key and API Info.
-
From the Build menu, select Tasks.
-
From the tabs at the top of the screen, select ChatBot.
-
Select the ChatBot task.
-
From the task details to the right of the screen, copy the Task Key. Paste the key where you have ready access to it, and for your own records.
-
From the Actions menu, select API Info.
-
Restful API Requests
Restful API | Description |
---|---|
POST |
Send HTTP POST requests to the Studio Base URL. See Studio API Resource Guide. |
HEADERS |
In the request header, set Content-Type: application/json |
BODY |
In the request body, send parameters as raw JSON. |
Parameters
Send these parameters as raw JSON in the body of the Restful API request.
Parameter | Required? | Description |
---|---|---|
api_key |
REQUIRED |
Identifies the Studio account. To source your account ID, from the Studio interface select Manage | Account Profile. System and Service Provider API keys do not work with ChatBot. |
task_key |
REQUIRED |
Identifies the ChatBot task. To source the task key, open the dashboard for ChatBot tasks and select the task to show more detail. |
session_id |
OPTIONAL |
Identifies the session (or conversation). To start the conversation, use an empty session ID. The first API response returns the session ID. Use this session ID for the rest of the session. |
text |
OPTIONAL |
Contains the user response (text) to send to the ChatBot. |
message_json |
OPTIONAL |
Use with your chat client to send information in addition to regular chat messages. The parameter value must be a valid JSON object. The JSON object is in the ChatBot task as an array variable called LAST_MESSAGE_JSON. Studio only supports single level JSON objects. JSON objects deeper than one level are not supported and will result in unexpected values in the LAST_MESSAGE_JSON variable. |
user_key |
OPTIONAL |
Use to identify a user or other information. |
Starting a Conversation
Post an empty session ID.
{
}
The First API Response
The API returns a unique session ID to use for the remainder of the session.
{
}
Continuing the Conversation
Use the session ID returned in the first API response to continue the conversation.
{
}
The Final API Response
The API returns an empty session ID with status 204 if you do not send a response within the defined timeout for the ChatBot task.
The conversation is complete. The session ID is no longer valid.
{
}