Chat with a Bot

This API allows you to interact with a Chatbot.


Generate your own API Key

The first thing you have to do to access Ollabot API, is by generating your own API Key. You can generate your API Key by following the steps here: Generate API Key.

Chat API Guide

The Chat API allows you to send a message to an existing chatbot by making a POST request to the /api/v1/chat endpoint using the user's API key.

Endpoint

POST https://app.ollabot.com/api/v1/chat

Request Headers

The API request must include the following headers:

  • Authorization: Bearer <User-Api-Key> - The user's API key for authenticating the request.
  • Content-Type: multipart/form-data - The content type of the request payload.

Parameters

The request body should contain the following parameters:

  • botId (string, required): The unique identifier of the chatbot.
  • message (string, required): The message to send to the chatbot.
  • description (string, optional): A description or additional context for the message.
  • file (file, optional): An optional file to send with the message.

Example Request

JavaScript

const formData = new FormData();
formData.append('botId', 'exampleId-123');
formData.append('message', 'Hello, chatbot!');
formData.append('description', 'A brief description of the chat context.');
formData.append('file', fileInput.files[0]);
 
const res = await fetch('https://app.ollabot.com/api/v1/chat', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer <User-Api-Key>`,
  },
  body: formData,
});
 
const data = await res.json();
console.log(data);

Python

import requests
 
url = 'https://app.ollabot.com/api/v1/chat'
headers = {
    'Authorization': 'Bearer <User-Api-Key>'
}
files = {
    'file': open('path/to/file', 'rb'),
}
data = {
    'botId': 'exampleId-123',
    'message': 'Hello, chatbot!',
    'description': 'A brief description of the chat context.'
}
 
response = requests.post(url, headers=headers, data=data, files=files)
print(response.json())

Shell

curl -X POST https://app.ollabot.com/api/v1/chat \
  -H "Authorization: Bearer <User-Api-Key>" \
  -H "Content-Type: multipart/form-data" \
  -F "botId=exampleId-123" \
  -F "message=Hello, chatbot!" \
  -F "description=A brief description." \
  -F "file=@path/to/file"

Response

The API response will be a JSON object with the chatbot's reply:

{
  "response": "Hello, how can I help you?"
}

Error Handling

If there are any errors during the API request, appropriate HTTP status codes will be returned along with error messages in the response body. Make sure to handle these errors gracefully in your application.