How to Send Messages to Individual Accounts in Microsoft Teams Chat using Python and MS Graph API

How to Send Messages to Individual Accounts in Microsoft Teams Chat using Python and MS Graph API

Using Python, it’s possible to send messages to individual accounts in MS Teams. It’s easy to send messages in Teams channels using Webhooks. But to send messages to individual accounts, there are some specific steps that need to be followed. The steps are shown in the video in details.

The Google Colab notebook link is here: https://colab.research.google.com/drive/1hFZpGEbss86FzLMSaTQt9r7mA9bJ8r68?usp=sharing

I used some documentations provided by Microsoft as references. The links are provided here-

How to create a chat- https://learn.microsoft.com/en-us/graph/api/chat-post?view=graph-rest-1.0&tabs=http

How to send a message- https://learn.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http#http-request

Authentication using Azure Identity library- https://learn.microsoft.com/en-us/python/api/overview/azure/identity-readme?view=azure-python#authenticate-users