在直接解决对话之前,如何让我的漫游器忽略对话? [英] How can I get my bot to ignore conversation until it is addressed directly?

查看:92
本文介绍了在直接解决对话之前,如何让我的漫游器忽略对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的漫游器添加到Slack频道.但我希望它在直接解决之前忽略对话,例如:

me: hi!
me: hi!
me: @bot hi!
bot: why hello there!

在Microsoft Bot Framework v1中,有一个选项:听所有消息".我在v3中看不到该选项.有没有简单的方法可以做到这一点(即无需分析所有话语以查看该机器人是否已解决)?

我正在使用node.js botbuilder 3.1.

解决方案

虽然检查活动文本当然是有效的选项,但我会改用库提供的Mentions功能(至少在C#中如此).

if (activity.GetMentions().Any(x => x.Mentioned.Name == "botName") 
{
  ...
}

IMessageActivity 具有实体.该列表中可能包含的实体之一是 GetMentions ()方法仅是过滤实体列表以检索提及"类型的实体.

更新

刚意识到您要的是Node.js.实体方法仍然有效,如您在 Node.js文档.您可以使用session.message.entities.

I want to add my bot to a Slack channel. But I want it to ignore conversation until it is addressed directly, e.g.:

me: hi!
me: hi!
me: @bot hi!
bot: why hello there!

In Microsoft Bot Framework v1, there was an option: "Listen to all messages". I don't see that option in v3. Is there a simple way to do this (i.e. without analyzing every utterance to see whether the bot was addressed)?

I'm using node.js botbuilder 3.1.

解决方案

While checking the activity text is certainly a valid option, I would instead use the Mentions capabilities provided by the library (at least in C#).

if (activity.GetMentions().Any(x => x.Mentioned.Name == "botName") 
{
  ...
}

IMessageActivity has a list of Entities. One of the possible entities coming in that list is the Mention entity.

The GetMentions() method is just a filtering the list of entities to retrieve the ones of type "mention".

Update

Just realized that you were asking for Node.js. The Entities approach is still valid, as you can see in the Node.js docs. You can use session.message.entities.

这篇关于在直接解决对话之前,如何让我的漫游器忽略对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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