MS Teams python

Office 365 Connectors from Microsoft Teams via Python API

A

Anonymous

3 min read
Share:

I was going to look at creating a Slack Channel with just DNS news for my coworkers but then found out we are going to use Microsoft Teams.  Mmmmm M$ Teams, never was a fan of Microsoft but my good buddy told me to check it out.

I was surprised it was like Slack but out of the box integrated with all my Coworkers(guess since it is Office 365 integrated).  Ok now for the fun part taking my Google News alert and posting it to Teams Channel.

So I get Google News that mostly for nerds like myself, but I work with many of those that need the news.  So I decided to post the Google News alert to the channel using their API.

I use python mostly, so I was looking for documentation on Python and Microsoft Teams did not find anything but found a reference to MS Teams Dev(Link) nothing of relevance, but I found on that site a load of information, some about Office 365 Connectors (Link)

From within Microsoft Teams, click “…” next to the channel name in the list of channels and then select Connectors.

Now we are going to choose “Web Hooks”

Now we give the Web Hook a useful name and hit create

It will take a second to create and give you the URL that is needed to make the API call

Copy the very long URL and we are going to use CURL to test our API call first.

Post a message using the webhook

For this part of the exercise, you’ll need cURL. It’s assumed that you have this installed and are familiar with basic usage.

1. From the command line, enter the following cURL command:

curl -H "Content-Type: application/json" -d "{\"text\": \"Hello World\"}" <YOUR WEBHOOK URL>
  1. If the POST succeeds, you should see a simple 1 output by cURL.

  2. Check the Microsoft Team. You should see the new card posted to the team.

Now that’s a little plain, let’s add a “title” to post

curl -H "Content-Type: application/json" -d "{\"title\": \"Testing 123 from CLI with CURL\", \"text\": \"Hello World\"}" <YOUR WEBHOOK URL>

Now that looks better but what if you want to add a link in the post here is an example:

curl -H "Content-Type: application/json" -d "{\"title\": \"Testing 123 from CLI with CURL\", \"text\": \"Hello World - [Microsoft](https://www.microsoft.com)\"}" <YOUR WEBHOOK URL>

Notice the link will take you to www.microsoft.com

Ok now for the fun stuff with Python…Part2 coming soon!

  • Author Details

      		![](https://i0.wp.com/sifbaksh.com/wp-content/uploads/2020/04/sifbaksh.png?w=200&ssl=1)
      			
    
    
      
      [Sif Baksh](https://sifbaksh.com/author/sifbaksh/)
      
      Administrator	
      	
      	
      		Principal Solutions Architect			 		
      

    As Principal Solutions Architect, Sif Baksh is responsible for the design of large-scale Core Services and Security systems. With 25 years of engineering experience in the computer and communications industry, Sif brings a depth of understanding of complex solutions for large and small organizations.

      						web
      							
      			[https://sifbaksh.com](https://sifbaksh.com)
      		
      		
      					
      
      
      
      			
      	email
      			
      	[sifbaksh@gmail.com](mailto:sifbaksh@gmail.com)
      
    
    
      				follow me
      			
  • **

  • **

  • **

  • **

  • **

Comments

Related Posts

My Journey into Automation: From Postman to Curl and Beyond

Introduction: The Beginning of Automation Today, I want to take you on a journey that started with curiosity and has become an essential part of my daily workflow. I’m talking about the fascinating world of automation. If you’ve ever need

Automation python

How to search for data in Infoblox via API(WAPI) using Python Module

Today we are going to take a look at retrieving different types of data from Infoblox via the RESTFUL API (a.k.a “Web API”, or WAPI) with the “requests” module and the “infoblox-client” using Python. You might want

Automation Infoblox