Learn how to retrieve a conversation history.
This endpoint allows you to get a conversation history. Below are explanations and examples on how to make requests.
Endpoint
Method: GET
https://proxy.botsheets.com/api/v0/conversations/history
Request Headers
Headers:
Authorization: Bearer <API 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)
The ID for the bot the conversation is with. Your botID can be found by navigating to Bot Settings > Webhook / API > API Key and Documentation.
Example:
{
"conversationId": "06811cd5-5595-41b2-98c2-dc108c0473bd",
"botId": "65fa4da045a986ffccec07w3",
}
Example Request
const response = await fetch('https://proxy.botsheets.com/api/v0/conversations/history', {
method: 'POST',
headers: {
Authorization: 'Bearer <API Key>'
},
body: JSON.stringify({
"conversationId": "string",
"botId": "string"
})
});
curl https://proxy.botsheets.com/api/v0/conversations/history \
-H 'Authorization: Bearer <API Key>' \
-d '{
"conversationId": "string",
"botId": "string"
}'
Response
Response will be a JSON object containing a list of messages in the following format:
{ history: [
{
"assistant": "Message"
},
{
"user": "Message"
},
...
]}