EvotecIT / PSTeams

PSTeams is a PowerShell Module working on Windows / Linux and Mac. It allows sending notifications to Microsoft Teams via WebHook Notifications. It's pretty flexible and provides a bunch of options. Initially, it only supported one sort of Team Cards but since version 2.X.X it supports Adaptive Cards, Hero Cards, List Cards, and Thumbnail Cards. All those new cards have their own cmdlets and the old version of creating Teams Cards stays as-is for compatibility reasons.
MIT License
409 stars 41 forks source link

Create a channel message, then reply to the message #40

Open LarsFosdal opened 3 years ago

LarsFosdal commented 3 years ago

Creating channel messages is awesome, but I find myself wishing that I would be able to reply to the initial message.

Scenario I am running a time-consuming script that updates several sites.

I'd like to first publish a message saying that "Update so and so is has started." Then, for each site that is processed, I'd like to reply to that message with a summary for that site. Finally, I'd finish off with a Upgrade completed message.

How do I identify a message? How to I reply to a message?

PrzemyslawKlys commented 3 years ago

Short answer: You can't do that with incoming webhooks Long answer: Probably can be done with Teams Graph Api as mentioned here: https://github.com/EvotecIT/PSTeams/issues/17

I have plans on exploring Teams Graph API and potentially supporting it in 3.0 but I have so many projects right now that are a priority for me - so can't promise any timelines.

codaamok commented 1 year ago

Replying to an existing message in Teams using Microsoft Graph API is possible but not really available using non-interactive authentication flows.

The application permission to use the API endpoint requires Teamwork.Migrate.All and has the following caveat:

Note: Application permissions are only supported for migration. In the future, Microsoft may require you or your customers to pay additional fees based on the amount of data imported.

First, the permission Teamwork.Migrate.All has so much reach, here is its description from the Azure portal:

Allows the app to create chat and channel messages, without a signed in user. The app specifies which user appears as the sender, and can backdate the message to appear as if it was sent long ago. The messages can be sent to any chat or channel in the organization.

Secondly, even if you were bat shit crazy enough to permit this, it's actually only operable on a Team set in migration mode (see the link above.)

Place the new team in migration mode, a special state that restricts users from most activities within the team until the migration process is complete.

I believe this endpoint and permission only really exists for non-interactive flows for products/services which let you migrate from e.g. Slack to Teams, to preserve/migrate chat history etc. Microsoft don't really provide a way via Graph API to expose this type of functionality in Teams. However, it seems to be possible relatively painlessly using delegated permissions.