Chat with chatbot
How to start chatting with your chatbot using the AI Chatbot Hub API
Before beginning, please make sure you meet the following prerequisites.
Prerequisites
An API key to access the AI Chatbot Hub API.
A development environment or tool for making HTTP requests, like Curl or a programming language such as Python.
To chat on specific topics, your chatbot needs relevant data sources uploaded.
Creating a Chat Session
Why Create a Chat Session?
Before you can send messages to the chatbot, it’s essential to create a chat session. A chat session acts as a container that organizes all messages exchanged between you and the chatbot. Here’s why this is important:
Message Context: A chat session preserves the conversation’s context, ensuring that the chatbot understands the flow of your questions or statements.
Order of Messages: The chat session maintains the sequence of messages, allowing for meaningful and coherent exchanges.
State Management: By referencing the session UUID, you can seamlessly continue a conversation, effectively managing the chat's state.
How to Create a Chat Session
To create a chat session, send a POST request to the following API endpoint:
https://app.aichatbothub.com/api/v1/chatbot/{chatbot_uuid}/session/create
Make sure to replace {chatbot_uuid}
with your specific chatbot's UUID.
Example Request
Here’s an example command for creating a chatbot session using the AI Chatbot Hub API. Replace <token>
with your actual API key.
This API request returns JSON data that can be used for sending messages:
The uuid
from this response is essential for sending messages within the established chat session and will be used in the next steps.
Chatting Within a Session
Sending Messages
With a chat session created, you can now send messages to your chatbot. Use the following API endpoint to send messages and receive a streamed AI response:
https://app.aichatbothub.com/api/v1/session/{session_uuid}/message/stream
Replace {session_uuid}
with the UUID from the chat session creation response.
Example Request
Below is an example command for sending a message using the AI Chatbot Hub API. Replace <token>
with your actual API key.
That’s it! You’ve now learned how to start a conversation with your chatbot using the AI Chatbot Hub API.
Last updated