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

メニュー

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?

見る

The Show action is responsible for rendering content to devices with screens.

At its most basic, a show action instructs the end device to display its body text verbatim. The show action may also wrap several properties that allow users to describe common output fields, such as subject, body, and images. These can be used to describe text with more detail to allow richer output on devices that support it.

Simple example: Show text

{
	"actions": [
		{
			"show": {
				"body": "Hello World!"
			}
		}
	]
}

Rich example: Display text and an image

{
	"actions": [
		{
			"show": {
				"body": "Twilio Owls",
				"images": [ {
				    "label": "Original Owl",
				    "url": "https://demo.twilio.com/owl.png"
				    
				}]
			}
		}
	]
}

Body

Body is a property of the Show action. The text defined by a Body property is used as the main text body for end devices that support richer text output formats. For simpler formats, the body is the only data displayed.

Images

Images is a list property of the Show action. Images specify images to attach to richer output formats. Every object has two attributes: url which points to a jpg or png file, and label which is an optional tag that can be used for slotting into rich media formats with specific positioning slots. If you test your Autopilot bot in the Simulator, images will show only if they are below 60 kB.

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

Dynamic example: Display text and an image from a Twilio Function, making your Action dynamic. Your Autopilot task may look like this:

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

Your replace-with-your-function.twil.io/dynamicshow Function could contain the following Node.js code to call dynamic JSON to display text and an image for your Autopilot task.

exports.handler = function(context, event, callback) {
    let actions = [];
    let show = {
        "show": {
            "body": "Twilio Owls", 
            "images": [{ 
                "label":"Original Owl",
                "url":"https://demo.twilio.com/owl.png"
            }]
        }
    }
    actions.push(show);
    let respObj = {
    	"actions": actions
    };
    callback(null, respObj);	
};
Rate this page:

ヘルプが必要ですか?

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