RichResponse

Class representing a rich response

These classes construct v1&v2 message objects for Dialogflow v1 Message object docs: https://dialogflow.com/docs/reference/agent/message-objects v2 Message object docs: https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/projects.agent.intents#Message

Kind: global class

richResponse.setPlatform(platform) ⇒ RichResponse

Set the platform for a specific RichResponse (optional)

Kind: instance method of RichResponse

Param Type Description
platform string representing desired rich response target platform

Example
js let richResponse = new RichResponse(); richResponse.setPlatform(PLATFORMS.ACTIONS_ON_GOOGLE)

Card ⇐ RichResponse

Class representing a card response

Kind: global class
Extends: RichResponse

new Card(card)

Constructor for Card object.

Param Type Description
card string | Object response title string or an object representing a card response

card.setTitle(title) ⇒ Card

Set the title for a Card

Kind: instance method of Card

Param Type Description
title string containing the title content

Example
js let card = new Card(); card.setTitle('sample card title')

card.setText(text) ⇒ Card

Set the text for a Card

Kind: instance method of Card

Param Type Description
text string containing the card body text content

Example
js let card = new Card(); card.setText('sample card body text')

card.setImage(imageUrl) ⇒ Card

Set the image for a Card

Kind: instance method of Card

Param Type
imageUrl string

Example
js let card = new Card(); card.setImage('https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png');

card.setButton(button) ⇒ Card

Set the button for a Card

Kind: instance method of Card

Param Type Description
button Object JSON configuration
options.text Object button text
options.url Object button link URL

Example
js let card = new Card(); card.setButton({ text: 'button text', url: 'https://assistant.google.com/' });

card.setPlatform(platform) ⇒ RichResponse

Set the platform for a specific RichResponse (optional)

Kind: instance method of Card

Param Type Description
platform string representing desired rich response target platform

Example
js let richResponse = new RichResponse(); richResponse.setPlatform(PLATFORMS.ACTIONS_ON_GOOGLE)

Suggestion ⇐ RichResponse

Class representing a suggestions response

Kind: global class
Extends: RichResponse

new Suggestion(suggestion)

Constructor for Suggestion object

Param Type Description
suggestion string | Object title string or an object representing a suggestion response

suggestion.setReply(reply) ⇒ Suggestion

Set the reply for a Suggestion

Kind: instance method of Suggestion

Param Type
reply string

Example
js let suggestion = new Suggestion('reply to be overwritten'); suggestion.setReply('reply overwritten');

suggestion.setPlatform(platform) ⇒ RichResponse

Set the platform for a specific RichResponse (optional)

Kind: instance method of Suggestion

Param Type Description
platform string representing desired rich response target platform

Example
js let richResponse = new RichResponse(); richResponse.setPlatform(PLATFORMS.ACTIONS_ON_GOOGLE)

Image ⇐ RichResponse

Class representing a image response.

Kind: global class
Extends: RichResponse

new Image(image)

Constructor for Image object

Param Type Description
image string | Object URL string or an object representing a image response

image.setImage(imageUrl) ⇒ Image

Set the image for a Image

Kind: instance method of Image

Param Type
imageUrl string

Example
js let image = new Image('https://example.com/placeholder.png'); image.setImage('https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png');

image.setPlatform(platform) ⇒ RichResponse

Set the platform for a specific RichResponse (optional)

Kind: instance method of Image

Param Type Description
platform string representing desired rich response target platform

Example
js let richResponse = new RichResponse(); richResponse.setPlatform(PLATFORMS.ACTIONS_ON_GOOGLE)

Payload ⇐ RichResponse

Class representing a payload response

Kind: global class
Extends: RichResponse

new Payload(platform, payload)

Constructor for Payload object

Param Type Description
platform string string indicating target platform of payload
payload Object contents for indicated platform
options.sendAsMessage boolean to include the payload in the messages field. Defaults to false to only send in the payload data field.
options.rawPayload boolean to prevent nesting the payload under the platform string, e.g. {"google": payload}.

payload.setPayload(payload) ⇒ Payload

Set the payload contents for a Payload

Kind: instance method of Payload

Param Type
payload string

Example
js const googlePayloadJson = { expectUserResponse: true, isSsml: false, noInputPrompts: [], richResponse: { items: [{ simpleResponse: { textToSpeech: 'hello', displayText: 'hi' } }] }, systemIntent: { intent: 'actions.intent.OPTION', } } let payload = new Payload(PLATFORMS.ACTIONS_ON_GOOGLE, {}); payload.setPayload(googlePayloadJson);

payload.setPlatform(platform) ⇒ RichResponse

Set the platform for a specific RichResponse (optional)

Kind: instance method of Payload

Param Type Description
platform string representing desired rich response target platform

Example
js let richResponse = new RichResponse(); richResponse.setPlatform(PLATFORMS.ACTIONS_ON_GOOGLE)

Text ⇐ RichResponse

Class representing a text response

Kind: global class
Extends: RichResponse

new Text(text)

Constructor for Text object

Param Type Description
text string | Object response string or an object representing a text response

text.setText(text) ⇒ Text

Set the text for a Text

Kind: instance method of Text

Param Type Description
text string containing the text response content

Example
js let text = new Text(); text.setText('sample text response')

text.setSsml(ssml) ⇒ Text

Set the SSML for a Text

Kind: instance method of Text

Param Type Description
ssml string containing the SSML response content

Example
js let text = new Text(); text.setSsml('<speak>This is <say-as interpret-as="characters">SSML</say-as>.</speak>')

text.setPlatform(platform) ⇒ RichResponse

Set the platform for a specific RichResponse (optional)

Kind: instance method of Text

Param Type Description
platform string representing desired rich response target platform

Example
js let richResponse = new RichResponse(); richResponse.setPlatform(PLATFORMS.ACTIONS_ON_GOOGLE)