【问题标题】:Send Image in Dialogflow Nodejs在 Dialogflow Nodejs 中发送图像
【发布时间】:2021-07-15 14:52:49
【问题描述】:

如何使用 NodeJS 在 Dialogflow 中发送图像?我希望它可以在任何平台上运行,但目前 Telegram 还不错。当我尝试此代码时,我收到此错误:UnhandledPromiseRejectionWarning:错误:未知响应类型:“{}”。 注意:我没有使用内联编辑器。

const myPicture = new Image({
                    imageURL: picture
                });
agent.add(myPicture);

【问题讨论】:

    标签: javascript node.js dialogflow-es


    【解决方案1】:

    您只是缺少使用Image() 类通过电报发送图片的platform: 参数。包括 platform: 'TELEGRAM' 以指定您在哪里集成消息。通过调用new Image(anotherImage)初始化agent.add()处的对象

    这里有可用的key value pair for platforms 供参考。见以下代码:

    const imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Stack_Overflow_logo.svg/200px-Stack_Overflow_logo.svg.png';
    const anotherImage = new Image({
                imageUrl: imageUrl,
                platform: 'TELEGRAM'
           });
            
    agent.add(new Image(anotherImage));
    

    试运行:

    here 所示,还有其他示例代码实现。在Git repository 中找到了一个使用图像的有用示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-07
      • 2019-06-07
      • 1970-01-01
      • 1970-01-01
      • 2019-03-20
      • 2014-07-26
      • 1970-01-01
      相关资源
      最近更新 更多