# Slack bot

URL: https://qrdx.dev/docs/slack-bot
Source: https://github.com/bucharitesh/qrdx/blob/main/apps/docs/content/docs/slack-bot.mdx

Make and style QR codes in Slack with /qr, a mention, a direct message or a message shortcut, and tracked codes once you link your QRdx account.

QRdx has a Slack app that makes QR codes inside Slack. Anyone in a Slack workspace that has the bot can make a code from a link or any text. People who link their QRdx account can also make tracked (dynamic) codes, which count scans and can point somewhere else later.

## Add the bot to Slack

1. In QRdx, open [Settings → Integrations → Slack](https://qrdx.dev/settings/integrations/slack) and click **Add the bot to Slack**. Any QRdx account can do this, on any plan.
2. Pick the Slack workspace and approve. The bot asks to see its slash command, mentions of it and its direct messages, and to post messages.
3. You come back to the settings page, which lists the Slack workspaces you added the bot to.

The same Slack app also posts [alerts](https://qrdx.dev/docs/notifications#slack-and-discord) to a channel. Adding the bot doesn't turn alerts on, and adding alerts doesn't add the bot.

## Make a QR code

| Where | What to do | Where the code appears |
| --- | --- | --- |
| Any channel | `/qr` followed by a link or text | In the channel |
| A channel the bot is in | Mention the bot with a link or text | In the thread |
| The bot's direct messages | Send a link or text | In the DM |
| Any message | **More actions** → **Make a QR code** | In the message's thread |

Each answer is a QR code image with the content under it, three buttons and the style menus described below. The buttons are **Download PNG** (1024 pixels), **Download SVG** and **Open in editor**, where you can change the design further. A link opens the editor with that link filled in; text opens an empty editor, because text never goes into a link.

The shortcut makes a code of the message's first web address, or of its whole text when it has none. If the bot isn't in that channel, only you see the code, and a note says to add the app to the channel.

`/qr` on its own, or `/qr help`, shows the commands. Content that is too long for a QR code gets a short explanation instead of an image, and only you see it.

## Style your code

Under each code are four menus: **Look**, **Color**, **Frame** and **Logo**. Pick something and the code changes in place, with new download links. Each pick builds on the code as it is now. Only the person who made the code can restyle it. When someone else picks, Slack shows them a note that only they can see, and the code stays as it was.

The looks are some of the editor's built-in designs that read well at small sizes, and **Plain** goes back to black on white. A color puts the whole code in that color on white. The frames add a "Scan me" label, and the logos are the editor's quick icons.

You can also style a code as you make it by adding options after the link or text, with the same names as the [QRdx CLI](https://qrdx.dev/docs/developers/cli):

```text
/qr qrdx.dev --look modern --fg 0051ff --frame banner-bottom --frame-text "Scan me"
```

Everything before the first option is the content. The look is applied first and the other options on top of it, so `--look royal --fg 0051ff` keeps Royal's shapes in blue. Options work in mentions and direct messages too. If an option or value is wrong, the bot tells you privately and lists the values it takes.

| Option | What it changes | Values |
| --- | --- | --- |
| `--look` | The whole design, from one of the editor's presets | `plain`, `classic`, `modern`, `royal`, `folio`, `caffeine`, `retro`, `bordeaux`, `blossom` |
| `--fg` (or `--color`) | The dots, and the corner eyes unless you set those too | A hex color such as `0051ff`, or `black`, `blue`, `green`, `red`, `purple`, `orange` |
| `--bg` | The background | The same as `--fg` |
| `--eye-color` | The three corner eyes | The same as `--fg` |
| `--dot-color` | The centers of the corner eyes | The same as `--fg` |
| `--body` | The shape of the dots | Any of the editor's 23 dot shapes, such as `rounded`, `circle` or `classy` |
| `--eye` | The shape of the corner eyes | Any of the 17 eye shapes, such as `square`, `rounded` or `gear` |
| `--dot` | The shape of the eye centers | Any of the 21 center shapes, such as `square`, `rounded` or `circle` |
| `--frame` | A frame around the code | `none` or any of the 19 built-in frames, such as `banner-bottom`, `banner-top`, `speech-bubble` or `polaroid` |
| `--frame-text` | The frame's label, up to 24 characters | Any text, in quotes when it has spaces. Without `--frame`, it goes on a banner under the code |
| `--template` | A decorative border | `Arrow`, `StandardBox`, `SquareBorder`, `StrikedBox` or `Halloween` |
| `--logo` | An icon in the middle | `link`, `wifi`, `location`, `phone`, `email`, `whatsapp`, `instagram`, `file`, `calendar` or `none` |

Before a styled code is posted, QRdx checks it with the same scan score as the editor. When a design would be hard for phones to read, QRdx adjusts it (darker colors, plainer shapes or more error correction) and says so under the code. If that still isn't enough, usually because the content is long, you get the code in black on white with a note. A styled code from `/qr` arrives a moment after you send the command, once it has been checked.

**Open in editor** opens the editor with the same design: colors, shapes, frame and border. The logo icon doesn't travel in the link, so pick it again in the editor.

Codes from the shortcut that only you can see have no menus, and tracked codes keep the plain design.

## Tracked codes

A plain code holds the link itself. A tracked code holds a short link (`https://qrdx.dev/q/<slug>`) that redirects to your link, so QRdx counts its scans and you can change where it goes. To make them from Slack, link your QRdx account once:

1. Run `/qr link`. A button only you can see opens QRdx. It works for 10 minutes.
2. Sign in to QRdx if asked. Then click **Sign in with Slack** and sign in as the same Slack account that ran `/qr link`. Slack tells QRdx only your Slack user and workspace, and QRdx checks that they match. If you sign in to Slack as someone else, nothing is linked.
3. Pick the QRdx workspace your tracked codes should go to and click **Confirm**. QRdx asks you to [confirm it's you](https://qrdx.dev/docs/help/privacy-and-security/two-step-verification#confirm-its-you) first, because the link lets that Slack account make codes in your workspace.
4. Back in Slack, the bot sends you a direct message naming the QRdx account and workspace you linked to. If you didn't link it, run `/qr unlink`.
5. Run `/qr track` followed by a link that starts with `https://` or `http://`. You can also mention the bot with `track` and a link.

The code appears in the channel with its short link and the name of the QRdx workspace it's in. The **Open in QRdx** button, which leads to the code in your dashboard, comes in a separate message that only you can see. The code is named after the link's site plus "from Slack", and you'll find it in the workspace's codes like any other.

Tracked codes follow the same rules as codes made in the dashboard: your role must allow creating codes, a workspace that requires two-step verification needs it on for your account, and your plan's limit on active dynamic codes applies. When you're at the limit, the bot says so and links to the plans. These are checked every time, so leaving a workspace or losing access stops the link from working there.

Each Slack account has one link per Slack workspace. When you run `/qr link` for a Slack account that's already linked, the page says which QRdx workspace it's linked to, and whether that's in another QRdx account. The button then reads **Replace the link**, and nothing changes until you click it. `/qr unlink` removes a link, and so does **Unlink** under **Linked Slack accounts** in [Settings → Integrations → Slack](https://qrdx.dev/settings/integrations/slack).

Owners and admins of a QRdx workspace see every Slack account linked to it in [Settings → API keys & apps](https://qrdx.dev/dashboard?to=settings/developers): the Slack workspace, the Slack user id, the member it acts as and when it was linked. **Revoke** removes a link there. If the workspace has the [audit log](https://qrdx.dev/docs/help/teams/audit-log), codes made with `/qr track` show the member's name "via Slack", with the Slack user and workspace ids, and revoking a link is recorded too.

## What the bot keeps [#what-the-bot-keeps]

The bot reads a message only when someone runs `/qr`, mentions the bot, messages it directly or uses the shortcut on that message. It never stores message text. QR code images come from the QRdx [image API](https://qrdx.dev/docs/developers/image-api), which Slack loads from the link in the message, so nothing is uploaded.

For each Slack workspace QRdx keeps its id and name, the bot's Slack user id, the bot's token (encrypted) and which QRdx account added it. For each linked Slack account it keeps the Slack user id, your QRdx account and the workspace you picked. Signing in with Slack to link adds nothing to that: QRdx compares the Slack user and workspace, then forgets the sign-in. Your linked Slack accounts are in your [data export](https://qrdx.dev/docs/help/account-and-billing/export-your-data).

## Remove the bot

In Slack, open the app's page and choose **Remove App** (or ask a Slack admin to). QRdx then deletes that Slack workspace's bot token and every Slack account link made there. Codes already made stay in QRdx, and tracked codes keep working.

## Self-hosting [#self-hosting]

The bot uses the same Slack app as "Add to Slack" alerts, with its signing secret added. Set `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `SLACK_SIGNING_SECRET`, plus `INTEGRATION_ENCRYPTION_KEY` in production, which encrypts the bot tokens. Without them the bot's pages and endpoints don't exist. `plugins/slack/manifest.json` in the repository is the app's manifest, and `plugins/slack/README.md` walks through creating the app from it. The manifest includes the `openid` user scope and the redirect URL `/api/integrations/slack/link/callback`, which Sign in with Slack needs when someone links their account.
