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: v69View latest version
This automation creates Linear tickets from Discord messages when they receive a specific emoji reaction (๐งฟ :charmaine:).
- Set environment variables: Add
DISCORD_BOT_TOKEN
,LINEAR_API_KEY
, andLINEAR_TEAM_ID
to your Val Town environment - Create and add Discord bot: Follow the setup instructions below
- Test the integration: Use the setup dashboard to verify everything works
- Start using: React to Discord messages with ๐งฟ to create tickets!
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 | โ |
In your Val Town environment, add these 3 required variables:
DISCORD_BOT_TOKEN
- Your Discord bot tokenLINEAR_API_KEY
- Your Linear API keyLINEAR_TEAM_ID
- Your Linear team ID
- 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
- In Discord Developer Portal, go to OAuth2 โ URL Generator
- Select "bot" scope
- Select the permissions mentioned above
- Use the generated URL to invite the bot to your server
- Go to Linear Settings โ API
- Create a new Personal API key
- Copy it to
LINEAR_API_KEY
- Open the setup dashboard (
/setup-dashboard.ts
) - Click "Get Linear Teams" button
- Copy your team ID to
LINEAR_TEAM_ID
- Use the setup dashboard to verify all environment variables are set
- Test ticket creation with the built-in test form
- Try reacting to a Discord message with ๐งฟ
This automation uses a Discord webhook to receive reaction events. You need to configure this in the Discord Developer Portal:
- Go to Discord Developer Portal
- Select your bot application
- Go to "Webhooks" in the left sidebar
- Click "New Webhook"
- Set webhook URL to:
https://[your-username]-discord-linear-automation.web.val.run
- Subscribe to event:
MESSAGE_REACTION_ADD
- Save the webhook
In your Discord application settings:
- Go to "Bot" โ "Privileged Gateway Intents"
- Enable "Message Content Intent"
- User reacts to a Discord message with the configured emoji (๐งฟ)
- Val Town's Discord webhook automatically triggers the automation
- 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)
โโโ discord-linear-automation.ts # Main automation (uses discordWebhook)
โโโ setup-dashboard.ts # Setup interface and testing tools
โโโ backend/
โ โโโ 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 interface
โโโ README.md
discord-linear-automation.ts
- The main automation that processes Discord reactionssetup-dashboard.ts
- Web interface for configuration and testing- Use the setup dashboard to test ticket creation and verify your configuration
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 setup dashboard (
/setup-dashboard.ts
) to:- Check configuration status
- Test ticket creation with any Discord message
- Get your Linear team IDs
- Manual API testing:
curl -X POST https://your-setup-dashboard.web.val.run/test-ticket \ -H "Content-Type: application/json" \ -d '{"message_id": "123", "channel_id": "456", "guild_id": "789"}'
- Live testing: React to any Discord message with ๐งฟ
- Check configuration status on the setup dashboard
- Verify environment variables are set correctly in Val Town
- Test Discord bot permissions - ensure bot can read message history
- Check Linear API key has proper permissions to create issues
- Use the test form in the setup dashboard to isolate issues
- Check Val Town logs for detailed error messages
- Bot not responding: Verify bot is in the server and has correct permissions
- API errors: Check that environment variables are set without extra spaces
- Wrong emoji: Make sure you're using the exact ๐งฟ emoji (not a similar one)
The automation is built with:
- Val Town's discordWebhook utility for Discord integration
- Hono for the setup dashboard HTTP server
- Discord API v10 for message fetching
- Linear GraphQL API for ticket creation
- TypeScript for type safety
- TailwindCSS for the frontend
- Uses Val Town's built-in Discord webhook system (much simpler than manual webhooks!)
- 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
- โ No manual webhook configuration - Val Town handles all Discord integration
- โ Automatic Discord event handling - Built-in processing for reactions
- โ Built-in error handling and retries - Reliable message delivery
- โ Simplified deployment - Just set environment variables and go
- โ Seamless Val Town integration - Works perfectly with the platform
- โ No webhook URLs to manage - Everything is handled automatically