Jack.c
Jack.c

Reputation: 1245

Node and Microsoft Teams API

I'm building a Node only application that reads logs in the background and based on an event being read will send a message to a Teams channel directly.

I've been having quite a few issues getting a Graph API access token valid through Username and password.

I have been able to get a Graph API access token with client secret and tenant id which represents access "without a user". Now that does not allow me to post a message in a channel as I would need to have access "on behalf of a user".

API => https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages .

Would there be another way of achieving this? Webhook/Connectors?

Thank you!

Upvotes: 2

Views: 3129

Answers (1)

alphaz18
alphaz18

Reputation: 2746

There's a few different ways you can post to a teams channel, you can set up like you said an http webhook, where you could call it to post into a channel https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using

You can use power automate (flow) or logic apps to post messages as the flowbot, or you can write a bot/ use the bot framework to register a bot that can post to teams, called proactive messaging: https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bot-conversations/bots-conv-proactive

As for trying to use graph with application permissions, that's not possible, at least for the moment.

Upvotes: 1

Related Questions