Public
Like
2
Discord-to-Linear
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v20View latest version
This automation creates Linear tickets from Discord messages when they receive a specific emoji reaction (๐งฟ :charmaine:).
- Visit the setup page: Open your Val Town URL in a browser to see the configuration dashboard
- Set environment variables (see below)
- Configure Discord webhook (instructions on the setup page)
- Test the integration using the built-in test form
Set these in your Val Town environment:
Variable | Description | Required |
---|---|---|
DISCORD_BOT_TOKEN | Your Discord bot token | โ |
LINEAR_API_KEY | Your Linear API key | โ |
LINEAR_TEAM_ID | The Linear team ID where tickets should be created | โ |
DISCORD_WEBHOOK_SECRET | Secret for verifying Discord webhooks | โ |
- Go to Discord Developer Portal
- Create a new application and bot
- Copy the bot token to
DISCORD_BOT_TOKEN
- Enable these bot permissions:
- Read Message History
- Add Reactions
- Use Slash Commands
- Add the bot to your Discord server
- In your Discord server settings, go to Integrations > Webhooks
- Create a new webhook pointing to:
https://[your-val-name].web.val.run/discord-webhook
- Configure it to listen for "Message Reactions" events
- Go to Linear Settings > API
- Create a new Personal API key
- Copy it to
LINEAR_API_KEY
- Find your team ID (use the
/linear-teams
endpoint) and setLINEAR_TEAM_ID
- User reacts to a Discord message with the configured emoji (๐งฟ)
- Discord sends a webhook to our service
- Service fetches the full message content
- Creates a Linear ticket with:
- Title: First 100 characters of the message
- Description: Full message content + link to Discord message
- Labels: "discord-import"
- Priority: Medium (configurable)
โโโ backend/
โ โโโ index.ts # Main HTTP handler and webhook endpoint
โ โโโ discord.ts # Discord API integration
โ โโโ linear.ts # Linear API integration
โ โโโ config.ts # Configuration and constants
โ โโโ types.ts # TypeScript type definitions
โโโ frontend/
โ โโโ index.html # Setup dashboard and testing interface
โโโ README.md
GET /
- Setup dashboard (web interface)POST /discord-webhook
- Discord webhook endpointPOST /test-ticket
- Manual ticket creation for testingGET /config
- Configuration statusGET /linear-teams
- List available Linear teamsGET /health
- Health check
Edit /backend/config.ts
to customize:
- Target emoji (default: ๐งฟ)
- Linear label name (default: "discord-import")
- Ticket priority (default: 3 = Medium)
- Title length limit (default: 100 characters)
- Use the web interface at your Val Town URL
- Or manually test with the
/test-ticket
endpoint:curl -X POST https://your-val.web.val.run/test-ticket \ -H "Content-Type: application/json" \ -d '{"message_id": "123", "channel_id": "456", "guild_id": "789"}'
- Check configuration status on the web dashboard
- Verify environment variables are set correctly
- Test Discord bot permissions in your server
- Check Linear API key has proper permissions
- Verify webhook URL is correctly configured in Discord
The automation is built with:
- Hono for the HTTP server
- Discord API v10 for message fetching
- Linear GraphQL API for ticket creation
- TypeScript for type safety
- TailwindCSS for the frontend
- Only processes
MESSAGE_REACTION_ADD
events - Automatically creates the "discord-import" label if it doesn't exist
- Handles both text messages and messages with attachments/embeds
- Generates meaningful ticket titles from message content
- Includes full context and links back to original Discord message