Bot Framework v4-Bot发起对话 [英] Bot Framework v4 - Bot Initiate Conversation

查看:89
本文介绍了Bot Framework v4-Bot发起对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Bot Framework SDK v4 for NodeJS为Microsoft Teams开发一个机器人.机器人有没有办法自动发起频道中的对话,而不是由用户发起对话?当用户发起对话时,我的机器人可以正常工作.关于如何进行此操作有什么建议吗?

I am developing a bot for Microsoft Teams using the Bot Framework SDK v4 for NodeJS. Is there a way that the bot can automatically initiate a conversation in a channel, rather than user initiating the conversation? My bot works fine when the user initiates the conversation. Any suggestions on how I can proceed with this?

推荐答案

MS小组将其称为主动消息"(注意:Bot Framework通常将主动消息"定义为向用户发送与当前对话无关的消息,您可以参考的内容.团队将一些东西归为此类).您可以阅读有关如何使用来自Teams官方文档的主动消息传递.或者,更具体地说,是

MS Teams calls that a "Proactive Message" (note: Bot Framework generally defines a "proactive message" as sending a user a message not related to current conversation, that you have a reference for. Teams lumps a few things into this category). You can read more about how to use proactive messaging from the official Teams docs. Or, more specifically, creating a channel conversation.

要点是您需要

The gist of it is that you need to capture a conversationUpdate and check for a new member added to the conversation or fetch the team roster, then you send the proactive message.

注意:对于MS Teams,用户或团队将必须首先添加漫游器:

Note: For MS Teams, the user or team will have to add the bot first:

只要您的机器人在个人或团队范围内拥有通过先前添加而获得的用户信息,机器人就可以与单个Microsoft Teams用户创建新的对话.该信息使您的机器人可以主动通知他们.例如,如果您的漫游器已添加到团队中,则它可以查询团队名册并在个人聊天中向用户发送个别消息,或者用户可以@提及其他用户以触发该漫游器向该用户发送直接消息.

Bots can create new conversations with an individual Microsoft Teams user as long as your bot has user information obtained through previous addition in a personal or team scope. This information enables your bot to proactively notify them. For instance, if your bot was added to a team, it could query the team roster and send users individual messages in personal chats, or a user could @mention another user to trigger the bot to send that user a direct message.

一些开发人员在使用主动消息传递时会遇到401: Unauthorized错误,尤其是如果漫游器由于某种原因而重新启动并且漫游器试图重新发起主动消息时.您可以阅读有关防止

Some developers come across 401: Unauthorized errors when using proactive messaging, especially if the bot was restarted for some reason and the bot is attempting to re-initiate a proactive message. You can read more about preventing that by using trustServiceUrl from this Sample (this is my branch, which is being used to submit a Pull Request to update the Proactive Sample with trustServiceUrl info).

这篇关于Bot Framework v4-Bot发起对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆