Answer a Question With Choices

Now let’s get the bot to respond to the customer with a question. A bot can send questions with a selection of answers to choose from, and the customer can select the answer with choice buttons or type it. This type of question is sent in a choice message. The message has the choices message type in the messages array of the response payload with the ChoicesResponseMessage schema in the API reference doc.

In this example, the bot asks what language (English, Spanish, or Japanese) the customer wants to communicate in.

Let’s say the customer answers by clicking the “Spanish” button. The request has the ChoiceMessage schema for the message object in this request body.

When the customer answers by clicking a button, the request contains the choiceId for the answer.

If the customer types an answer, use the TextRequestMessage schema for the message object in the request body. If a valid answer isn’t provided to the choice question, the bot sends the question again. Here’s an example of a customer that types “Español” as their answer.