Reputation: 2303
when responding to a user query using actions sdk I am able to create a basic card using:
conv.ask(new BasicCard({
text: 'Text with card display',
title: 'Title:',
display: 'CROPPED',
}));
However, if I wish to provide the user with some audio (different from the display text) how do I do it?
I tried to add a conv.ask('<speak>' + 'Hello' + '</speak>');
but it throws a error
MalformedResponse
expected_inputs[0].input_prompt.rich_initial_prompt.items[0].simple_response: 'display_text' must be set or 'ssml' must have a valid display rendering.
What is the best way to include an audio in a google actions project? Thanks
Upvotes: 1
Views: 124
Reputation: 50731
The Basic Card does not have audio attached to it. As the name suggests, it is a visual cue rather than an audible one. It is meant to supplement the text that is spoken and displayed - not replace it.
While you can create a SimpleResponse that has different text that is spoken vs displayed, you should make sure that both responses are substantially the same. You can use a SimpleResponse with something like this:
conv.ask(new SimpleResponse({
speech: '<speak>Here are the results, showing our sunny recreational facilities. <audio src="https://actions.google.com/sounds/v1/animals/cicada_chirp.ogg">And the sounds of nature.</audio></speak>',
text: 'Here is the result',
}));
Upvotes: 0
Reputation: 384
If you want to play the audio in the background, I'd suggest using SSML, but if your actual goal is to just deliver the audio to the user (like if it's a podcast or something) you can use a Media Response.
If, however, you want the text displayed on a device with a screen to be different from the text that's spoken, you could add a Simple Response (which has the option to add different text and speech).
Upvotes: 1