【问题标题】:How to create card in messenger using API.ai (dialogflow)如何使用 API.ai 在 Messenger 中创建卡片(对话流)
【发布时间】:2018-11-06 14:01:45
【问题描述】:

我通过使用 nodejs 集成了对话流和信使,这对于文本交换来说效果很好。我对在 Messenger 中创建卡片感到困惑。有人可以帮忙吗?
我已将 facebook messenger 机器人与网站集成。当客户访问该机器人将提供帮助的页面时。我想在那个机器人中显示卡片。请为此要求提供参考或解决方案。请看这张图片Like this I want to show

【问题讨论】:

    标签: node.js dialogflow-es


    【解决方案1】:

    我假设 messenger 是指 Facebook Messenger?

    要将基本卡片与 Google 助理一起使用,您首先必须检查屏幕输出是否支持卡片 UI 的使用。你可以这样做:

    if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
      conv.ask('Sorry, try this on a screen device or select the ' +
        'phone surface in the simulator.');
      return;
    }
    

    在您测试了屏幕是否支持使用基本卡片后,您可以创建一个基本卡片类的新实例,代码如下:

    // Create a basic card
    conv.ask(new BasicCard({
      text: `This is a basic card.  Text in a basic card can include "quotes" and
      most other unicode characters including emoji ?.  Basic cards also support
      some markdown formatting like *emphasis* or _italics_, **strong** or
      __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other
      things like line  \nbreaks`, // Note the two spaces before '\n' required for
                                   // a line break to be rendered in the card.
      subtitle: 'This is a subtitle',
      title: 'Title: this is a title',
      buttons: new Button({
        title: 'This is a button',
        url: 'https://assistant.google.com/',
      }),
      image: new Image({
        url: 'https://example.com/image.png',
        alt: 'Image alternate text',
      }),
      display: 'CROPPED',
    }));
    

    更多信息请见via Google's documentation

    【讨论】:

    • 感谢重播。实际上,我已经将 facebook messenger 机器人与网站集成。当客户访问该机器人将提供帮助的页面时。我想在那个机器人中显示卡片。请为此要求提供参考或解决方案
    猜你喜欢
    • 2018-12-28
    • 2018-04-03
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 2021-11-20
    • 2020-09-22
    • 2019-05-16
    • 1970-01-01
    相关资源
    最近更新 更多