Send Proactive Messages in Microsoft Bot Framework Teams Bot using C# Console Application

Console C# Application to create and send Proactive Messages/ Notifications in Microsoft Bot Framework v4 .NET Core C# for Teams Channel.

A proactive message is any message sent by a bot that isn’t in response to a request from a user. This message can include content such as:

  • Welcome messages
  • Notifications, for example, Any notification. The most recent example is the Company Communicator Bot
  • Scheduled messages -For Example, User has Requested the BOT “Send Me an alert Tomorrow 8 pm”

To send a proactive message, follow these steps:

  1. Get the user ID, team ID, or channel ID.
  2. Create the conversation
  3. Get the conversation ID.
  4. Send the message.

Source Code

If you want the source code for this console application, visit the JD Bots Repository. Else, you can follow the blog.

Create Console Application in Visual Studio

Launch Visual Studio and create a new Console App C# project.

Send Proactive Message/Notification to Microsoft Teams Channel from C# Console App

Add the following random property.

Create a new method that sends the proactive message to the required user.

In the above code, you need to provide all the details like

  • AppID
  • Password
  • Conversation ID
  • Message to be sent

Next, add the following code/methods that implement the retry logic if failed to send the proactive message or notification to the Microsoft Teams channel using Microsoft Bot Framework v4 C#.

Add the following code in the main method to call the Send method by passing the required credentials.

You can send the proactive message in two ways:

  1. Sending one-on-one – for targeting single user
  2. Sending in a group or to all users

Run your project and wait for it to send a message to the user. You can also send an Adaptive Card, Hero Card, Thumbnail Card, or Audio and Video cards as well.

In our next blog, we will send a hero card proactively to the user using the console application.

Video: Send Proactive Message / Notification to a single user in Microsoft Teams Channel using C# Console Application

Thank you All!!! Hope you find this useful.


One thought on “Send Proactive Messages in Microsoft Bot Framework Teams Bot using C# Console Application

Add yours

Up ↑

%d bloggers like this: