Learn how to sending messages to your chatbot using the API and get back a response.
This endpoint allows you to send messages to a chatbot and get back a response. Below are explanations and examples on how to make requests.
Endpoint
Method: POST
https://proxy.botsheets.com/api/v0/chat
Request Headers
Headers:
Authorization: Bearer <YOUR BOTSHEETS SECRET KEY>
"Authorization" is the key and the value should include Bearer plus your Botsheets API Secret Key. You can get a Botsheets Secret Key in your Botsheets account by navigating to Bot Settings > Webhook / API > API Key and Documentation. One Secret Key is used for all chatbots on your Botsheets account.
Content-Type: application/json
This is the type of request you'll make.
Request Body
The body should contain the following:
conversationId
(string, required)
A UNIQUE identifier for the current conversation is required. Botsheets handles the chat history for you. However, each conversation must have a unique conversation ID. We recommend generating a UUID, however there is no schema enforcement besides being a string.
botId
(string, required)
A unique ID for the bot you want to message. Your botID can be found by navigating to Bot Settings > Webhook / API > API Key and Documentation.
message
(string, required)
The latest user message you want to send to the bot. This is the message that will be posted and used to process a response.
Example request:
{
"conversationId": "06811cd5-5595-41b2-98c2-dc108c0473bd",
"botId": "65fa4da045a986ffccec07w3",
"message": "I'm interested in buying a home today!"
}
Example Request
const response = await fetch('https://proxy.botsheets.com/api/v0/chat', {
method: 'POST',
headers: {
Authorization: 'Bearer <API Key>'
},
body: JSON.stringify({
"conversationId": "string",
"botId": "string",
"message": "string"
})
});
curl https://proxy.botsheets.com/api/v0/chat \
-H 'Authorization: Bearer <API Key>' \
-d '{
"conversationId": "string",
"botId": "string",
"message": "string"
}'
Response
Response will be a JSON object in the following format:
{ message: "Chatbot Response" }