Pages Menu
TwitterRssFacebook

Posted by on Nov 7, 2016 in Development, Everything Else, Skype for Business® (Lync®) | 0 comments

Posting messages to Microsoft Teams from IFTTT, PowerShell and beyond!

Posting messages to Microsoft Teams from IFTTT, PowerShell and beyond!

Edit: I found out after posting this that Michael Greene actually wrote a very similar post on this a few days ago, so you should definitely go and read his post too, especially as he has some additional information about posting cards as well as just IMs.

Microsoft Teams has been out for a little while now. I’ve already blogged about the developer opportunities that exist today, but it turns out that there’s a really cool, single integration method for posting messages into Teams.

Imagine if you could post to a team, just by calling a web URL?

That would mean that you can integrate it with IFTTT, or use it with anything that can post to a URL, like monitoring tools. Or build it into PowerShell scripts to notify a Team when something happens.

Why is this exciting? Wouldn’t it be handy if your website monitoring could post to your team when the CPU starts maxing out? Or, when the server-room door is opened, or the temperature there reaches a peak temperature.

Here’s how to do that. Read on for instructions on setup, then using in IFTTT and PowerShell.

Setup in Teams

From within a team, click the ellipsis next to the team name, and choose Connectors:

2016-11-07-19_02_38-onenote

 

Find the Incoming Webhook connector in the list, and click Add:

2016-11-07-19_03_29-onenote

 

Give your webhook a fancy name, and upload an image if you want to – this image will show up as the avatar when your message is posted:

2016-11-07-19_04_00-onenote

 

Click the Create button. Once the webhook is created you’ll see a URL. This is an auto-generated, unique URL that posts to your team. This is a public URL – anyone who has it can post to your team. Bear that in mind before you share it around!

2016-11-07-19_05_09-onenote

 

Setup complete. Now, we can have fun.

Usage 1 – IFTTT

Let’s create a new IFTTT recipe applet. For this example I’m going to post to my team when the forecast suggests that it’s going to rain tomorrow. I like to keep my team informed!

First, choose the service. I’m going to choose the Weather service:

2016-11-07-19_24_19-new-notification

 

Step through whatever configuration options you need to setup your service:

2016-11-07-19_24_41-onenote

 

Once you get here, click “that” to add the action. Add the Maker channel:

2016-11-07-19_25_11-onenote

2016-11-07-19_57_25-settings

The Maker channel lets you POST to URL endpoints, perfect for what we want to do.

Click on the “Make a web request” button:

2016-11-07-19_25_28-settings

 

Copy the secret URL you got from Teams and paste it into the URL field. Make sure that the Method is set to POST:

2016-11-07-19_26_06-onenote_2

Make sure the Content-Type is “application/json”. The body is where you can put the message that will go to the Team. You have to use this format for the Body:

{“text” : “Head’s up – rain tomorrow! High of {{HighTempCelsius}} C”}

This is important, because if you get it wrong then the message won’t be posted. You need the curly braces, and the quotation marks, and the ‘ “text” : ‘ bit. You can add in Ingredients to personalise your message, such as in the example above where I’ve included the max temperature.

Once you’ve done that, click Finish and you’re done.

2016-11-07-19_27_16-start

Usage 2 – PowerShell

You can do the same thing using PowerShell if you want to embed message sending into something you already have. Here’s how:

Cool, right?!

If all went well, you’ll see 1 returned from the call to Invoke-RestMethod. The messages show up immediately in Teams, there’s seemingly no delay when sending messages this way, which is good news.

Usage 3 – ???

There’s loads of different places you could put this. If you find that you can use it to integrate with something cool / interesting, let me know in the comments 🙂

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses cookies to help make this website better. By continuing to use this site we’ll assume you’re OK with that (implied consent).