Sending a message
Last updated
Last updated
Sending a message to the chatbot requires you to execute an HTTP POST
requests to this endpoint:
/chats/{id}/message
The id
of the chatbot can be found in the URL of Oswald when configuring the chatbot.
The payload of the POST
request should look like this:
In the following table you can find a detailed description of every value in the payload:
Name
Type
Possible values
Description
message
String
Can be any text value
The message from the user that needs to be sent to the chatbot.
environment
String
"production"
or "test"
The environment of the chatbot, which can be either "production"
of "test"
. The default value expected here is "production"
in which case the published version of the chatbot will be contacted. In special cases the value "test"
can be given to test the development version of your chatbot.
session
String
Can be any value
The session identifier. The value of this parameter can be of your own choosing, but must be unique per user session. When two session identifiers match, Oswald will assume a single conversation.
locale
String
Any valid locale
The locale of the chatbot you want to contact. If the chatbot has that locale configured (e.g. en-gb
) , the correct chatbot will answer your request. If you set this variable to be an unconfigured value, the default locale will be used as a fallback.
If you want to receive the configured startup message from the chatbot, you can send the folowing payload:
In Oswald it's possible to send a metadata payload alongside you main user input. This JSON object can be anythong you want. In an Oswald advanced code response it's possible to read out this object through the sentence
-object: sentence.metadata
. This enables sending more information about the user to the chatbot, such as short lived acces tokens, name, etc.
As a response on your POST
requests, you will receive a JSON-object in the following form:
In this object you can find a lot of information about the sent request and the NLP estimations. The most important property is data
. This is an array of message objects where eacht object can have a different type and properties. These are the objects that will have to be visualized in your frontend. The types can be text, images, urls, carroussels, locations, Youtube links, etc.