Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request for mentioning users #253

Open
BenedettoHabitante opened this issue Nov 24, 2023 · 5 comments
Open

Feature request for mentioning users #253

BenedettoHabitante opened this issue Nov 24, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@BenedettoHabitante
Copy link

It seems that the feature for mentioning user(s) inside the notification, just like one can tag a user manually in MS Teams via the "@" symbol, is not possible yet, right?

Would it be possible to add this feature similar to this Adaptive Card?

Thanks in advance.

@mikesprague mikesprague added the enhancement New feature or request label Nov 24, 2023
@mikesprague mikesprague self-assigned this Nov 24, 2023
@mikesprague
Copy link
Owner

Unfortunately, I am not sure how practical that would be as they require the Entra (Active Directory) ID and the User Principal Name for each person someone wants to @ mention.

Incoming webhooks start to support user mention in Adaptive Cards with the Microsoft Entra Object ID and UPN

(:point_up: from docs you linked to)

If you have implementation suggestions or want to try coding it yourself and submitting a pull request, I will definitely consider it. My initial thoughts though are that it's a bit out of scope for this project.

@BenedettoHabitante
Copy link
Author

First of all thanks a lot for your quick response and of course thanks for making your nice repository public so that other people can use it.

I found out that either the Entra (Active Directory) ID or the UPN are required, but not both.

I tried out this minimal example which works exactly as intended:

{
    "type": "message",
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "content": {
                "type": "AdaptiveCard",
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "version": "1.3",
                "msteams": {
                    "width": "Full",
                    "entities": [
                        {
                            "type": "mention",
                            "text": "<at>Benedetto Habitante</at>",
                            "mentioned": {
                                "id": "[email protected]",
                                "name": "Benedetto Habitante"
                            }
                        }
                    ]
                },
                "body": [
                    {
                        "type": "Container",
                        "items": [
                            {
                                "type": "TextBlock",
                                "text": "Hi <at>Benedetto Habitante</at>",
                                "weight": "bolder",
                                "size": "medium"
                            }
                        ]
                    }
                ]
            }
        }
    ]
}

(Above, I provided an UPN as id under mentioned, but this could also be an AD id.
Posting the json from above would result in this notification
image

I could imagine an interface on the GitHub action side that would be quite useful like this:

jobs:
  teams_notification:
      runs-on: ubuntu-22.04
      # Run always even if the main workflow fails, is cancelled, or is skipped
      if: ${{ always() }}
      needs: main_workflow
      steps:
        - name: Cancelled Notification
          if: ${{ needs.main_workflow.result == 'cancelled' }}
          uses: mikesprague/[email protected]
          with:
            github-token: ${{ github.token }}
            webhook-url: ${{ secrets.MS_TEAMS_WEBHOOK_URL }}
            deploy-card: true
            timezone: "Europe/Rome"
            title: 'Release Check Cancelled, triggered by <at>Benedetto Habitante</at>'
            color: 'warning'
            mentions:
              - name: "Benedetto Habitante"
                id: "[email protected]"  # This can be either a UPN or an AD id

Also, I saw that you provide an optional message field to be filled by the GitHub action, here which - unlike the title - is not posted for deploy notifications. Would it be possible to add that also for deploy notifications where a user could then be mentioned in the text?

If I could submit a pull request in Python here, I would really try out coding it myself, but unfortunately I am not familiar with TypeScript at all.

@mikesprague
Copy link
Owner

mikesprague commented Dec 1, 2023

@BenedettoHabitante With a little more time to think about this, I am not opposed to the ideas since they would be opt-in and not change the experience for other users.

That said, I don't see a practical way to allow mentions inline (within a message) per se. I will likely implement them with a line that shows something like the following if mentions are supplied:

Mentions: @somerandomeuser1, @mention2

I am not sure when I will be able to get to this but likely in the coming weeks. Once completed, they will prob be part of a major version release (v2.0.0) and I will leave this issue open until I am able to do this work.

@BenedettoHabitante
Copy link
Author

Hi @mikesprague,
this sounds great!
Sure! If inline mentions are more complicated to implement then a new line, like

Mentions: @somerandomeuser1, @mention2

would be nice, too.

Perfect. I am very much looking forward to version release (v2.0.0)
Thanks a lot!

@runxc1
Copy link

runxc1 commented May 1, 2024

I like the idea of Mentions as I've basically got a single Teams group that the build notifications go to and imagine it being a little spam like so would love it when only certain events (build failed) ping a specific person

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants