Slackbot: Slack Link Preview User Agents and Blocking
Slack fetches links that users post in Slack to build previews. Its user agents, why it ignores robots.txt, the tags it reads and how to block it.
Slackbot-LinkExpanding is the bot that Slack uses to build link previews. When a Slack user posts a link, Slack fetches the page and reads its meta tags. Slack does not follow robots.txt for these requests. If you want to control the previews, set your meta tags, or block the user agent on your server.
Slack user agents
The Slack robots page lists three user agents:
| User agent | What it does |
|---|---|
Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots) |
Fetches links that users post, to build previews |
Slack-ImgProxy 0.19 (+https://api.slack.com/robots) |
Fetches and caches images posted in Slack channels |
Slackbot 1.0 (+https://api.slack.com/robots) |
All other requests, for example API calls to integrated services and outgoing webhooks |
Slack proxies images for three reasons. The proxy hides referrer data, which can include team or project names. It also serves the images over HTTPS and improves performance.
How link previews work
Slack calls a link preview an unfurl. Slackbot-LinkExpanding fetches as little of the page as it can. It uses HTTP Range headers, which request only part of a file. It looks for these tags:
- oEmbed
- Open Graph tags
- Twitter Card tags
If a tag points to an image, video or audio file, Slack fetches that file too. Slack caches the result across the service for about 30 minutes. So you see about one request for the same URL in that time.
The guides for Open Graph tags and Twitter Card tags show the tags that Slack reads.
If a workspace has an app that handles links for your domain, the app builds the preview instead. The Slack unfurling guide describes this.
Why Slack ignores robots.txt
Slack says that it stopped processing robots.txt files. Slack does not follow links, and it acts for the person who posted the link. Slack also says that users complained, because many sites block crawlers. So a Disallow rule for Slackbot has no effect.
Block or change previews
You have these options:
- Refuse requests from
Slackbot-LinkExpandingon your server or firewall. Slack then cannot read your tags. - Ask Slack to block your site from Slack embeds, or to change how your embeds look. Slack offers a blocklist and an allowlist through its contact page.
- A Slack user can remove the preview while writing a message.
- An app that posts messages can set
unfurl_linksandunfurl_mediatofalse.
The Slack robots page gives no IP addresses for these bots. Any client can send these user agents, so a match does not prove that a request came from Slack.