Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

App Logic > Output

In this section, you will learn how to use Jovo to craft a response to your users.

Introduction to Output Types

What do users expect from a voice assistant? Usually, it's either direct or indirect output in form of speech, audio, or visual information. In this section, you will learn more about basic output types like tell, ask, but also how to use SSML or the Jovo speechBuilder to create more advanced output elements.

Basic Output

Jovo's basic output options offer simple methods for interacting with users through text-to-speech. If you're interested in more, take a look at Advanced Output.

tell

The tell method is used to have Alexa or Google Home say something to your users. You can either use plain text or SSML (Speech Synthesis Markup Language).

Important: The session ends after a tell method, this means the mic is off and there is no more interaction between the user and your app until the user invokes it again. Learn more about sessions here.

this.tell(speech);

// Use plain text as speech output
this.tell('Hello World!');

// Use SSML as speech output
this.tell('<speak>Hello <say-as interpret-as="spell-out">World</say-as></speak>');

ask

Whenever you want to make the experience more interactive and get some user input, the ask method is the way to go.

This method keeps the mic open (learn more about sessions here), meaning the speech element is used initially to ask the user for some input. If there is no response, the reprompt is used to ask again.

this.ask(speech, reprompt);

this.ask('How old are you?', 'Please tell me your age');

You can also use SSML for your speech and reprompt elements.

Multiple Reprompts

Google Assistant offers the functionality to use multiple reprompts.

this.ask(speech, [reprompt1, reprompt2, goodbyeMessage]);

You can find more detail about this feature here: Platform Specific Features > Google Assistant > Multiple Reprompts.

Advanced Output

Voice platforms offer a lot more than just converting a sentence or paragraph to speech output. In the following sections, you will learn more about advanced output elements.

SSML

SSML is short for "Speech Synthesis Markup Language." You can use it to can add more things like pronunciations, breaks, or audio files. For some more info, see the SSML references by Amazon, and by Google. Here’s another valuable resource for cross-platform SSML.

Here is an example how SSML-enriched output could look like:

let speech = '<speak>Welcome to this Pizza Skill.'
      + 'Don\'t we all want some <say-as interpret-as="spell-out">pizza</say-as>'
      + 'in our life? <break time="1s"/> Oh yes.'
      + '<audio src="https://www.jovo.tech/downloads/pizza.mp3"/></speak>';

this.tell(speech);

But isn’t that a little inconvenient? Let’s take a look at the Jovo speechBuilder.

speechBuilder

With the speechBuilder, you can assemble a speech element by adding different types of input:

let speech = this.speechBuilder()
                .addText('Welcome to this Pizza Skill.')
                .addBreak('300ms')
                .addAudio('https://www.jovo.tech/downloads/pizza.mp3');

this.tell(speech);

You can find everything about the SpeechBuilder here: App Logic > Output > SpeechBuilder.

i18n

Jovo uses a package called i18next to support multilanguage voice apps.

Here's the detailed documentation for it: App Logic > Output > i18n.

Raw JSON Responses

If you prefer to return some specific responses in a raw JSON format, you can do this with the platform-specific functions alexaSkill().setResponseObject and googleAction().setResponseObject.

// Set a Raw JSON Response for Alexa
this.alexaSkill().setResponseObject(obj);

// Set a Raw JSON Response for Google Assistant
this.googleAction().setResponseObject(obj);

Learn more about platform-specific features and resonses here: Platform Specifics.

Visual Output

The Jovo framework, besides sound and voice output, can also be used for visual output.

Learn more about visual output here: App Logic > Output > Visual Output.

No Speech Output

Sometimes, you might want to end a session without speech output. You can use the endSession method for this case:

this.endSession();