使用 actions-on-google Carousel 或 List 与 dialogflow 的 WebhookClient 时出错

Error using actions-on-google Carousel or List with dialogflow's WebhookClient

我尝试了所有方法来使 this 示例正常工作(尤其是 Carousel 部分)。每次我尝试在 google 上的操作中使用 List 或 Suggestions 或 Carousel 时,它都会在 google 模拟器中给我这个错误: 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

谁已经解决了这个问题?我没有在这上面找到任何东西...

提前致谢!

在您的实现中,您漏掉了原始示例中的一行。您需要在轮播之前有一个 SimpleResponse。所以你需要一行

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

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

您可以尝试像这样直接为 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"
                        }
                    ]
                }
            }
        }
    }));
}

结果: