API

API Integration allows you to access CosmoBots from another system, serving as a channel that is responsible for processing the sending and returning of messages between the user and the bot.

First you must choose which type of API you want and Enable it.

There are four API types: Messages, Conversations, Intentions and Users.

Below you will have a summary of the chosen API, with the method type, API Url, a brief description and the version.

Authentication

In this section you will have the botid and token required to perform the authentication.

Nome

Tipo

Descrição

botid

string

ID of your bot on CosmoBots: 1866e980-d661-15e7-b7bf-cb2aa1b94640 (Illustrative ID)

token

string

Token key specific to this bot, and can be used in any of the available API services: 2973f350-06db-11e9-92ad-5b7ab3d1568c (illustrative token)

Parameters

Nome

Tipo

Descrição

uid

string

ID of the user who talks to the bot. If it is a new user sending the first message send 'new_user'.

user

object

If you are a new user, you have the option to send the following default user fields: first_name, last_name, email

type

string

Type of message being sent. There can be 5 options: text (plain text), payload (response to clicking a button, for example), image (content of an image), audio (content of an audio), video (content of a video)

time

integer

Date / Time in milliseconds when the message was sent.

data

object

Depending on the type of message defined above, the content / value of this data will be placed here.

Return

Nome

Tipo

Descrição

uid

string

ID of the user who talks to the bot. In return, the ID created for this user will be entered and used in subsequent calls.

time

integer

Date / Time in milliseconds when the message was processed.

data

object

This will place an array containing 1 or more data types returned. There are 6 options of type: text, text_buttons, cards, image, audio (content of an audio), video (content of a video )

Examples

The examples section is for you to understand and test, you can test a Simple Text, Text with Buttons and Cards. Taking into account the two tables above Parameters and Return, let's look at the example below:

In that case we sent the bot a "Hey There" type text. Now let's see how the Return will work:

Last updated