Files
supabase/apps/docs/content/guides/functions/examples/slack-bot-mention.mdx
Colum Ferry d97a410577 docs: add a Supabase CLI v2 to v3 migration guide (#52147)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Docs update

## What is the current behavior?

There's no page covering the breaking changes between Supabase CLI v2
and v3. v3.0.0 was released on 2026-11-02.

## What is the new behavior?

Adds a migration guide at
`/docs/guides/local-development/cli/migrating-to-v3`, linked from the
Local Dev / CLI nav just under "Install and run the CLI". It's modelled
on [Vite's migration guide](https://vite.dev/guide/migration): a short
summary, what to do before upgrading, how to install (or stay on v2), a
CI quick-reference table, then one section per change, ending with the
removed commands, flags, config keys and env vars as tables.

The content comes from the `BREAKING CHANGE` footers of the breaking PRs
on supabase/cli `next`, checked against the code there:
supabase/cli#6609, supabase/cli#7064, supabase/cli#7066,
supabase/cli#7074, supabase/cli#7109, supabase/cli#7116,
supabase/cli#7172, supabase/cli#7176, supabase/cli#7188 and
supabase/cli#7221.

## Additional context

The page describes v3.0.0 as released: npm `latest`, Homebrew, Scoop and
the Linux packages all install v3.

The "Staying on v2" channels are live with v2.122.1: npm `v2.stable`,
`supabase/tap/supabase@2`, `supabase-v2-stable` on Scoop, and `version:
v2.stable` or a semver range like `^2` on `supabase/setup-cli@v3`
(ranges need v3.2.0).

It also updates about 60 existing guides and troubleshooting pages for
v3. Hosted examples pass `--remote`, CI examples that change a hosted
project pass `--yes`, deprecated target flags and removed commands are
replaced, and pages that described migra as the default now describe
pg-delta.

It adds a new concept page, "Running commands against local and hosted
projects" at `/docs/guides/local-development/local-and-hosted-projects`,
linked from the Local Dev nav after "Local development workflow". It
covers how a command picks its target (local by default, `--remote` and
its forms, the linked project, the `Target:` line), how settings resolve
(flag, then shell env, then project env files, then config), and when
the CLI asks before changing a hosted project (`--yes`, `SUPABASE_YES`,
`--dry-run`, seeding), with a CI recipe and a section for AI coding
agents. The migration guide links to it from its target, consent and
config sections.

Tracks CLI-2747

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-11-02 13:44:40 +00:00

67 lines
2.3 KiB
Plaintext

---
id: 'slack-bot-mention'
title: 'Slack Bot Mention Edge Function'
description: 'Building a Slack Bot that Handles Mentions.'
---
The Slack Bot Mention Edge Function allows you to process mentions in Slack and respond accordingly.
## Configuring Slack apps
For your bot to seamlessly interact with Slack, you'll need to configure Slack Apps:
1. Navigate to the Slack Apps page.
1. Under "Event Subscriptions," add the URL of the `slack-bot-mention` function and click to verify the URL.
1. The Edge function will respond, confirming that everything is set up correctly.
1. Add `app-mention` in the events the bot will subscribe to.
## Creating the Edge Function
Deploy the following code as an Edge function using the CLI:
```bash
supabase secrets set \
SLACK_TOKEN=<xoxb-0000000000-0000000000-01010101010nacho101010> \
--remote=nacho_slacker
```
Here's the code of the Edge Function, you can change the response to handle the text received:
```ts index.ts
import { WebClient } from 'npm:@slack/web-api@^7'
import { withSupabase } from 'npm:@supabase/server@^1'
const slackBotToken = Deno.env.get('SLACK_TOKEN') ?? ''
const botClient = new WebClient(slackBotToken)
console.log(`Slack URL verification function up and running!`)
// Slack calls this endpoint, so deploy with --no-verify-jwt.
export default {
fetch: withSupabase({ auth: 'none' }, async (req) => {
try {
// Implement your Slack request signature verification here before trusting the payload
// (validate `x-slack-signature` / `x-slack-request-timestamp` with your signing secret).
const reqBody = await req.json()
console.log(JSON.stringify(reqBody, null, 2))
const { token, challenge, type, event } = reqBody
if (type == 'url_verification') {
return Response.json({ challenge })
} else if (event.type == 'app_mention') {
const { user, text, channel, ts } = event
// Here you should process the text received and return a response:
const response = await botClient.chat.postMessage({
channel: channel,
text: `Hello <@${user}>!`,
thread_ts: ts,
})
return Response.json({ ok: true })
}
} catch (error) {
return Response.json({ error: error.message }, { status: 500 })
}
}),
}
```