Flag repeat customer contacts in Gorgias and alert Slack using a Claude Code skill

low complexityCost: Usage-based

Prerequisites

Compatible agents

This skill works with any agent that supports the Claude Code skills standard, including Claude Code, Claude Cowork, OpenAI Codex, and Google Antigravity.

Prerequisites
  • One of the agents listed above
  • Gorgias account with API access
  • Slack Incoming Webhook configured for your alerts channel
Environment Variables
# Your Gorgias subdomain (e.g. yourstore)
GORGIAS_DOMAIN=your_value_here
# Gorgias account email for API authentication
GORGIAS_EMAIL=your_value_here
# Gorgias API key from Settings > REST API
GORGIAS_API_KEY=your_value_here
# Slack Incoming Webhook URL for repeat contact alerts
SLACK_WEBHOOK_URL=your_value_here

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:

  • "Check for repeat contacts and alert Slack"
  • "Show me customers with 5+ tickets in the last 14 days"
  • "Who are the top repeat contacts this month? Just list them, don't tag anything"
  • "Flag repeat contacts but skip anyone tagged high-volume-expected"

The skill contains workflow guidelines and API reference materials 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. If you ask for something different next time — a higher threshold, a wider window, analysis instead of alerting — the agent adapts without you touching any code.

How it works

The skill directory has two parts:

  1. SKILL.md — workflow guidelines telling the agent what steps to follow, which env vars to use, and what pitfalls to avoid
  2. references/ — Gorgias API patterns (ticket listing, customer grouping) and a Slack alert template

When invoked, the agent reads SKILL.md, consults the reference files as needed, writes a Python script, executes it, and reports what it found. No AI classification is needed — this is a data aggregation task.

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, alert templates — that the agent reads to generate and execute code itself.

Once installed, you can invoke a skill as a slash command (e.g., /repeat-contact), or the agent will use it automatically when you give it a task where the skill is relevant.

Step 1: Create the skill directory

mkdir -p .claude/skills/repeat-contact/{templates,references}

This creates the layout:

.claude/skills/repeat-contact/
├── SKILL.md                          # workflow guidelines + config
├── templates/
│   └── slack-alert.md                # Slack message template
└── references/
    └── gorgias-tickets-api.md        # Gorgias API patterns

Step 2: Write the SKILL.md

Create .claude/skills/repeat-contact/SKILL.md:

---
name: repeat-contact
description: Scan Gorgias tickets for customers with 3+ tickets in the past 7 days, tag the latest ticket, and post a Slack alert.
disable-model-invocation: true
allowed-tools: Bash, Read
---
 
## Goal
 
Scan recent Gorgias tickets, group them by customer, and identify anyone who has opened 3 or more tickets in the past 7 days. Tag the latest ticket from each repeat contact and post a Slack alert with their ticket history.
 
## 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)
- `SLACK_WEBHOOK_URL` — Slack Incoming Webhook URL (required)
 
Default threshold: 3 tickets in 7 days. The user may request different values.
 
## Workflow
 
1. Validate that all required env vars are set. If any are missing, print which ones and exit.
2. Fetch recent tickets from Gorgias sorted by creation date. See `references/gorgias-tickets-api.md` for the endpoint.
3. Filter to tickets created within the detection window (default: 7 days).
4. Group tickets by customer ID, collecting each customer's name, email, and ticket list.
5. Identify customers whose ticket count meets or exceeds the threshold (default: 3).
6. For each flagged customer, tag their most recent ticket with `repeat-contact` via `PUT /tickets/{id}`.
7. Post a Slack alert for each flagged customer using the template in `templates/slack-alert.md`.
8. Print a summary of flagged contacts.
 
## Important notes
 
- The Gorgias `PUT /tickets/{id}` endpoint REPLACES the entire tags array. Fetch current tags first, merge `repeat-contact`, then PUT the combined list.
- Tag only the most recent ticket, not all tickets. Tagging every ticket from a repeat contact creates noise.
- The script fetches a max of 100 tickets per run. For high-volume stores, this may not cover the full 7-day window. Implement pagination if needed.
- Exclude customers tagged `high-volume-expected` (agencies, resellers) to reduce false positives.
- Rate limit: Gorgias allows roughly 2 requests per second.
- Use the `requests` library for HTTP calls. Install with pip if needed.

Step 3: Add reference files

templates/slack-alert.md

Create .claude/skills/repeat-contact/templates/slack-alert.md:

# Repeat Contact Slack Alert Template
 
Use this format for each repeat contact alert sent via webhook.
 
## Message Format
 
```json
{
  "text": ":rotating_light: *Repeat Contact Flagged*\n\n*<customer_name>* (<customer_email>) has opened *<ticket_count> tickets* in the last <window_days> days.\n\n*Recent tickets:*\n<ticket_list>\n\n<latest_ticket_url>"
}
```
 
## Notes
 
- `<ticket_list>` should be formatted as:
  ```
  - #12345: Subject here (status)
  - #12340: Another subject (status)
  ```
- `<latest_ticket_url>` format: `https://<GORGIAS_DOMAIN>.gorgias.com/app/ticket/<ticket_id>`
- Wrap the URL in Slack link syntax: `<url|View latest ticket in Gorgias>`
- Send via `POST` to the `SLACK_WEBHOOK_URL`.

references/gorgias-tickets-api.md

Create .claude/skills/repeat-contact/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 recent tickets
 
**Request:**
 
```
GET /api/tickets?limit=100&order_by=created_datetime:desc
```
 
**Response shape:**
 
```json
{
  "data": [
    {
      "id": 14501,
      "subject": "Can't log in to my account",
      "status": "open",
      "created_datetime": "2026-03-05T10:00:00+00:00",
      "customer": {
        "id": 678,
        "firstname": "Sarah",
        "email": "sarah@example.com"
      },
      "tags": [
        { "name": "technical" }
      ]
    }
  ]
}
```
 
- Use `created_datetime` to filter tickets within the detection window.
- Group by `customer.id` to count tickets per customer.
- The `customer` field may use `id`, `firstname`, and `email`.
 
## Update a ticket (add tag)
 
**Request:**
 
```
PUT /api/tickets/{ticket_id}
Content-Type: application/json
```
 
**IMPORTANT:** The `tags` field REPLACES the entire array. Fetch current tags, add `repeat-contact`, then PUT the merged list.
 
```json
{
  "tags": [
    { "name": "technical" },
    { "name": "repeat-contact" }
  ]
}
```

Step 4: Test the skill

Invoke the skill conversationally:

/repeat-contact

A typical run looks like:

Scanning for customers with 3+ tickets in the last 7 days...
 
Fetched 87 tickets from the last 7 days
Found 2 repeat contact(s):
 
  Sarah M. (sarah@example.com)
    4 tickets in 7 days
      #14501: Can't log in to my account (open)
      #14487: Still can't access order history (open)
      #14463: Password reset not working (closed)
      #14451: Account access issue (closed)
    -> Tagged #14501 + Slack alert sent
 
  James K. (james@example.com)
    3 tickets in 7 days
      #14498: Wrong item received again (open)
      #14472: Missing item in my order (closed)
      #14460: Shipping damage (closed)
    -> Tagged #14498 + Slack alert sent
 
Done. Flagged 2 repeat contact(s).

Because the agent generates code on the fly, you can also make ad hoc requests:

  • "Show me customers with 5+ tickets in 14 days" — the agent adjusts thresholds
  • "Just list repeat contacts, don't tag or alert" — the agent runs read-only
  • "Who are the top repeat contacts this month?" — the agent expands the window
Tune the threshold after a week

After a week of running, review flagged contacts. Too many false positives? Raise the threshold to 4-5. Missing genuine repeat contacts? Lower to 2 or expand the window to 14 days.

Step 5: Schedule it (optional)

Option A: Cron + Claude CLI

# Run every 2 hours during business hours
0 8-18/2 * * 1-5 cd /path/to/your/project && claude -p "Run /repeat-contact" --allowedTools 'Bash(*)' 'Read(*)'

Option B: GitHub Actions + Claude

name: Repeat Contact Flagging
on:
  schedule:
    - cron: '0 */2 * * *'  # Every 2 hours
  workflow_dispatch: {}
jobs:
  flag:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          prompt: "Run /repeat-contact"
          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 }}
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

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

High-volume stores may need pagination

The default script fetches 100 tickets per run. If your store generates more than 100 tickets in 7 days, some customers may be missed. Ask the agent to implement pagination, or shorten the detection window to stay within the 100-ticket limit.

Troubleshooting

When to use this approach

  • You want conversational flexibility — custom thresholds, time windows, and read-only analysis alongside scheduled flagging
  • You want on-demand checks during team reviews or retrospectives
  • 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 real-time flagging on every new ticket → use n8n with a webhook trigger
  • You need flagging running 24/7 with zero LLM cost → use n8n with a scheduled workflow

Common questions

Why not just use Gorgias Rules?

Gorgias Rules can match keywords and tags on individual tickets, but they cannot query a customer's ticket history or count how many times someone has contacted you recently. Repeat contact detection requires cross-ticket aggregation, which Rules don't support.

Does this use Claude API credits?

Yes, but minimally. The agent reads skill files and generates code (~$0.01-0.05 per invocation). No inner Claude calls are needed — this is pure data aggregation, not classification.

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 — $0.01-0.05 per invocation (the agent reads files and generates code)
  • Gorgias API — included in all paid plans, no per-call cost
  • Slack Incoming Webhook — free
  • 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.