我有问题。
[我选择一个对话流程,谷歌动作示例(播放音频文件)
我想为多个音频文件构建。
因此,在完成媒体响应后,将调用媒体状态。
所以当时我想自动播放下一个音频。
请帮助我。我需要您的帮助。
谢谢。
这是我的代码。
'use strict';
const {
dialogflow,
SimpleResponse,
Image,
Suggestions,
MediaObject,
} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});
app.intent('Media Response', (conv) => {
if (!conv.surface.capabilities
.has('actions.capability.MEDIA_RESPONSE_AUDIO')) {
conv.ask('Sorry, this device does not support audio playback.');
conv.ask('Which response would you like to see next?');
return;
}
conv.ask('This is a media response example.');
conv.ask(new MediaObject({
name: 'Jazz in Paris',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Album cover of an ocean view',
}),
}));
conv.ask(new Suggestions(['cancel']));
});
app.intent('Media Status', (conv) => {
const mediaStatus = conv.arguments.get('MEDIA_STATUS');
let response = 'Unknown media status received.';
if (mediaStatus && mediaStatus.status === 'FINISHED') {
response = 'Hope you enjoyed the tune! ';
}
conv.ask(response);
conv.ask('Media ended successfully');
conv.ask(new Suggestions(['exit']));
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
我尝试针对“媒体状态”意图调用另一个响应。
app.intent('Media Status', (conv) => {
const mediaStatus = conv.arguments.get('MEDIA_STATUS');
let response = 'Unknown media status received.';
if (mediaStatus && mediaStatus.status === 'FINISHED') {
conv.ask(new MediaObject({
name: 'Jazz in Paris',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Album cover of an ocean view',
}),
}));
conv.ask(new Suggestions(['cancel']));
});
}
});
然后发生“ Webhook意图失败:媒体状态”错误。我应该如何解决这个问题?谢谢。
所有包含MediaObject
的响应还必须包含SimpleResponse
-通常只是媒体之前所说的一些文本。
例如,当您发送第一个MediaObject
时,在“媒体响应”意图处理程序中,您将看到以下行:
conv.ask('This is a media response example.');
但是“媒体状态”意图处理程序中缺少这种类型的行。