ChatBot Client Development Guide

You need the following to implement a Studio ChatBot for your platform or front end.

  • Studio API Resource Guide

  • Create a ChatBot task. See Creating Tasks.

  • For the ChatBot task, gather the Task Key and API Info.

    1. From the Build menu, select Tasks.

    2. From the tabs at the top of the screen, select ChatBot.

    3. Select the ChatBot task.

    4. 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.

    5. 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.

Example:

{

"api_key": "re51itj458rhjvd565cu205931aldjr098df",
"task_key": "CHAT000003a5qc",
"session_id": "",
"text": "",
"user_key": "123456"

}

The First API Response

The API returns a unique session ID to use for the remainder of the session.

Example:

{

"status": 200,
"session_id": "c45ff7def52641b88d8aaa2bcd7abbd8",
"message": "Hi, how can I help you?"

}

Continuing the Conversation

Use the session ID returned in the first API response to continue the conversation.

Example:

{

api_key: "re51itj458rhjvd565cu205931aldjr098df",
task_key: "CHAT000003a5qc",
session_id: "c45ff7def52641b88d8aaa2bcd7abbd8",
text: "I need to make an appointment",
user_key: "123456"

}

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.

Example:

{

status: 204,
session_id: "",
message: "Thanks and Good Bye."

}