Skip to main content

Bot replies

You can use JAICP to transmit various bot replies in a uniform format, such as images or buttons. The replies transmitted will then be converted to the channel-specific format.

tip
You can also use DSL tags or methods from the $reactions built-in service to generate bot replies.

Generating bot replies​

Bot replies are generated via the $response variable. All replies are added to the $response.replies array. To add a new reply, you need to call the push method.

Before adding a new reply in the array, you need to initialize the replies field in the $response variable. If the field is not initialized, the $response.replies value will be undefined. In this case, when the bot starts executing its reactions, the following error will be returned: Cannot read property “push” from undefined.

Therefore, if the replies field was initialized earlier (the state already has reactions called via DSL tags or built-in methods), assign the same value to it. Otherwise, assign an empty array.

var reply = {"type": "telegramPayment"};
// Reply properties initialization.
// ...
// Reply array initialization.
$response.replies = $response.replies || [];
$response.replies.push(reply);

Restrictions​

  1. One bot response can contain no more than 100 elements in the $response.replies array. Their total length cannot exceed 50,000 characters.

  2. Bot replies are specific to each channel: a channel can have a number of its own restrictions on the passed properties or not support the reply type at all. Each article lists the channels that support a particular reply type. You can also refer to the Channel features and restrictions article to find out what restrictions some channels have on the selected reply type.

Reply types​

The platform supports the following reply types:

TypeDescription
audioSend an audio recording.
buttonsDisplay a button.
carouselDisplay a list of elements to select one of them.
context-switch
context-return
Switch and return the dialog context from one bot to another.
crmIntegrationIntegration with the Bitrix24 CRM system.
dtmfRequest a DTMF message from the user (numbers and letters in the tone mode). Phone channel only.
fileSend a file.
hangupAbort a call. Phone channel only.
imageSend an image.
inlineButtonsDisplay an inline button.
llmRequestUse LLMs with minimal pauses. Phone channel only.
locationSend coordinates.
rawCan be used to transmit channel-specific methods.
smsSend an SMS message.
switchSwitch the conversation from the bot to an agent.
textA simple text response; each response is output as a single message.
telegramPaymentSend a payment form for services or goods in Telegram.
telegramPaymentPrecheckoutCheck the goods availability before checkout.
timeoutConfigure switching to a certain state if there is no response from the user.
videoSend a video.