FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
project logo
charmaineDiscord-to-Linear
Discord -> Linear ticket based on emoji reaction trigger
Public
Like
2
Discord-to-Linear
Home
Code
9
backend
4
frontend
1
README.md
USAGE.md
H
debug-message-content.ts
H
discord-linear-automation.ts
C
discord-reaction-cron.ts
H
setup-dashboard.ts
H
test-title-format.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: v69
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. Set environment variables: Add DISCORD_BOT_TOKEN, LINEAR_API_KEY, and LINEAR_TEAM_ID to your Val Town environment
  2. Create and add Discord bot: Follow the setup instructions below
  3. Test the integration: Use the setup dashboard to verify everything works
  4. Start using: React to Discord messages with ๐Ÿงฟ to create tickets!

๐Ÿ“‹ 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โœ…

๐Ÿ”ง Setup Instructions

1. Set Environment Variables

In your Val Town environment, add these 3 required variables:

  • DISCORD_BOT_TOKEN - Your Discord bot token
  • LINEAR_API_KEY - Your Linear API key
  • LINEAR_TEAM_ID - Your Linear team ID

2. Create Discord Bot

  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

3. Add Bot to Your Discord Server

  1. In Discord Developer Portal, go to OAuth2 โ†’ URL Generator
  2. Select "bot" scope
  3. Select the permissions mentioned above
  4. Use the generated URL to invite the bot to your server

4. Get Linear API Key

  1. Go to Linear Settings โ†’ API
  2. Create a new Personal API key
  3. Copy it to LINEAR_API_KEY

5. Find Your Linear Team ID

  1. Open the setup dashboard (/setup-dashboard.ts)
  2. Click "Get Linear Teams" button
  3. Copy your team ID to LINEAR_TEAM_ID

6. Test the Setup

  1. Use the setup dashboard to verify all environment variables are set
  2. Test ticket creation with the built-in test form
  3. Try reacting to a Discord message with ๐Ÿงฟ

โœ… Discord Webhook Setup Required!

This automation uses a Discord webhook to receive reaction events. You need to configure this in the Discord Developer Portal:

Webhook Setup Steps:

  1. Go to Discord Developer Portal
  2. Select your bot application
  3. Go to "Webhooks" in the left sidebar
  4. Click "New Webhook"
  5. Set webhook URL to: https://[your-username]-discord-linear-automation.web.val.run
  6. Subscribe to event: MESSAGE_REACTION_ADD
  7. Save the webhook

Required Bot Intents:

In your Discord application settings:

  1. Go to "Bot" โ†’ "Privileged Gateway Intents"
  2. Enable "Message Content Intent"

๐ŸŽฏ How It Works

  1. User reacts to a Discord message with the configured emoji (๐Ÿงฟ)
  2. Val Town's Discord webhook automatically triggers the automation
  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

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

๐Ÿ”— Key Files

  • discord-linear-automation.ts - The main automation that processes Discord reactions
  • setup-dashboard.ts - Web interface for configuration and testing
  • Use the setup dashboard to test ticket creation and verify your configuration

โš™๏ธ 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 setup dashboard (/setup-dashboard.ts) to:
    • Check configuration status
    • Test ticket creation with any Discord message
    • Get your Linear team IDs
  2. 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"}'
  3. Live testing: React to any Discord message with ๐Ÿงฟ

๐Ÿ” Troubleshooting

  1. Check configuration status on the setup dashboard
  2. Verify environment variables are set correctly in Val Town
  3. Test Discord bot permissions - ensure bot can read message history
  4. Check Linear API key has proper permissions to create issues
  5. Use the test form in the setup dashboard to isolate issues
  6. Check Val Town logs for detailed error messages

Common Issues

  • 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)

๐Ÿ› ๏ธ Development

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

๐Ÿ“ Notes

  • 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

๐ŸŽ‰ Benefits of Using discordWebhook

  • โœ… 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
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
ยฉ 2025 Val Town, Inc.