Messaging
POST /api/v1/messages
Send and receive messages from your chatbot.
Params
JSON request body.
clientId string
required
Your client ID from your dashboard.
message string
required
Prompt message to your chatbot.
stream boolean
(default: false)
Whether to stream the response or respond with JSON.
Response
Response can be in one of the following status codes:
Success 200
For immiediate responses.
{
"success": true,
"content": "Chatbot's response"
}For stream responses use the stream parameter and listen to the response stream. Example
Example
Examples which can be used in the browser.
const response = await fetch('http://chatfolio.me/api/v1/messages', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Hello.',
clientId: 'CLIENT_ID',
})
});
const { content } = await response.json();
console.log(content);Message
Message type used for history.
interface Message {
role: 'user' | 'assistant' | 'system';
content: string;
}