Create message

Post messages to any chat on behalf of a customer
Written by Alexander Shpilka
Updated 5 months ago

With this endpoint you can send messages on behalf of a customer and get response in the same request

  • Key Concepts:

    1. Publishing a new message without specifying a chatId will result in the creation of a new chat.
    In the response, you will receive the chatId of the newly created chat.
    This chatId can be used for future interactions with the chat, such as sending additional/follow-up messages.

    2. If a chatId is specified, the new message will be added to the existing chat. The chat history will be utilized to generate a more contextually accurate response.

    3. You have the option to provide your own messagesHistory which will be taken into account during the generation of the answer.
    , please note that if a chatId is already provided, your custom chatHistory will be disregarded.

➡️ Request

Method POST

Authorization: Bearer <your_api_key>

Accept: application/json

Content-Type: application/json

Read more about authentication headers here.

➡️ Parameters

Parameter Type Description
message string The question to ask the bot.


1 to 1000 characters

applicationId string

The ID of the chat application. You can find it in your application Settings tab.

chatId string

The ID of the chat to publish follow up question.

If not specified, new chat will be created


return_sources boolean Whether to return the sources that were used for answer generation


default: false

format string

How to format the answer.

Can be markdown or text.


default: markdown

messagesHistory array

The chat history array.

Required format:
{"author":"user", "content": {"value":"message text"}}


default: []

user_data object

A user identification object with metadata about the the user. 

Required format:

 "name": "user name", "email": "user email",
 "phone": "user phone"


➡️ Example of request body

    "message": "What is the cheapest plan you offer?",
    "applicationId": "68G4zk6jieG6Z6Nbw6ns",
    "format": "text",
    "return_sources": true,
    "user_data": {"name": "Alex", "email":"[email protected]", "phone": "239847"}

➡️ Example of request (cURL)

curl --location '' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
    "message": "what is the cheapest pricing option you offer?",
    "applicationId": "O8G6666688ZbNbwDns",
    "format": "text",
    "return_sources": true,
    "user_data": {"name": "Alex", "email":"[email protected]", "phone": "239847"},
    "messagesHistory" : [
      {"author":"user", "content": {"value":"Hey how much for Enterprise plan?"}}, 
      {"author":"operator", "content": {"value":"Hi! Can you clarify what features you need from Enterprise plan?"}}

➡️ Example of request (NodeJs)

const axios = require('axios');

const API_TOKEN = '<API_TOKEN>'; // Replace with your actual API token

const data = {
  message: "what is the cheapest pricing option you offer?",
  applicationId: "O8G6666688ZbNbwDns",
  format: "text",
  return_sources: true,
  user_data: {"name": "Alex", "email":"[email protected]", "phone": "239847"},
  messagesHistory : [
    {"author":"user", "content": {"value":"Hey how much for Enterprise plan?"}}, 
    {"author":"operator", "content": {"value":"Hi! Can you clarify what features you need from Enterprise plan?"}}

  method: 'post',
  url: '',
  headers: {
    'Accept': 'application/json',
    'Authorization': `Bearer ${API_TOKEN}`,
    'Content-Type': 'application/json'
  data: data
}).then(response => {
}).catch(error => {

➡️ Example of response 

    "answer":"The cheapest pricing option we offer is the Small plan, which costs $19.99 per month.",
      {"title":"Pricing | LiveReacting", "url":""},
You can utilize the chatId for your next requests for follow-up questions. By doing so, the existing chat history will be reused to generate more accurate responses.

Did this answer your question?