メニュー

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?

say

The Say action instructs an Assistant on what to speak back to the user. Say may contain SSML or plain text.

Simple example: Say Hello World!

{
	"actions": [
		{
			"say": "Hello World!"
		}
	]
}

This Say action would say "Hello World!" and end the dialogue. This is an example of statically-rendered JSON and the Say action is a static Action.

Dynamic example: Say "Hello World" by calling dynamic JSON from a Twilio Function (or another endpoint) instead of the Autopilot Actions bin.

First you'll redirect to the Function from the Actions bin:

{
    "actions": [
        {
            "redirect": "replace-with-your-function.twil.io/dynamicsay"
        }
    ]
}

In the Twilio Function, your Node.js code to say "Hello World" by rendering Actions' JSON dynamically could look like this. This is also where you could add data from the conversation context, like the name of the user, to your bot's response:

exports.handler = function(context, event, callback) {
    let actions = [];
    let say = {
        "say": "Hello World!"
    }
    actions.push(say);
    let respObj = {
    	"actions": actions
    };
    callback(null, respObj);	
};
Rate this page:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。