azure - 在 Microsoft Azure 聊天机器人中发送图像附件

标签 azure botframework chatbot azure-language-understanding azure-bot-service

我使用 Microsoft Azure 机器人服务和 LUIS 创建了一个聊天机器人。使用经过 LUIS 训练的机器人,我能够接收短信。我已将机器人连接到 Skype channel 。

我不知道如何返回图像附件作为消息的答复。

我听说一些 Microsoft 机器人框架可以将图像作为附件发送,但我不确定 Azure 机器人服务。

示例代码:

var recognizer = new builder.LuisRecognizer(LuisModelUrl);

var intents = new builder.IntentDialog({ recognizers: [recognizer] })
    .matches('**Greetings**', (session, args) => {session.send('**Hi! Welcome**');});

bot.dialog('/', intents); 

我的案例:

我想在下面的 URL 图像中附加“嗨!”当与我的意图“问候”匹配时显示“欢迎”消息。

内容URL:“https://img.clipartfest.com/13e01fd74f423c39c4af7dcc8a7b8455_animated-welcome-sign-animated-welcome-clip-art-images_1300-899.jpeg”,

内容类型=“图像/jpeg”

我不知道如何以及在代码中的何处添加上述内容 URL 以将附件发送到邮件。

有人可以帮我吗?

最佳答案

RAS 是对的,尽管他的代码有错误。您需要在 matches 方法中传递的函数内定义回复消息,否则您将收到 ReferenceError,因为 session 未定义。另外,请使用 text() 而不是 setText(),后者已被弃用。

var recognizer = new builder.LuisRecognizer(LuisModelUrl);

var intents = new builder.IntentDialog({ recognizers: [recognizer] })
    .matches('**Greetings**', (session, args) => {
        var reply = new builder.Message(session)
            .text("Hello!")
            .addAttachment({contentType: "image/jpeg", contentUrl: "https://img.clipartfest.com/13e01fd74f423c39c4af7dcc8a7b8455_animated-welcome-sign-animated-welcome-clip-art-images_1300-899.jpeg"});
    });

bot.dialog('/', intents); 

另一种添加图像的方法是使用 Hero CardsThumbnail Cards 。您可以在 Bot Framework Samples github 中查看这些示例的用法。 .

关于azure - 在 Microsoft Azure 聊天机器人中发送图像附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42945039/

相关文章:

sql-server - 如何使用 Entity Framework Core 进行迁移,通过 ASP.NET CORE MVC 连接到现有的 Azure SQL 数据库?

sql-server - Azure SQL 数据仓库中的拆分器函数

Azure CLI 运行命令使用参数调用 RunPowerShellScript

node.js - 基于 botframework v4 node.js 在 bot 中查看 Azure blob 存储中保存的聊天记录

facebook - Microsoft BotBuilder 机器人状态 API 已弃用。 ,需要帮助理解新架构

machine-learning - 响应生成如何在 RASA 核心中工作?

c# - Azure IoT 中心设备查询分页继续 token 不起作用

node.js - 将 npm 包安装到 Azure Bot 服务中

chatbot - 如何在lex中创建开放式插槽

c++ - 编译 Eliza 聊天机器人 C++ 时出现问题 LNK2019