Send a Message to the Bot
Let’s stick with the example where the bot greets the customer with a welcome message and a choices menu (see Retrieve the Bot’s Response for the JSON response body).
There are two methods that the customer can use to send an answer back to the bot.
Method 1: The customer answers the bot with a choice
label, for example, “1” for “Order Status”. The message object of the request has the
TextMessage type in this case.
Method 2: The customer answers the bot by selecting a menu choice. The message object of the request has the
ChoiceMessage type and a
choiceIndex(). The index starts with 0, for example, “Order Status” has an index of 0.
Now, build the request with the message.
Then extract the bot’s message from the response envelope.
Here is an example output to the customer stating what the order status is.