Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Listen

The Listen action instructs the Assistant to wait for user input, keeping the dialogue alive. If there is no Listen action the dialogue will end.

The Listen action can have one property: tasks, that allows you to constrain the listen to a subset of tasks.

On messaging channels (including SMS, Chat, FB Messenger, or Slack), the Listen action will wait for user response for 4hrs. If there is no user response the dialogue will timeout.

The Listen action has one optional property:

Property Description Optional
tasks The tasks you want to constrain the listen to. yes

Example 1: Ask a question and wait for an answer

{
	"actions": [
		{
			"say": {
				"speech": "Hello! how can I help you"
			}
		}, {
		    "listen":true
		}
	]
}

In the above example, the Assistant will ask the question and keep the dialogue open waiting for an answer.

Example 2: Constrain the listen to a subset of tasks

With the tasks property, you can constrain the tasks that the Assistant listens to.

{
	"actions": [
		{
			"say": {
				"speech": "What would you like to do? Continue shopping or check out?"
			}
		},
		{
			"listen": {
				"tasks": [
					"search-for-product",
					"checkout"
				]
			}
		}
	]
}
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.