FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
project logo

charmaine

Discord-to-Linear

Discord -> Linear ticket based on emoji reaction trigger
Public
Like
2
Discord-to-Linear
Home
Code
5
backend
5
frontend
1
README.md
discord-linear-automation.ts
setup-dashboard.ts
Branches
1
Pull requests
Remixes
3
History
Environment variables
5
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
5/24/2025
Viewing readonly version of main branch: v18
View latest version
README.md

Discord to Linear Ticket Automation

This automation creates Linear tickets from Discord messages when they receive a specific emoji reaction (๐Ÿงฟ :charmaine:).

๐Ÿš€ Quick Start

  1. Visit the setup page: Open your Val Town URL in a browser to see the configuration dashboard
  2. Set environment variables (see below)
  3. Configure Discord webhook (instructions on the setup page)
  4. Test the integration using the built-in test form

๐Ÿ“‹ Environment Variables

Set these in your Val Town environment:

VariableDescriptionRequired
DISCORD_BOT_TOKENYour Discord bot tokenโœ…
LINEAR_API_KEYYour Linear API keyโœ…
LINEAR_TEAM_IDThe Linear team ID where tickets should be createdโœ…
DISCORD_WEBHOOK_SECRETSecret for verifying Discord webhooksโŒ

๐Ÿ”ง Setup Instructions

1. Discord Bot Setup

  1. Go to Discord Developer Portal
  2. Create a new application and bot
  3. Copy the bot token to DISCORD_BOT_TOKEN
  4. Enable these bot permissions:
    • Read Message History
    • Add Reactions
    • Use Slash Commands
  5. Add the bot to your Discord server

2. Discord Webhook Setup

  1. In your Discord server settings, go to Integrations > Webhooks
  2. Create a new webhook pointing to: https://[your-val-name].web.val.run/discord-webhook
  3. Configure it to listen for "Message Reactions" events

3. Linear API Setup

  1. Go to Linear Settings > API
  2. Create a new Personal API key
  3. Copy it to LINEAR_API_KEY
  4. Find your team ID (use the /linear-teams endpoint) and set LINEAR_TEAM_ID

๐ŸŽฏ How It Works

  1. User reacts to a Discord message with the configured emoji (๐Ÿงฟ)
  2. Discord sends a webhook to our service
  3. Service fetches the full message content
  4. 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)

๐Ÿ“ Project Structure

โ”œโ”€โ”€ 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

๐Ÿ”— API Endpoints

  • GET / - Setup dashboard (web interface)
  • POST /discord-webhook - Discord webhook endpoint
  • POST /test-ticket - Manual ticket creation for testing
  • GET /config - Configuration status
  • GET /linear-teams - List available Linear teams
  • GET /health - Health check

โš™๏ธ 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)

๐Ÿงช Testing

  1. Use the web interface at your Val Town URL
  2. 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"}'

๐Ÿ” Troubleshooting

  1. Check configuration status on the web dashboard
  2. Verify environment variables are set correctly
  3. Test Discord bot permissions in your server
  4. Check Linear API key has proper permissions
  5. Verify webhook URL is correctly configured in Discord

๐Ÿ› ๏ธ Development

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

๐Ÿ“ Notes

  • 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
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
ยฉ 2025 Val Town, Inc.