Microsoft Teams notify (using Node-Red)

At work we use Microsoft Teams for calls, chat etc and I wanted a way to get alerts in a system I use regularly. Mobile is great, but some alerts could be urgent, or some could be just informational I don’t need to alert my phone.

It was surprisingly easy to configure (2 steps)

  1. Inside of teams set up a connector either within the specific team, or search for the app (and then add it to a team) - i’d recommend creating a private team that isnt searchable for this :wink: The connector/App is called ‘Incoming Webhook’…

  1. Complete the name of the webhook (HomeAssistant in my case), and upload an image of the HomeAssistant Logo. Copy the Webhook URL, and store it somewhere as you’ll need it later.

DONE - I know, crazy right?!

However now we have to send content to the webhook URL, and actually this is really easy too.
In Node-Red create an inject node -> template node -> http request node

In the Test Teams Node use this example:

{
  "@context": "https://schema.org/extensions",
  "@type": "MessageCard",
  "themeColor": "0072C6",
  "title": "HomeAssistant is now connected to Teams",
  "text": "Actionable Messages possible as well"
}

In the http request node configure:
Method: POST
URL: <Webhook_URL_from_Teams>

Deploy, and inject. you should see this in your Teams Channel now:

Now here’s the fun part, check out the ‘Card Playground’ to really have some fun with your messages and cards
Pictures, actionable responses etc etc.

HTH

3 Likes

Newer card tool: https://amdesigner.azurewebsites.net/

Outlook also has a webhook connector too.

Note outlook accepts
HeroImage To add an image. However Teams currently does not. Just text.

Wow! Have to check this out!

I remember something that we might have connector apps blocked. Hopefully this ban is lifted by now :smiley:

Can you send chat messages also with this?

My dev skills are pretty limited.
I imagine someone with more talent and know-how could either:

  1. Build a bot to receive JSON with specific structure from HA and the webhook URL?
    Or
  2. Build a custom component in HA to send a standard notify with structure like android, iOS etc.

Right now this is completely manual and probably only possible without much uplift from Node-Red.

I was hoping someone would be interested in exploring the Microsoft Graph (events, calendar, teams, outlook etc)

well looks like @peroyvind did build an official integration in for the next release:

Not sure how its using image, as it looked like image wasn’t supported in the Webhook for teams when I had a look at the docs

also seems to be an interesting notification platform called ‘apprise’ being integrated in the next release:

APPRISE: https://github.com/caronc/apprise/

1 Like

Thanks for referring this one - that looks promising - how’s your experience with it so far?

I’m not really using this with HA, but I am using the node-red to teams webhook connector.

Here are some observations:

  1. it’s effective and does what you’d expect.
    You create a template, shove it through the webhook URL as a POST (leave the rest of the node boxes unchecked) and voila, Teams will spit out your card.

  2. It’s limited to Legacy Cards formatting.
    See Office 365 connector card for details. You don’t get to do much with them. In fact the original link to the message card playground is really the best place to fiddle. If you use the adaptive card playground, you’ll end up with a card that doesn’t work.

  3. I want more.

I use this feature to send out coffee maker notifications. They are pretty simple. They use the node-red simpletime node to pass the time the coffee is ready to the card, but they don’t do much else. I’d like some more flexibility.

I have since expanded the system to detect the size of pot made (cup, half pot, full pot) but they’ll just have to be 3 different templates rather than something smarter.

this is great, can you suggest or supply the export of the flow. I am keen to explore the teams connector but unsure what node red package you are using.

how can i get messgaes to node red?

so lets say someone will say i want coffe and the machine will turn on?