Jovo Response Object

Learn more about the Jovo $response object.

Introduction

Learn more about the Request & Response Lifecycle here.

The $response object offers helpful features to access information from the response that is sent back to the platform (e.g. Amazon Alexa or Google Assistant).

You can access the response object like this:

The response gets assembled from the $output object in the platform.output middleware, and then sent back to the platform in the response middleware.

Cross-Platform Methods

Response Setters

Method Description
setSessionData(sessionData: SessionData) Setts session data. Learn more about session data here.

Response Getters

For some use cases (especially Unit Testing), it might be helpful to get information from a response object, like this.$response.getSpeech().

You can use these cross-platform helper methods:

Method Description
getSpeech(): string Returns speech text without "speak" and tags.
getReprompt(): string Returns reprompt text without "speak" tags.
hasSessionData(name: string, value?: any): boolean Checks if response has a specific session attribute in it.
getSessionData(): SessionData | undefined Returns session data. Learn more about session data here.
hasSessionEnded(): boolean Returns true if session ended
hasState(state: string): boolean Checks if response has state in it

Platform Specific Methods

Alexa Methods

Alexa Response Getters

Method Description
hasAskForAddressCard(): boolean Checks that Alexa permissions card is present and contains read::alexa:device:all:address
hasAskForCountryAndPostalCodeCard(): boolean Checks that Alexa permissions card is present and contains read::alexa:device:all:address:country_and_postal_code
hasLinkAccountCard(): boolean Checks that Alexa LinkAcount card is present.
hasStandardCard(title?: string, text?: string, smallImageUrl?: string, largeImageUrl?: string): boolean Checks if response has a standard Alexa card.
hasSimpleCard(title?: string, text?: string): boolean Checks if response has a simple Alexa card.
hasAplDirective(): boolean Checks if response APL directive.
hasDisplayDirective(): boolean Checks if response has display template directive.
hasAudioDirective(): boolean Checks if response has audio directive.
hasVideoDirective(): boolean Checks if response has video directive.
getDirectives(): Directives object | undefind Returns entire directives object from response.
getAplDirective(): APL object | undefind Returns APL object from response.
getDisplayDirective(): Display object |undefind Returns Display Template object from response.
getAudioDirective(): Audio object | undefind Returns Audio Player object from response.
getVideoDirective(): Video object | undefind Returns Video Player object from response.

Comments and Questions

Any specific questions? Just drop them below or join the Jovo Community Forum.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.