Automate first responses to Gorgias tickets using a Claude Code skill
Install this skill
Download the skill archive and extract it into your .claude/skills/ directory.
first-response.skill.zipPrerequisites
This skill works with any agent that supports the Claude Code skills standard, including Claude Code, Claude Cowork, OpenAI Codex, and Google Antigravity.
- One of the agents listed above
- Gorgias account with API access
- Anthropic API key for Claude-drafted responses
- A company knowledge base or FAQ text file for accurate answers
Why a Claude Code skill?
The other approaches in this guide are deterministic: they run the same logic every time, the same way. An Claude Code skill is different. You tell Claude what you want in plain language, and the skill gives it enough context to do it reliably.
That means you can say:
- "Draft first responses for all unanswered tickets"
- "Only draft replies for shipping and returns questions"
- "Send responses directly instead of creating internal notes"
- "What tickets are waiting for a first reply right now?"
The skill contains workflow guidelines, API reference materials, and a knowledge base that the agent reads on demand. When you invoke the skill, Claude reads these files, writes a script on the fly, runs it, and reports results. Because it uses Claude to draft replies, it produces contextual responses that match tone and reference specific details — far beyond what static Macros can do.
How it works
The skill directory has three parts:
SKILL.md— workflow guidelines telling the agent what steps to follow, which env vars to use, and what pitfalls to avoidreferences/— Gorgias API patterns (ticket endpoints, message creation) and your knowledge base so the agent has accurate policy informationtemplates/— a system prompt template that shapes how Claude drafts replies
When invoked, the agent reads SKILL.md, consults the reference and template files as needed, writes a Python script that calls Claude's API for drafting and the Gorgias API for posting, executes it, and reports what it did.
What is a Claude Code skill?
An Claude Code skill is a reusable command you add to your project that Claude Code can run on demand. Skills live in a .claude/skills/ directory and are defined by a SKILL.md file that tells the agent what the skill does, when to run it, and what tools it's allowed to use.
In this skill, the agent doesn't run a pre-written script. Instead, SKILL.md provides workflow guidelines and points to reference files — API documentation, a knowledge base, a drafting prompt — that the agent reads to generate and execute code itself. The generated script calls Claude's API directly for drafting replies, so the outer agent handles orchestration while an inner Claude call handles the creative writing.
Once installed, you can invoke a skill as a slash command (e.g., /first-response), or the agent will use it automatically when you give it a task where the skill is relevant. Skills are portable — anyone who clones your repo gets the same commands.
Step 1: Create the skill directory
mkdir -p .claude/skills/first-response/{templates,references}This creates the layout:
.claude/skills/first-response/
├── SKILL.md # workflow guidelines + config
├── templates/
│ └── drafting-prompt.md # system prompt for Claude reply drafting
└── references/
├── gorgias-tickets-api.md # Gorgias API patterns
└── knowledge-base.md # your support FAQs and policiesStep 2: Write the SKILL.md
Create .claude/skills/first-response/SKILL.md:
---
name: first-response
description: Find Gorgias tickets with no agent reply and draft a contextual first response using Claude, posted as an internal note for agent review or sent directly.
disable-model-invocation: true
allowed-tools: Bash, Read
---
## Goal
Find open Gorgias tickets that have no agent reply yet, draft a contextual first response using Claude (Haiku), and post it to Gorgias as either an internal note (default) or a public reply.
## Configuration
Read these environment variables:
- `GORGIAS_DOMAIN` — your Gorgias subdomain (required)
- `GORGIAS_EMAIL` — Gorgias account email for API auth (required)
- `GORGIAS_API_KEY` — Gorgias API key (required)
- `ANTHROPIC_API_KEY` — Anthropic API key for Claude drafting (required)
- `AUTO_SEND` — set to "true" to send as public reply instead of internal note (optional, default: false)
## Workflow
1. Validate that all required env vars are set. If any are missing, print which ones and exit.
2. Fetch open tickets from Gorgias. See `references/gorgias-tickets-api.md` for the endpoint.
3. Filter to tickets where no message has `source.type == "helpdesk"` (no agent reply yet).
4. For each ticket, read the customer's message body and subject.
5. Read the knowledge base from `references/knowledge-base.md` and the drafting prompt from `templates/drafting-prompt.md`.
6. Call the Anthropic API (claude-haiku-4-5) with the drafting prompt, knowledge base, and ticket content to generate a reply.
7. Post the drafted response to Gorgias via `POST /tickets/{id}/messages`. Set `public: false` by default (internal note) or `public: true` if AUTO_SEND is enabled.
8. Print each ticket ID, subject, and a preview of the draft.
## Important notes
- Default to internal notes (`public: false`). Only send as public replies when the user explicitly asks or sets `AUTO_SEND=true`.
- Use claude-haiku-4-5 for drafting — it's fast and inexpensive (~$0.003 per reply).
- Keep draft replies under 150 words. Customers prefer concise answers.
- The knowledge base in `references/knowledge-base.md` must be kept up to date with current policies. Stale information produces inaccurate replies.
- Use the `requests` library for Gorgias API calls and `anthropic` for Claude. Install with pip if needed.Understanding the SKILL.md
| Section | Purpose |
|---|---|
| Goal | Tells the agent what outcome to produce |
| Configuration | Which env vars to read and what defaults to use |
| Workflow | Numbered steps with pointers to reference files |
| Important notes | Non-obvious context that prevents common mistakes |
The allowed-tools: Bash, Read setting lets the agent both read reference files and execute code. The agent writes its own script based on the workflow steps and reference materials.
Step 3: Add reference files
templates/drafting-prompt.md
Create .claude/skills/first-response/templates/drafting-prompt.md:
# First Response Drafting Prompt
Use this system prompt when calling Claude to draft a reply.
## System Prompt
```
You are a friendly, concise customer support agent for an e-commerce store.
Use the knowledge base below to write a helpful first response to this customer's message. Keep the response under 150 words. Be warm but efficient. Don't over-apologize.
Write only the reply body — no subject line, no "Dear", just the message content starting with "Hi [name],".
```
## User Prompt Template
```
Knowledge base:
{knowledge_base_content}
Customer name: {customer_name}
Subject: {subject}
Message: {body_first_800_chars}
```
## Notes
- Use `claude-haiku-4-5-20251001` as the model for cost efficiency (~$0.003 per reply).
- Set `max_tokens: 300` to keep replies concise.
- Replace `{customer_name}` with `ticket.requester.firstname` or "there" if unavailable.
- Only include the first 800 characters of the message body to stay within prompt limits.references/gorgias-tickets-api.md
Create .claude/skills/first-response/references/gorgias-tickets-api.md:
# Gorgias Tickets API Reference
## Authentication
All requests use HTTP Basic Auth:
- Username: `GORGIAS_EMAIL`
- Password: `GORGIAS_API_KEY`
- Base URL: `https://{GORGIAS_DOMAIN}.gorgias.com/api`
## List open tickets
**Request:**
```
GET /api/tickets?status=open&limit=20
```
**Response shape:**
```json
{
"data": [
{
"id": 12345,
"subject": "Where is my order?",
"status": "open",
"requester": {
"id": 678,
"firstname": "Sarah",
"email": "sarah@example.com"
},
"messages": [
{
"id": 99001,
"body_text": "Hi, I placed an order 3 days ago...",
"source": { "type": "email" },
"created_datetime": "2026-03-05T10:00:00+00:00"
}
]
}
]
}
```
- To find tickets needing a first reply: filter for tickets where NO message has `source.type == "helpdesk"`.
- The first message in the `messages` array is typically the customer's original message.
## Post a message on a ticket
**Request:**
```
POST /api/tickets/{ticket_id}/messages
Content-Type: application/json
```
**Body (internal note):**
```json
{
"body_text": "Draft reply text here...",
"body_html": "<p>Draft reply text here...</p>",
"channel": "email",
"from_agent": true,
"public": false,
"source": {
"type": "helpdesk",
"from": {
"name": "Support Team",
"address": "support@<GORGIAS_DOMAIN>.com"
}
}
}
```
- Set `public: false` for internal notes (agent review before sending).
- Set `public: true` for direct customer-facing replies.
- The `body_html` field accepts simple HTML — convert newlines to `<p>` tags.references/knowledge-base.md
Create .claude/skills/first-response/references/knowledge-base.md:
# Support Knowledge Base
Update this file with your current policies and FAQs. Claude uses this content to draft accurate replies.
## Order Tracking
- Tracking emails are sent within 24 hours of shipping
- Track at: https://yourstore.com/tracking
- Orders ship in 1-2 business days; delivery takes 3-5 business days
## Returns
- 30-day return window from delivery date
- Items must be unused and in original packaging
- Start a return at: https://yourstore.com/returns
- Refunds process within 5-7 business days after we receive the item
## Order Changes and Cancellations
- Orders can be changed or cancelled within 1 hour of placement
- After 1 hour, contact us immediately — we'll try but can't guarantee changes
## International Shipping
- We ship to 40+ countries
- International delivery: 7-14 business days
- Customs fees are the customer's responsibilityStep 4: Test the skill
Invoke the skill conversationally:
/first-responseClaude will read the SKILL.md, check the reference files, write a script, install dependencies, run it, and report the results. A typical run looks like:
Looking for tickets with no agent reply...
Found 5 ticket(s) needing a first response
#14801 "Where is my order?" → posted as internal note
Draft: Hi Sarah, Thanks for reaching out! Your order shipped yesterday...
#14805 "Return request for jacket" → posted as internal note
Draft: Hi James, Happy to help with your return! You can start the...
Done. Processed 5 ticket(s).Because the agent generates code on the fly, you can also make ad hoc requests:
- "Only draft replies for shipping questions" — the agent adds a topic filter
- "Send responses directly instead of internal notes" — the agent sets
public: true - "What tickets are waiting for a first reply?" — the agent runs read-only
Run with the default internal-note mode for the first week. Review drafts in Gorgias and verify quality before switching to auto-send. This builds confidence without risk.
Step 5: Schedule it (optional)
Option A: Cron + Claude CLI
# Run every 30 minutes during business hours
*/30 8-18 * * 1-5 cd /path/to/your/project && claude -p "Run /first-response" --allowedTools 'Bash(*)' 'Read(*)'Option B: GitHub Actions + Claude
name: First Response Drafts
on:
schedule:
- cron: '*/30 13-22 * * 1-5' # 8 AM-5 PM ET, weekdays
workflow_dispatch: {}
jobs:
draft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@v1
with:
prompt: "Run /first-response"
allowed_tools: "Bash(*),Read(*)"
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GORGIAS_DOMAIN: ${{ secrets.GORGIAS_DOMAIN }}
GORGIAS_EMAIL: ${{ secrets.GORGIAS_EMAIL }}
GORGIAS_API_KEY: ${{ secrets.GORGIAS_API_KEY }}Option C: Cowork Scheduled Tasks
Claude Desktop's Cowork supports built-in scheduled tasks. Open a Cowork session, type /schedule, and configure the cadence — hourly, daily, weekly, or weekdays only. Each scheduled run has full access to your connected tools, plugins, and MCP servers.
Scheduled tasks only run while your computer is awake and Claude Desktop is open. If a run is missed, Cowork executes it automatically when the app reopens. For always-on scheduling, use GitHub Actions (Option B) instead. Available on all paid plans (Pro, Max, Team, Enterprise).
The quality of Claude's drafted replies depends entirely on references/knowledge-base.md. If your policies change (new return window, updated shipping times), update this file immediately. Stale knowledge base content produces incorrect replies.
Troubleshooting
When to use this approach
- You want contextual replies that reference specific details from the customer's message, not generic macro text
- You want conversational control — filter by topic, adjust tone, switch between draft and auto-send modes
- You're already using Claude Code and want skills that integrate with your workflow
- You want to run tasks in the background via Claude Cowork while focusing on other work
- You prefer guided references over rigid scripts — the agent adapts while staying reliable
When to switch approaches
- You need instant auto-replies (under 30 seconds) → use Gorgias Rules with Macros
- You want a visual workflow builder → use n8n
- You need replies running 24/7 at zero LLM cost → use Gorgias native Macros
Common questions
Does this use Claude API credits?
Yes, twice per ticket. The outer agent reads skill files and generates code ($0.01-0.05), and the inner Claude call drafts each reply ($0.003 per reply using Haiku). For 300 tickets/month, expect ~$1 in drafting costs plus ~$2-5 in agent invocation costs.
Will Claude's replies match our brand voice?
The drafting prompt in templates/drafting-prompt.md shapes the tone. Customize it — add your brand guidelines, specify how formal or casual to be, list phrases to avoid. The knowledge base provides factual accuracy; the prompt template controls style.
Can I run this skill on a schedule without a server?
Yes. GitHub Actions (Option B in Step 5) runs Claude on a cron schedule using GitHub's infrastructure. The free tier includes 2,000 minutes/month.
Cost
- Claude API (agent) — $0.01-0.05 per invocation
- Claude API (drafting) — ~$0.003 per reply using Haiku
- Gorgias API — included in all paid plans
- GitHub Actions (if scheduled) — free tier includes 2,000 minutes/month
Looking to scale your AI operations?
We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.