Find the answer you are looking for

Information about the Messaging API

The Messaging API lets you use the Virtual Assistant conversational engine in channels without a direct integration. For example, if you want to embed the bot inside an application without opening the chat window, or integrate it into your own channel, the API is the right path.

It is a stateful conversational API that operates through a single endpoint. "Stateful" refers to a system or application that keeps information about previous interactions so it can continue processes or respond in context.

Each interaction represents one conversation turn: you send a message (sentence) and receive a response from the Virtual Assistant along with optional UI components (complements).

The Virtual Assistant's response arrives in the same HTTP response as each message, with the corresponding text and complements. The API does not use webhooks or send "push" messages: each response is obtained by sending a message.

⚠ This type of integration requires a development team due to its level of complexity.

📄 Here you will find all the documentation you need to use the Messaging API: Conversation Public Api

⏩ General flow: the integration follows this cycle:

  1. You must authenticate with a username and password and obtain a Bearer Token (JWT).
  2. Request the channel's X-Token through a Service Request in the Support Center.
  3. With the Bearer Token you obtained and the X-Token you received, send messages to the conversation endpoint along with the user's data.
  4. The Virtual Assistant responds with text and, optionally, UI components (buttons, lists, etc.).
  5. The cycle repeats until the user ends the interaction or is transferred to a human agent.
⚠ Through the user parameter, you can send additional data to use in Integrations or to save the user's information in the Chat Report.  

⏩ Authentication: You must obtain the Bearer Token required for all calls to the Messaging API.

Endpoint: POST https://gateway.aivo.co/api/v1/auth

  1. The Bearer Token lasts 10 hours and can be reused. We recommend not generating a new token for every request.
  2. The user is created based on the email address you provided; the password is defined by your team.

⏩ Sending messages: All interactions (queries, flows, actions) are made through this single endpoint, which is the main endpoint of the conversational API.

Endpoint: POST https://gateway.aivo.co/api/v1/conversation/messages

↘ Required headers

HeaderType
RequiredDescription
Content-TypestringYesAlways application/json
X-TokenstringYes Token provided by your team
Authorizationstring Yes Bearer token obtained from the Auth API

↘ Request Body example

{
"sentence": "Hello",
"user": {
"hash": "rTC8N6bN88D5KjRvXQ4HlmJ4fFyPt883",
"name": "Juan",
"lastname": "Perez",
"email": "juan.perez@example.com"
}
}

Field
TypeRequiredDescription
sentencestringYesThe user's message, the option chosen by the user, or the intent that starts the desired flow.
userobjectYes User data.
user.hashstringYes Unique user identifier (keeps the session). It must be exactly 32 characters long; otherwise, the API returns an error.
user.idstringNo

Unique user ID. It is optional; if sent, it is usually the same as the hash.

user.namestringYes
User's first name.
user.lastnamestringYes
User's last name.
user.emailstringYes User's email address.
⚠ You do not have to use real data. The name, last name, and email fields do not necessarily need to contain the user's real information.

⏩ Key facts about Complements 

Complements let you display content in a friendlier way, with visual and interactive formats, making it faster to read and understand than plain text alone. When implementing them through the API, your technical team must build them entirely. The API only provides the information as JSON.

  1. Image: returns an image link and a reference ID to position it when there are placeholders available in the text, such as { ref: xxxx}.
  2. Cobrowsing: the chat history cannot be preserved when redirecting to another page unless this is specifically implemented.
  3. Transfer to an online human agent via open_agentlive/Firebase (customToken, Room).
    1. Response with derivation to a human agent: when the flow requires human attention, the response includes a specific complement. How to detect and process it:
      1. Look for the route complements with param = "live".
      2. Extract the customToken from open_agentlive to authenticate against the live chat service (Firebase).
      3. Room identifies the room assigned to the user.
      4. Live_agent is null until an agent takes the session.
  4. Forms: arrive in "callback" format, one field at a time. If the channel adapts them to callback, they will work correctly.
    1. Dropdown menu: not supported by the API. The options do not arrive correctly.
  5. Existing integrations: If you already have integrations, you do not need to adjust them when migrating to the API. However, if they contain complements (carousel, buttons, etc.), you need to validate that they work in the channel where you implement them. The integration_response field indicates that the response was processed by an integration.
  6. Buttons: Let you add a button with a link or a question, in the form of options for the user.
    1. If the button is of type "Next step", the next interaction must be the "label" of the option chosen by the user. The expected behavior is to advance the flow.
    2. If the button is of type "Message", the next interaction must be the "value" of the option chosen by the user. The expected behavior is to send a message.
    3. For links, the URL format is validated (https), and you can choose whether it opens in the same window (_self) or a new one (_blank). When the user opens the link, you do not need to send any message to the Messaging API.
  7. Interactive dropdown list: the behavior is the same as the message button type, and the next interaction must be the ID of the item chosen by the user.
Type
Behavior What to send as a sentence 
Next step buttonAdvances the flow
The button's LABEL
Message button
Sends a message
The button's VALUE
Interactive listSends a message

The ID of the item chosen by the user.

ℹ The value field of step-type buttons is an internal reference. Never send it as a sentence.
Field
TypeDescription
blockInputbooleantrue: the user can only choose a button;
false: the user can also type
oneChoiceboolean  true: the button disappears after being selected
ℹ For full integration with human agents, consult the CSM team about the Live APIs and Webhooks documentation.

↘ Other formats:

  1. Conditions: if you need conditional content (for example, different answers by country), you must use a separate channel for each condition. When making the request from the Messaging API, you must use one channel or the other, sending the corresponding token. Example:
    1. If you want to differentiate the response for customers in Argentina and Uruguay, you will need two channels on the platform, each conditioned on "Argentina" and "Uruguay". When making the request from the Messaging API, you must send the Argentina channel's xtoken for requests from Argentina and the Uruguay channel's xtoken for requests from Uruguay.
  2. Satisfaction surveys: there are no events or ways to send satisfaction surveys through the API.
⚠ Aivo does not provide support for the external tools used for the integration, as they are platforms outside the Suite.

⏩ Session management:

  1. The API maintains one conversational session per user. Understanding the session is key to integrating correctly.
  2. The session is identified by user.hash, which must be exactly 32 characters long.
  3. All calls with the same hash belong to the same session.

↘ Lifecycle

Event
Description
Action you must take
StartCreated when the first message with a hash is sent.
Send the initial sentence with the user's data
Active
Each message keeps the session alive and accumulates context.
Keep sending sentences according to the flow
Expiration
Expires due to inactivity (configurable timeout).
Detect the expiration and start a new session
Explicit closeClosed with POST /api/v1/conversation/events/close
Call close when finished.
Transfer to liveThe route changes to live and the conversation passes to a human agent.Open the Live channel with the customToken.  

↘ Closing the conversation:

  1. We recommend explicitly closing the session when the user finishes the interaction, with POST https://gateway.aivo.co/api/v1/conversation/events/close, sending the conversation's user.hash.
  2. If the session is not closed explicitly, it expires automatically according to the TTL (Time to Live), the mechanism that sets the maximum duration of an active session.

↘ Signs of an expired session:

  1. The response does not match the flow in progress.
  2. user_data loses variables accumulated during the flow.
  3. The route changes unexpectedly.

↘ Recommended action for an expired session:

  1. Re-authenticate.
  2. Obtain a new Bearer token.
  3. Resend the flow's initial sentence.
  4. Let the user know that the session was restarted.

⏩ User data variables: The user_data complement contains the accumulated state of the session. As the user progresses, useful variables are added for debugging and tracking.

↘ Variables common to all flows

VariableTypeDescription
canal_nombrestringChannel name (e.g., HELP- Messaging API).
canal_tipostringChannel type (e.g., Web)
emailstringUser's email address
idstringUser ID/hash
namestringUser's first name
lastnamestring

User's last name

lastSessionIdstringID of the last active session
ℹ Analytics: channels implemented with the API are analyzed under the "Public API" filter. It is not possible to distinguish between multiple channels connected through the API.

📚 See also:

FAQs and best practices for the Messaging API

Error mapping and technical considerations for the Messaging API

This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience and for analytics and metrics about our visitors both on this website and other media. To find out more about the cookies we use, see our Privacy Policy.

If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference not to be tracked.