qas*_*ali 4 node.js actions-on-google dialogflow-es
我正在通过播放MediaObject. 我想创建一个意图处理程序来捕获媒体播放完成的回调,文档显示了一个关于如何编写实现代码来处理它的示例。
建立你的成就感
下面的代码片段展示了如何为 Action 编写执行代码。如果您使用 Dialogflow,请将 actions.intent.MEDIA_STATUS 替换为接收 actions_intent_MEDIA_STATUS 事件的意图中指定的操作名称(例如,“media.status.update”)。
我对对话流说明的部分感到困惑。我处理并返回 MediaObject 的意图被调用,smoothie-02并且我有一个后备,它在媒体播放完毕后得到处理,但我想创建另一个意图并在那里处理它。我想要做的是创建一个新的意图来处理它,而不是它去意图的后备smoothie-02意图。
smoothie-02 处理程序
app.dialogFlow.intent('smoothie-02', (conv) => {
const welcomeContext = getConvContext(conv, AppContexts.WELCOME);
givenName = welcomeContext.parameters['given-name'];
fruitTypes = welcomeContext.parameters['FruitTypes'];
if (!conv.surface.capabilities.has('actions.capability.MEDIA_RESPONSE_AUDIO')) {
conv.ask('Sorry, this device does not support audio playback.');
return;
}
conv.contexts.set("actions_capability_media_response_audio", 5);
// Zoe says something
let response = `Ooh good choice ${givenName} ! `;
response += fruitTypes.length > 1 ? `${fruitTypes[0]} and ${fruitTypes[1]}` : `${fruitTypes[0]} `;
response += `${drinkType} ` ;
response += 'coming right up. But will you first turn me on?';
console.log(response);
conv.ask(response);
conv.ask(new Suggestions("Don't be shy"));
// Blender plays
conv.ask(new MediaObject({
name: 'Blender Sound',
url: 'https://storage.googleapis.com/zoe-mortimer.appspot.com/blender.wav',
}));
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
851 次 |
| 最近记录: |