AI Chatbot Hub
HomepageAPI docsDiscordLog inSign up
API docs
API docs
  • API usage guides
    • Getting an API key
    • Create a chatbot
    • Chat with chatbot
    • Uploading data sources
  • Chatbots
    • Chatbot properties
    • Create chatbot
    • Update chatbot
    • Fetch a chatbot
    • Fetch all chatbots
    • Delete chatbot
  • Agents
    • Agent properties
    • Create agent
    • Update agent
    • Fetch all agents
    • Delete agent
  • Chatbot sessions
    • Session properties
    • Create session
    • Fetch a session
    • Fetch all sessions
    • Delete session
  • Session messages
    • Message properties
    • Create message
    • Fetch all messages
    • Delete message
    • Delete multiple messages
  • Data sources
    • Source properties
    • Upload a file
    • Create QA source
    • Create URL source
    • Update source
    • Fetch list of sources
    • Retrain sources
    • Delete source
    • Delete multiple sources
  • Data source tags
    • Create source tag
    • Fetch all source tags
    • Update source tag
    • Delete source tag
Powered by GitBook
On this page
  • Endpoint
  • Authorization
  • Path
  • ​Body
  • Request example
  • ​Response example
  1. Session messages

Create message

Create a session message for a chatbot session specified by session uuid

PreviousMessage propertiesNextFetch all messages

Last updated 6 months ago

Endpoint

POST / api / v1 / session / {uuid} / message / stream

Authorization

Authorization string Bearer <your_token>

This API utilizes streaming technique to transmit data, and as a result, it returns the data in the form of a string continuously over the connection. Once the connection is over, you can refetch the list of messages to view the actual data.

Path

uuid string required

Body

query string required

Request example

curl --location --request POST 'https://app.aichatbothub.com/api/v1/session/{uuid}/message/stream' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{"query": "Your query goes here"}'
import requests

uuid = '<session-uuid>'
url = f"https://app.aichatbothub.com/api/v1/session/{uuid}/message/stream"
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

data = {
    "query": "Your query goes here"
}

response = requests.post(url, headers=headers, json=data, stream=True)

if response.status_code == 200:
    for line in response.iter_lines(decode_unicode=True):
        # Process streaming response here
        print(line)
else:
    print("Error:", response.status_code)
const xhr = new XMLHttpRequest();
const uuid = '<session-uuid>'
xhr.open("POST", `https://app.aichatbothub.com/api/v1/session/${uuid}/message/stream`, true);

xhr.setRequestHeader("Authorization", "Bearer <token>");
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");

const data = JSON.stringify({"query": "Your query goes here"});

xhr.send(data);

xhr.onprogress = () => {
    const streamingResponse = xhr.responseText;
    console.log(streamingResponse);
};

xhr.onreadystatechange = () => {
    if (xhr.readyState === 4) {
        if (xhr.status === 200) {
            console.log("Streaming completed successfully");
        } else {
            console.error("Error:", xhr.status);
        }
    }
};

Response example

"Chat streaming response"
​
​