• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
templates

templates

pylon-support-bot

Drafts replies to Pylon support tickets with AI
Public
Like
pylon-support-bot
Home
Code
6
scripts
1
README.md
H
main.ts
pipeline.ts
prompt.md
pylon.ts
Connections
Environment variables
Branches
1
Pull requests
Remixes
History
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
/
Code
/
Search
README.md

Pylon Support Bot

AI-powered support draft bot for Pylon. Receives Pylon webhooks, generates draft replies using Claude (via Kilo Gateway), and posts them as internal notes on the Pylon issue for human review.

Architecture

Rendering mermaid diagram...

Setup

1. Val Town Secrets

Add these environment variables in the Val Town project settings:

KeyDescriptionWhere to get it
KILO_GATEWAY_KEYKilo Gateway API keyapp.kilo.ai/profile
PYLON_API_KEYPylon API token (Bearer auth)Pylon → Settings → API → Create token
PYLON_WEBHOOK_SECRETWebhook destination secretPylon → Settings → API → Webhook destination secret

2. Pylon Webhook Destination

  1. Go to Pylon → Settings → API → Webhooks.
  2. Create a new webhook destination with URL: https://YOUR-VAL-ENDPOINT.web.val.run/
  3. Select the event types you want to trigger on (e.g., issue.message.created).
  4. Save the secret — add it as PYLON_WEBHOOK_SECRET in Val Town.

3. Pylon Trigger Configuration

Create a Pylon Trigger that fires on new customer messages and sends a webhook with the issue ID:

{ "id": "{{issue.id}}" }

The bot will fetch the full issue context (metadata and conversation history) from the Pylon API.

Files

FilePurpose
main.tsHTTP handler — webhook receiver, signature verification, background processing
pylon.tsPylon API client — webhook verification, context fetching, note posting
pipeline.tsCore pipeline — fetch context → generate LLM reply → post note
prompt.mdSystem prompt for the AI model with response guidelines
scripts/test-pipeline.tsEnd-to-end test script
README.mdThis file

How It Works

  1. Webhook received at POST / — the handler verifies the Pylon HMAC-SHA256 signature.
  2. Early return — responds 200 OK immediately, then fires a background request to POST /process.
  3. Fetch context — retrieves full issue metadata and conversation history from Pylon API.
  4. AI inference — loads prompt.md as the system prompt, sends the issue context to Claude Opus 4.6 via Kilo Gateway.
  5. Internal note — posts the AI-generated draft as an internal-only note on the Pylon issue.
  6. Error handling — on failure, sends an error notification email to steve@val.town.

Customization

Change the AI Model

Edit pipeline.ts to use a different model:

// Current: Claude Opus 4.6 via Kilo Gateway const kilo = createOpenAI({ baseURL: "https://api.kilo.ai/api/gateway", apiKey: Deno.env.get("KILO_GATEWAY_KEY"), }); const { text: draftReply } = await generateText({ model: kilo("anthropic/claude-opus-4-6"), system: systemPrompt, prompt: userPrompt, }); // Example: Use a different model through Kilo Gateway const { text: draftReply } = await generateText({ model: kilo("openai/gpt-4-turbo"), system: systemPrompt, prompt: userPrompt, });

Customize the System Prompt

Edit prompt.md to add:

  • Product-specific knowledge
  • FAQ pairs from your support history
  • Links to your documentation
  • Custom tone and style guidelines
  • Troubleshooting trees for common issues

Testing

Run the test script to verify the pipeline end-to-end:

// Edit scripts/test-pipeline.ts with a real issue ID const TEST_ISSUE_ID = "your-pylon-issue-id"; // Run the script from Val Town

Webhook Signature Verification

The bot verifies Pylon webhook signatures using HMAC-SHA256:

  1. Pylon sends X-Pylon-Signature header with hex-encoded digest
  2. Bot computes HMAC-SHA256 of raw request body using PYLON_WEBHOOK_SECRET
  3. Constant-time comparison prevents timing attacks
  4. Invalid signatures return 401 Unauthorized

See Pylon webhook signature docs for more details.

API Usage

Pylon API Endpoints Used

  • GET /issues/{id} — Fetch issue metadata
  • GET /issues/{id}/messages — Fetch conversation messages (with pagination)
  • POST /issues/{id}/threads — Create a new thread
  • POST /issues/{id}/note — Post an internal note to a thread

See Pylon API Reference for more details.

Deployment

This bot is deployed on Val Town, a serverless platform for TypeScript/JavaScript functions.

To deploy your own:

  1. Fork this val or create a new val in your Val Town account
  2. Add the required environment variables (see Setup section)
  3. Configure the Pylon webhook destination to point to your val's endpoint
  4. Test with a real issue using scripts/test-pipeline.ts
Code
scriptsREADME.md
H
main.ts
pipeline.tsprompt.mdpylon.ts
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.