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:
- Get the user ID, team ID, or channel ID.
- Create the conversation
- Get the conversation ID.
- 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:
- Sending one-on-one – for targeting single user
- 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.