github-actionsslackslack-apislack-commandsslack-block-kit

Mention in slack payload does not become an actual mention in the posted message


I am using this action to post a message to a slack channel through a Github Actions workflow.

I am constructing the payload as follows


      - name: set slack payload
        uses: actions/github-script
        with:
          script: |
            const payload = {
              "text": "Some text",
              "username": "Some username",
              "icon_url": "https://www.ecample.com/icon.png",
              "attachments": [
                {
                  "mrkdwn_in": ["text"],
                  "color": "'#ffffff'",
                  "fields": [
                    {
                      "title": "A title",
                      "value": "some text",
                      "short": true
                    },
                    {
                      "title": "Mention",
                      "value": "<@username> hello",
                      "short": true
                    },
                  ]
                }
              ]
            }
            core.setOutput('payload', payload)

This works as expected and username does indeed get mentioned.

However when I am substituting it with a slack user group, it does not get mentioned.

Any ideas?


Solution

  • You can't use the human-readable name for user group mentions, but need the ID. You can get that, for example, from the user group side panel:

    user group context menu

    and then use it like this:

    "value": "<!subteam^ABCDEF12345> hello"