EvotecIT/PSTeams

Create a channel message, then reply to the message

LarsFosdal opened this issue · 2 comments

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?

Short answer: You can't do that with incoming webhooks
Long answer: Probably can be done with Teams Graph Api as mentioned here: #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.

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.