|
| 1 | +# Receiving Discord Interactions Locally |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- Docker Compose |
| 6 | +- A [Discord Application](https://discord.com/developers/applications) with an |
| 7 | + Interactions Endpoint configured |
| 8 | +- An [ngrok](https://ngrok.com) account (free tier works) |
| 9 | + |
| 10 | +## 1. Get your public key |
| 11 | + |
| 12 | +1. Go to **Discord Developer Portal → Applications → your app → General Information** |
| 13 | +2. Copy the **Public Key** (hex string) |
| 14 | + |
| 15 | +## 2. Start the stack |
| 16 | + |
| 17 | +```bash |
| 18 | +DISCORD_PUBLIC_KEY=<your-hex-public-key> docker compose --profile dev up |
| 19 | +``` |
| 20 | + |
| 21 | +This starts NATS, the webhook receiver, and ngrok. Find the public tunnel URL |
| 22 | +in the ngrok container logs: |
| 23 | + |
| 24 | +```bash |
| 25 | +docker compose logs ngrok |
| 26 | +``` |
| 27 | + |
| 28 | +Look for the `discord` tunnel URL (e.g. `https://abc123.ngrok-free.app`). |
| 29 | + |
| 30 | +## 3. Configure your Discord Application |
| 31 | + |
| 32 | +1. Go to **Discord Developer Portal → Applications → your app → General Information** |
| 33 | +2. Set **Interactions Endpoint URL** to `https://<ngrok-url>/webhook` |
| 34 | +3. Discord will send a PING to verify the endpoint — the receiver handles this |
| 35 | + automatically |
| 36 | + |
| 37 | +## 4. Verify |
| 38 | + |
| 39 | +Create a slash command or trigger an interaction. You should see: |
| 40 | + |
| 41 | +- The webhook receiver log the incoming interaction |
| 42 | +- The interaction published to NATS on `discord.{interaction_type}` |
| 43 | + |
| 44 | +You can inspect NATS with: |
| 45 | + |
| 46 | +```bash |
| 47 | +nats sub -s nats://nats.trogonai.orb.local:4222 "discord.>" |
| 48 | +``` |
| 49 | + |
| 50 | +Without `--profile dev`, ngrok is excluded and only the core services start. |
| 51 | + |
| 52 | +## Environment variables |
| 53 | + |
| 54 | +| Variable | Required | Default | Description | |
| 55 | +|---|---|---|---| |
| 56 | +| `DISCORD_PUBLIC_KEY` | yes | — | Ed25519 public key (hex) from Discord app settings | |
| 57 | +| `NGROK_AUTHTOKEN` | yes (dev profile) | — | ngrok auth token | |
| 58 | +| `DISCORD_WEBHOOK_PORT` | no | `8080` | HTTP port for the webhook receiver | |
| 59 | +| `DISCORD_SUBJECT_PREFIX` | no | `discord` | NATS subject prefix | |
| 60 | +| `DISCORD_STREAM_NAME` | no | `DISCORD` | JetStream stream name | |
| 61 | +| `RUST_LOG` | no | `info` | Log level | |
0 commit comments