简体   繁体   English

Nodejs 中 Telegram、Facebook、Slack for DialogFlow 等平台的自定义负载

[英]Custom payload for platforms like Telegram, Facebook, Slack for DialogFlow in Nodejs

I would like to ask how to custom payload for carousel, image in other platforms like Facebook, Telegram and etc.我想问一下如何在其他平台(如 Facebook、Telegram 等)中为轮播、图像自定义有效负载。

Information信息

  1. DialogFlow API version: V2 API DialogFlow API 版本:V2 API
  2. Node version: v8.10.0节点版本:v8.10.0
  3. body-parser version: ^1.18.3正文解析器版本:^1.18.3
  4. express: ^4.16.4快递:^4.16.4
return res.json({
  payload: {
    google: {
      expectUserResponse: true,
      systemIntent: {
        intent: "actions.intent.OPTION",
        data: {
          "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
          carouselSelect: {
            items: [{
                optionInfo: {
                  key: "car",
                  synonyms: ["automobile", "vehicle"]
                },
                description: "A four wheel vehicle",
                title: "Car"
              },
              {
                optionInfo: {
                  key: "plane",
                  synonyms: ["aeroplane", "jet"]
                },
                description: "A flying machine",
                title: "Plane"
              }
            ]
          }
        }
      },
      richResponse: {
        items: [{
          simpleResponse: {
            textToSpeech: "Category List"
          }
        }]
      }
    },
    telegram: {
      text: "Category list",
      expectUserResponse: true,
      systemIntent: {
        intent: "actions.intent.OPTION",
        data: {
          "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
          carouselSelect: {
            items: [{
                optionInfo: {
                  key: "car",
                  synonyms: ["automobile", "vehicle"]
                },
                description: "A four wheel vehicle",
                title: "Car"
              },
              {
                optionInfo: {
                  key: "plane",
                  synonyms: ["aeroplane", "jet"]
                },
                description: "A flying machine",
                title: "Plane"
              }
            ]
          }
        }
      }
    }
  },
  outputContexts: []
});

This is code snippet to return carousel response to Telegram and Google.这是将轮播响应返回给 Telegram 和 Google 的代码片段。 It worked in google assistant but failed to display carousel list in Telegram.它在谷歌助手中工作,但未能在 Telegram 中显示轮播列表。 Only text "Category list" was displayed in Telegram. Telegram 中仅显示文本“类别列表”。

Is there any mistake in the payload for Telegram? Telegram 的有效负载是否有任何错误? Could anyone provide guidance on this?任何人都可以提供这方面的指导吗?

Option responses(such as Carousel and List) are response type of actions-on-google modules and it is created for Google Assistant.选项响应(例如 Carousel 和 List)是 Google 操作模块的响应类型,它是为 Google 助理创建的。 Every platform has different screen abilities so you can not use every response type for every platform.每个平台都有不同的屏幕功能,因此您不能为每个平台使用每种响应类型。 As far as I know, there is no carousel or list type supported by Telegram.据我所知,Telegram 不支持轮播或列表类型。 You may consider to use different options.您可以考虑使用不同的选项。 For more information you may check out :有关更多信息,您可以查看:

Rich messages丰富的消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM