检测机器人应用程序打开事件 [英] Detect bot application open event

查看:83
本文介绍了检测机器人应用程序打开事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用bot框架v3(c#)进行消息扩展.当我在团队中安装该应用程序并在与bot 1-1聊天中打开bot并发送消息时,我收到欢迎文本. 但是我想在打开/访问bot时不发送任何消息给bot就欢迎文本,所以我有任何方法可以实现这一目标. 对于消息事件的欢迎文本,我正在使用activity.GetActivityType() == ActivityTypes.Message 因此,类似地,有任何活动类型都可以获取机器人访问事件.

I'm working on a message extension using bot framework v3 (c#). When i install the application in teams and open the bot in 1-1 chat with bot, and send message i'm getting a welcome text. But i want the welcome text as soon as i open/ access the bot without sending any message to the bot, so i there any way to achieve this. For welcome text on message event i'm using activity.GetActivityType() == ActivityTypes.Message So similarly is there any activity type to get bot access event.

推荐答案

如果您使用的是C#,则您正在侦听OnMessageActivityAsync事件,并在那里进行检查.但是,如果您想立即发送消息,而无需用户先发送一条消息,则还需要挂接到OnMemberwegoAsync事件,然后将其首先发送到该事件.有关更多信息,请参见

If you're using C#, you're listening for the OnMessageActivityAsync event, and implementing your check in there. However, if you want to send the message straight away, without the user having to send one first, you need to also hook into the OnMembersAddedAsync event, and send it there first. For more info, see Send welcome message to users.

在Teams中,现在甚至有此版本的修改版本,专门针对Teams.我还没有亲自调查,但是看到了

In Teams, there's even a modified version of this now, specifically for Teams. I haven't looked into yet myself, but see Subscribe to conversation events for more.

与此相关,特别是如果将bot安装到团队或小组聊天中,则需要在OnMemberFyresAsync中做一些工作,以检查-bot-是否是要添加的新成员,并确保您仅发送1条消息,而不发送多条消息(否则可能最终会多次发送此欢迎"消息).我在上面提供的链接中显示了这一点.基本上member.Id != turnContext.Activity.Recipient.Id可能需要根据您要执行的操作进行更改.

Related to this, especially if the bot is installed into a Team or group chat, you need to do a bit of work in the OnMembersAddedAsync to check if the -bot- is the new member being added, and to make sure you only send 1 message, not multiple (otherwise it can end up sending this 'welcome' a few times). This is shown in the links I provided above. Baically member.Id != turnContext.Activity.Recipient.Id might need to change, based on what you're trying to do.

希望有帮助

这篇关于检测机器人应用程序打开事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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