API
In this guide, we go through the steps necessary to integrate your custom Quickchat AI Assistant with your product via an API endpoint.
Authentication
Include your API Key and scenario_id in every request.
In order to obtain your API key, upgrade your subscription to include API Access.
Chat
Initialise new conversation / new user history
- Shell
- Python
curl https://chat.quickchat.ai/chat \
-H 'Content-Type: application/json' \
-d '{
"api_key": "<API_KEY>",
"scenario_id": "<SCENARIO_ID>",
"text": "Hello!"
}'
import requests, json
response = requests.post(
url="https://chat.quickchat.ai/chat",
json={
"api_key": "<API_KEY>",
"scenario_id": "<SCENARIO_ID>",
"text": "Hello!"
})
if response.status_code == 200:
data = json.loads(response.content)
else:
raise ValueError(
"Error code {}: {}".format(
response.status_code,
response.content.decode('utf-8')))
The above command returns JSON structured like this:
{
"ord_number": 2,
"conv_id": "abcd1234",
"reply": "Hey there! 🙂"
}
conv_id
is an optional parameter. Request which does not contain conv_id starts a new conversation and newly-generated conv_id is returned.
Associate conv_id with your particular user to maintain conversation context across time and multiple user interactions.
This endpoint performs a single conversation exchange.
HTTP Request
POST https://chat.quickchat.ai/chat
Query Parameters
Parameter | Type | Description |
---|---|---|
api_key | string | Create an account and subscribe to obtain your API key |
scenario_id | Text | ID associated with your Quickchat API implementation. |
text | string | User input message |
Send message to the AI Assistant
- Shell
- Python
curl https://chat.quickchat.ai/chat \
-H 'Content-Type: application/json' \
-d '{
"api_key": "<API_KEY>",
"scenario_id": "<SCENARIO_ID>",
"conv_id": "abcd1234",
"text": "Hello!"
}'
import requests, json
response = requests.post(
url="https://chat.quickchat.ai/chat",
json={
"api_key": "<API_KEY>",
"scenario_id": "<SCENARIO_ID>",
"conv_id": "abcd1234",
"text": "Hello!"
})
if response.status_code == 200:
data = json.loads(response.content)
else:
raise ValueError(
"Error code {}: {}".format(
response.status_code,
response.content.decode('utf-8')))
The above command returns JSON structured like this:
{
"ord_number": 236,
"reply": "Hey, great to hear from you again! 😉"
}
HTTP Request
POST https://chat.quickchat.ai/chat
Query Parameters
Parameter | Type | Description |
---|---|---|
api_key | string | Create an account and subscribe to obtain your API key |
scenario_id | string | ID associated with your Quickchat API implementation. |
conv_id | string (Optional) | Identify a particular conversation/user. |
text | string | User input message. |
Errors
Below we have gathered the error codes which may be returned by the API, together with their description and possible solutions.
Code | Description | Action |
---|---|---|
400 | The following parameters must be provided: api_key , scenario_id , text | Please make sure all required parameters are provided. |
400 | conv_id abcd1234 does not exist | Please ensure that conv_id you are referring to is correct. |
401 | Unauthorized | Please make sure that your api_key and scenario_id are correct (see Integrations - API in the App). |
500 | Internal Server Error | There is an issue on our side. Please get in touch with support. |
503 | Service Unavailable | Our servers are overloaded or temporarily unavailable due to maintenance. If problem persists, please get in touch with support. |