I'm writing a BotFramework bot, and have integrated it with Slack and Teams and in 1-to-1 chats it's working quite nicely.
I'd like to have it work in a group channel as well, but I don't want it to respond to every comment (as most responses would be "I didn't understand the question") - I'm using a Luis Dialog along with a FormFlow form and some Prompts.
I initially tried the following setup within my MessagesController Post method:
if (questionIsToMe(activity))
{
await Conversation.SendAsync(activity, () => new OctopusLuisDialog());
}
with the questionIsToMe
defined as:
private bool questionIsToMe(Activity activity)
{
// IsGroup is null => 1-1 conversation with non-group capable client
// IsGroup is False => 1-1 conversation within group capable client
// IsGroup is True AND message starts with OctoBot => group conversation with question
// to me
return !activity.Conversation.IsGroup.HasValue ||
!activity.Conversation.IsGroup.Value ||
(activity.Conversation.IsGroup.Value &&
activity.Text.StartsWith("OctoBot", StringComparison.InvariantCultureIgnoreCase));
}
Which works for most of the intents fairly well, but causes problems when the user is responding to the FormFlow or Prompts - as I need to include "Octobot" in the response to send the value, which I can strip out of my FormFlow, but the prompts all fail with my fallback text.
How can I distinguish between normal channel chatter and responses to my bots questions?