Hi i'am working with google assistant, i'am using Action Builder in the Google Action Console. And i working with google Cloud function editor provided in the Action Console to test my webhook. I would like to use a media player to read an mp3 song that i provide with an url. i followed the documentation here : https://developers.google.com/assistant/conversational/prompts-media and i used this code :
app.handle('media', (conv) => {
conv.add('This is a media response');
conv.add(new Media({
mediaObjects: [
{
name: 'Media name',
description: 'Media description',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
image: {
large: JAZZ_IN_PARIS_IMAGE,
}
}
],
mediaType: 'AUDIO',
optionalMediaControls: ['PAUSED', 'STOPPED'],
startOffset: '2.12345s'
}));
});
Problem is that this code work when i remove the image but if i keep it i got an error :
Unsuccessful webhook call due to client issue: Error querying agent endpoint. State: URL_UNREACHABLE, reason: UNREACHABLE_5xx.
and in the webhookResponse i got :
"error": "JAZZ_IN_PARIS_IMAGE is not defined"
My question is how to send image in a MediaObject send by a webhook? Where do i have to store my image and how to add it in the response?
In the code snippet, JAZZ_IN_PARIS_IMAGE
is not defined directly but is supposed to be an Image object, like png
or jpg
. A MediaObject can have a large image and/or an icon.
For testing purposes, you can upload a file to your Cloud Storage or just take any image from the web. But when you move forward you really should fix that image URL and provide corrected alt text.
conv.add('This is a media response');
conv.add(new Media({
mediaObjects: [
{
name: 'Media name',
description: 'Media description',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
image: {
large: {
url: 'https://serebii.net/pokearth/sprites/green/025.png',
alt: 'This is a sprite of Pikachu!',
},
}
}
],
mediaType: 'AUDIO',
optionalMediaControls: ['PAUSED', 'STOPPED'],
startOffset: '2.12345s'
}));
});