【问题标题】:Error using actions-on-google Carousel or List with dialogflow's WebhookClient在 dialogflow 的 WebhookClient 中使用 actions-on-google Carousel 或 List 时出错
【发布时间】:2018-07-12 09:23:23
【问题描述】:

我尽一切努力让this 示例工作(尤其是轮播部分)。每次我尝试从谷歌上的操作中使用列表或建议或轮播时,它都会在谷歌模拟器中给我这个错误: error from actions on google simulator

这是我的 heroku webhook 中的 Intent 代码(它是示例中的复制粘贴)

function prova(agent){
let conv = agent.conv();
const imageUrl = 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png';
const imageUrl2 = 'https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw';
const linkUrl = 'https://assistant.google.com/';

conv.ask(new Carousel({
  title: 'Google Assistant',
  items: {
    'WorksWithGoogleAssistantItemKey': {
      title: 'Works With the Google Assistant',
      description: 'If you see this logo, you know it will work with the Google Assistant.',
      image: {
        url: imageUrl,
        accessibilityText: 'Works With the Google Assistant logo',
      },
    },
    'GoogleHomeItemKey': {
      title: 'Google Home',
      description: 'Google Home is a powerful speaker and voice Assistant.',
      image: {
        url: imageUrl2,
        accessibilityText: 'Google Home'
      },
    },
  },
}));
agent.add(conv);
}

所以,这是我的依赖项:

package.json dependencies

谁已经解决了这个问题?我没有找到任何关于这...

提前谢谢你!

【问题讨论】:

    标签: node.js actions-on-google dialogflow-es


    【解决方案1】:

    在您的实现中,您错过了原始示例中的一行。您需要在轮播之前有一个SimpleResponse。所以你需要一条线,例如

    conv.ask('Please choose an item:');
    

    conv.ask()之前的行为new Carousel

    【讨论】:

    • 很容易错过,希望将来能帮助其他人。
    【解决方案2】:

    您可以尝试像这样直接为 Carousel 添加 JSON 负载:

    function prova(agent){
        const imageUrl = 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png';
        const imageUrl2 = 'https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw';
        const linkUrl = 'https://assistant.google.com/';
    
        agent.add(new Payload(agent.ACTIONS_ON_GOOGLE,   {
            "expectUserResponse": true,
            "richResponse": {
                "items": [
                    {
                        "simpleResponse": {
                            "textToSpeech": "Please choose an item:"
                        }
                    }
                ]
            },
            "systemIntent": {
                "intent": "actions.intent.OPTION",
                "data": {
                    "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
                    "carouselSelect": {
                        "items": [
                            {
                                "optionInfo": {
                                    "key": "WorksWithGoogleAssistantItemKey"
                                },
                                "description": "If you see this logo, you know it will work with the Google Assistant.",
                                "image": {
                                    "url": imageUrl,
                                    "accessibilityText": "Works With the Google Assistant logo"
                                },
                                "title": "Works With the Google Assistant"
                            },
                            {
                                "optionInfo": {
                                    "key": "GoogleHomeItemKey"
                                },
                                "description": "Google Home is a powerful speaker and voice Assistant.",
                                "image": {
                                    "url": imageUrl2,
                                    "accessibilityText": "Google Home"
                                },
                                "title": "Google Home"
                            }
                        ]
                    }
                }
            }
        }));
    }
    

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多