I am trying to find a way to run a piece of code (MS Bot Framework, C# hosted on Azure) every time a person is mentioned on Yammer or receives a direct message.
The two ways that I tried:
1) The best I came up with for now is to enable email notifications from Yammer, and watch a mailbox for emails from notifications@yammer.com
. Microsoft's Bot Framework has a one-click setup for monitoring emails, so that works.
But notification emails arrive with a 15 minutes delay, which renders this pretty useless as I need near-instant performance.
Finally, it looks like this approach simply doesn't work because the MS Bot Framework seems to reply to the email address who sent the email, rather to the one that I specify:
if (activity.ChannelId == "email" && activity.From.Id == "notifications@yammer.com")
{
var newActivity = activity.CreateReply();
//doesn't work, sends email back to the activity.From.Id
newActivity.Recipient.Id = "k48@gmail.com";
newActivity.Text = "I got a message from " + activity.From.Name + "!";
BotUtils.SendActivityToChat(newActivity);
}
I could write my own code for sending emails to an arbitrary recipient, but then there is still the problem with 15 min delay.
2) Another approach I am using is to poll Yammer's API every minute to see if there are new messages, but this is still not instant, and I'm not sure if my account gets banned if I keep polling the API way too often. (Update: the official rate limit is 1 poll per minute, or else they ban you).
Is there something I missed? How else would you run a piece of code every time you get a message or mention on Yammer?