处理dialogflow中的音频播放完成回调(媒体响应) [英] Handle audio play completion callback in dialogflow (Media responses)

查看:98
本文介绍了处理dialogflow中的音频播放完成回调(媒体响应)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过播放 MediaObject 处理意图。我想创建一个意图处理程序,以捕获媒体播放完成的回调,


I'm handling an intent by playing a MediaObject. I want to create an intent handler that will catch the callback of media play completion, the documentation shows an example on how to write fulfillment code to handle it.

Building your fulfillment

The code snippet below shows how you might write the fulfillment code for your Action. If you're using Dialogflow, replace actions.intent.MEDIA_STATUS with the action name specified in the intent which receives the actions_intent_MEDIA_STATUS event, (for example, "media.status.update").

I am confused with the part of the dialogflow instructions. The intent that I handle and return a MediaObject is called smoothie-02 and I have a fallback for it which what gets handled after the media finishes being played, but I want to create another intent and handle it there instead. What I want to do is to create a new intent that would handle it, instead of it going to the fallback intent of smoothie-02 intent.

smoothie-02 handler

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',
    }));
});

解决方案

What I needed to do is create a new intent and add actions_intent_MEDIA_STATUS in the Events, and that will be the intent that would handle the media playback finished callback. Credits to this article!

这篇关于处理dialogflow中的音频播放完成回调(媒体响应)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆