Sending a message to microsoft teams bot using python

Copper Contributor

I have created a bot and subscribed it to Microsoft Teams, I have done all the configuration settings such that I am getting all the messages to my web-app from MSTeams.

Following to this documentation, I am trying to hit an Http post request to send the reply message to the same bot. But I am getting 401 i.e unauthorized error. Maybe I am not getting the correct token. could someone help me telling how can we generate the token in order to do an Http request to the MSTeams?

below is the code snippet that I am using.

team_message = json.loads("utf-8"))
conversion_id = team_message.get("conversation").get("id")
activity_id = team_message.get("channelData").get("clientActivityID")
service_url = team_message.get("serviceUrl")
url = service_url + "/v3/conversations/{}/activities/{}".format(conversion_id, activity_id)
res =, headers={"Authorization": "Bearer abcdfjkdsa")


1 Reply

@barun69 ,

Can you please share how did you generate the Bearer Token? It has to be a valid access token.