Output Templates
By Ruben Aegerter ยท Last updated Mar 2024 ยท v4.x
Output Templates are Jovo's platform-agnostic response system. Instead of writing Alexa-specific JSON and Google-specific JSON separately, you define your response once as an Output Template โ and Jovo translates it to the correct format for each platform at runtime.
Overview
In Jovo v4, every handler returns an Output object. The simplest form is a message string:
LAUNCH() {
return this.$send({ message: 'Hello world!' });
}
Under the hood, Jovo converts this into the platform-specific response JSON. For Alexa, this becomes an outputSpeech directive with SSML. For Google, it becomes a simpleResponse. For the web, it becomes a chat message.
Output Properties
| Property | Type | Description |
|---|---|---|
| message | string | The main speech/text output |
| reprompt | string | Follow-up prompt if user doesn't respond |
| listen | boolean | Keep the mic open (true) or end session (false) |
| card | object | Visual card for screen-enabled devices |
| carousel | object[] | Scrollable list of items |
| platforms | object | Platform-specific overrides (APL, Chips, etc.) |
Platform-Specific Responses
Use the platforms property to add platform-specific features alongside your generic response:
return this.$send({
message: 'Here are some options.',
platforms: {
alexa: {
nativeResponse: {
// Alexa APL directive
directives: [{ type: 'Alexa.Presentation.APL.RenderDocument', ... }]
}
},
googleAssistant: {
nativeResponse: {
suggestions: [{ title: 'Option A' }, { title: 'Option B' }]
}
}
}
});
SSML Support
Jovo automatically wraps your message in <speak> tags when sending to voice platforms. You can also use SSML directly:
message: '<speak>Welcome <break time="500ms"/> to the quiz!</speak>'
i18n / Internationalization
Output Templates work seamlessly with Jovo's i18n system. Store your messages in a CMS (Google Sheets, Airtable, Sanity) or local JSON files, and reference them by key:
message: this.$t('welcome_message')
See Google Sheets CMS Tutorial for a complete walkthrough of CMS-driven content.