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:
プロパティ | 概要 | オプション |
tasks | The tasks you want to constrain the listen to. | はい |
voice_digits | The tasks you want to trigger for certain DTMF inputs from the user. See example 3. | はい |
barge |
In Programmable Voice it controls whether the bot should stop saying and start listening when the user talks. Defaults to |
はい |
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:
プロパティ | 概要 | オプション | 初期値 | 許容値 |
num_digits | The number of DTMF inputs you expect from the user | はい | 無制限 | 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. | はい | # |
0 ~ 9、#、*、および空文字列 |
redirects | The tasks to trigger based on the DTMF input received | If not provided, the fallback task is trigerred. |
該当なし |
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" } } } } ] }
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。