Rik Harink
Rik Harink

Reputation: 13

Know if IActivity is from bot or user in IActivityLogger

I'm trying to implement IActivityLogger and perform different actions depending on if the bot is the sender of the activity or a user is the sender.

How do I know if the activity is from the bot or the user. Can I get the bot's channel id somewhere to compare it to the Id in Activity.From.Id or is there a different solution?

Upvotes: 1

Views: 91

Answers (1)

Ezequiel Jadib
Ezequiel Jadib

Reputation: 14787

You can maintain a static dictionary of ChannelId / BotId (Recipient.Id) that you can fill in your MessagesController every time a new message arrives. At that time, you know that activity.Recipient.Id will be the bot and then use activity.ChannelId to get the channel id that will be the key of your dictionary.

After that, you can use that dictionary in your IActivityLogger to do the check of the id.

Upvotes: 1

Related Questions