A message was posted containing one or more links relevant to your application

Facts

Required scopes

Works with

Events API

The link_shared event is sent over the Events API when a link—matching the registered URL domain your app is setup to track—is posted.

Your app will receive this event both when the link is written into the message composer before being posted, and when the link is posted into a Slack channel.

The link_shared event is not dispatched when a message posted by an app or integration includes a matching domain.

For context on these events, learn more about unfurling links in messages.

{
    "token": "XXYYZZ",
    "team_id": "TXXXXXXXX",
    "api_app_id": "AXXXXXXXXX",
    "event": {
        "type": "link_shared",
        "channel": "Cxxxxxx",
        "is_bot_user_member": true,
        "user": "Uxxxxxxx",
        "message_ts": "123456789.9875",
        "unfurl_id": "C123456.123456789.987501.1b90fa1278528ce6e2f6c5c2bfa1abc9a41d57d02b29d173f40399c9ffdecf4b",
        "thread_ts": "123456621.1855",
        "source": "conversations_history",
        "links": [
            {
                "domain": "example.com",
                "url": "https://example.com/12345"
            },
            {
                "domain": "example.com",
                "url": "https://example.com/67890"
            },
            {
                "domain": "another-example.com",
                "url": "https://yet.another-example.com/v/abcde"
            }
        ]
    },
    "type": "event_callback",
    "authed_users": [
        "UXXXXXXX1",
        "UXXXXXXX2"
    ],
    "event_id": "Ev08MFMKH6",
    "event_time": 123456789
}

The thread_ts field only appears when the link was shared within a message thread.

is_bot_user_member is a boolean field indicating whether the app’s bot user is a member of the conversation.

unfurl_id identifies the link and can be used to supply the chat.unfurl method (along with source).

source is an enumerated string that tells you whether the event happened in composer ("source": "composer") or in a sent message ("source": "conversations_history).

Take care with the message_ts and channel fields. When the source of this event is the message composer, rather than a posted message, these values don't correspond to typical timestamps and channels. No matter what, the values of message_ts and channel always work to supply chat.unfurl, but if you attempt to use other Slack API methods with these timestamps and channels, the calls will fail.

A full payload for the link_shared event sent when a link is typed into the message composer is:

{
    "type": "link_shared",
    "channel": "COMPOSER",
    "is_bot_user_member": true,
    "user": "Uxxxxxxx",
    "message_ts": "Uxxxxxxx-909b5454-75f8-4ac4-b325-1b40e230bbd8-gryl3kb80b3wm49ihzoo35fyqoq08n2y",
    "unfurl_id": "Uxxxxxxx-909b5454-75f8-4ac4-b325-1b40e230bbd8-gryl3kb80b3wm49ihzoo35fyqoq08n2y",
    "source": "composer",
    "links": [
        {
            "domain": "example.com",
            "url": "https://example.com/12345"
        },
        {
            "domain": "example.com",
            "url": "https://example.com/67890"
        },
        {
            "domain": "another-example.com",
            "url": "https://yet.another-example.com/v/abcde"
        }
    ]
}

Learn more about unfurling links in messages.