Proactive Messaging|Mastering Microsoft Teams Bots 4.2

4.2 Proactive Messaging

Imagine this: A project manager doesn’t open Teams all morning — she's focused on a client call. But just before noon, a quiet ping arrives:

ProjectBot: “Reminder: Your 1 PM meeting with Acme Inc. is in 2 hours. Here’s the prep doc. ✨”

That’s not just a message. That’s a bot being helpful — at the right time, with the right content, without being asked.

This is proactive messaging: when your bot initiates the conversation. It’s how bots go from reactive tools to active assistants — delivering reminders, alerts, summaries, escalations, and more.

4.2.1 What Is Proactive Messaging?

Normally, bots in Teams only respond after a user sends a message. But sometimes, your bot needs to speak first — to notify a user about a change in status, a deadline, or something their future self will thank you for.

Proactive messaging means your bot sends a message without an immediate user trigger — based on time, system events, or external logic.

4.2.2 When to Use Proactive Messaging

  • Deadline or meeting reminders
  • Task completion summaries
  • Alerts from external systems (e.g., ticket escalations)
  • Daily digests or status check-ins
  • Post-approval follow-ups (“Your request was approved!”)

But like all good assistants, your bot should be helpful, not annoying. Message users only when it adds value.

4.2.3 Technical Requirements

To send proactive messages, your bot must:

  • Be installed in the chat, group, or team you want to message
  • Have stored a valid conversation reference for the recipient
  • Be authorized to send messages in that context

4.2.4 Getting a Conversation Reference

When your bot first interacts with a user or group, the Bot Framework provides a ConversationReference. You must store this (e.g., in a database) to use later.


// Example: extract and save conversation reference
const reference = TurnContext.getConversationReference(context.activity);
saveConversationReference(reference, userId); // You define this
  

4.2.5 Sending a Proactive Message

When triggered — say, by a scheduled task, webhook, or system event — your bot can use the stored reference to send a message:


// Node.js (Express example)
adapter.continueConversation(reference, async (proactiveContext) => {
    await proactiveContext.sendActivity("Don't forget, your report is due at 3 PM today!");
});
  

In .NET:


await adapter.ContinueConversationAsync(appId, conversationReference, async (context, token) =>
{
    await context.SendActivityAsync("Here's your daily summary 📊");
}, cancellationToken);
  

4.2.6 Best Practices for Proactive Messaging

  • Respect timing: Don’t send messages during off hours unless they’re critical.
  • Be concise: Proactive messages should be clear and actionable in one glance.
  • Use cards: Summaries, buttons, or links in Adaptive Cards work beautifully here.
  • Let users control frequency: Offer settings for daily/weekly digests or opt-out options.

4.2.7 Common Pitfall: Message Routing

Proactive messages will fail if the bot was never installed in the chat or if the stored reference is stale. Always validate before attempting to message, and handle failures gracefully — bots that crash silently are bots that get uninstalled.

4.2.8 Real-World Example: Weekly Digest Bot

Picture a bot that checks every Monday at 9 AM and sends each user a personalized card:

  • 📅 Upcoming meetings
  • ✅ Tasks due this week
  • 📌 A gentle reminder for unfinished items

That’s proactive messaging — and it's the difference between a passive bot and a proactive partner.

4.2.9 Summary

Proactive messaging adds personality, timing, and usefulness to your Teams bot. When you initiate contact with context and clarity, users don’t feel interrupted — they feel supported.

In the next section, we’ll explore Message Extensions — the tools that let users call your bot directly from the message composer, enabling contextual search, actions, and content injection.

2025-04-12

Shohei Shimoda

I organized and output what I have learned and know here.