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 two properties: tasks, which allows you to constrain the listen to a subset of tasks, and voice_digits, which allows you to give the user the option to use DTMF in addition to speech for the input if they are interacting with your bot using the voice channel. Autopilot will ignore the voice_digits property on all other channels.

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
voice_digits The tasks you want to trigger for certain DTMF inputs from the user. See example 3. 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"
				]
			}
		}
	]
}

Example 3: Allow the user to use DTMF in addition to speech to provide the input

With the voice_digits property, you can map DTMF inputs provided by the user to the task you want to invoke for those inputs. It has the following properties:

Property Description Optional Default Value Allowed Values
num_digits The number of DTMF inputs you expect from the user yes unlimited positive integers
finish_on_key The key the user should press to submit their input. If not provided, Autopilot will automatically move to the next task after 5 seconds. yes # 0-9, #, *, and '' (the empty string)
redirects The tasks to trigger based on the DTMF input received If not provided, the fallback task is trigerred. N/A

Digits should be mapped to a task's unique name as shown below.

{
	"actions": [
		{
			"say": "Hi, press 1 for sales and 2 for support. Press the pound key when you're done."
		},
		{
			"listen": {
				"voice_digits": {
					"num_digits": 1,
					"finish_on_key": "#",
					"redirects": {
						"1": "task://sales",
						"2": "task://support"
					}
				}
			}
		}
	]
}
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.