如何使用NodeJS在Dialogflow中发送图像?我希望它能在任何平台上工作,但目前,Telegram还不错。当我尝试这段代码时,我得到这个错误: UnhandledPromiseRejectionWarning: error: Unknown response type:"{}“。注意:我没有使用内联编辑器。
const myPicture = new Image({
imageURL: picture
});
agent.add(myPicture);发布于 2021-07-16 10:51:20
您只是缺少使用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中可以找到一个使用图像的有用示例。
https://stackoverflow.com/questions/68396102
复制相似问题