Auto-triage Gorgias tickets using n8n

low complexityCost: $0-24/mo

Prerequisites

Prerequisites
  • n8n instance (cloud or self-hosted)
  • Gorgias account with REST API access (Settings → API → REST API)
  • Gorgias API credentials: your account email and API key
  • Your Gorgias domain (e.g., your-store.gorgias.com)

Why n8n?

n8n extends ticket triage beyond what Gorgias Rules can do alone. You can build multi-step classification logic, integrate with external systems (log to Google Sheets, notify Slack, check CRM data), and handle edge cases that single-keyword matching misses. The Switch node routes to the first matching case, giving you ordered priority that Gorgias Rules can't replicate.

Self-hosted n8n is completely free with unlimited executions. n8n Cloud starts at $24/mo. For most support teams processing 500 tickets/month, this workflow uses about 2,500 executions — within the Starter plan.

How it works

  • Gorgias HTTP integration sends a webhook to n8n when a new ticket is created
  • Code node extracts and lowercases the ticket subject and body for matching
  • Switch node routes to the first matching keyword case (billing, shipping, returns, technical, account) with a default fallback for needs-triage
  • HTTP Request node fetches existing tags from the ticket (Gorgias replaces tags on update)
  • Code node merges the new category tag with existing tags
  • HTTP Request node updates the ticket with the merged tag array

Overview

This workflow receives new Gorgias tickets via webhook, extracts and normalizes the ticket text, runs keyword matching to determine the topic, then calls the Gorgias API to apply the correct tag. Because n8n sits outside Gorgias, you can extend this workflow to also log to a spreadsheet, notify Slack, or call other APIs as part of the same triage step.

Step 1: Create a Webhook trigger node

Add a Webhook node as the trigger:

  • HTTP Method: POST
  • Path: gorgias-triage
  • Authentication: None (Gorgias doesn't sign webhooks by default)

Copy the webhook URL shown in the node — you'll paste it into Gorgias in the next step.

Step 2: Register the webhook in Gorgias

In Gorgias, go to Settings → Integrations → HTTP.

Click Add HTTP integration:

  • Name: n8n Triage
  • URL: Your n8n webhook URL
  • Events: Ticket created
  • Content-Type: application/json

Save and enable.

What Gorgias sends

The webhook payload contains the full ticket object including id, subject, messages (array — the customer's first message is messages[0]), status, tags, and the customer object with name and email.

Step 3: Extract and normalize the ticket text

Add a Code node to pull out the searchable text:

const ticket = $input.first().json;
const subject = (ticket.subject || '').toLowerCase();
const body = (ticket.messages?.[0]?.body_text || '').toLowerCase();
const combined = `${subject} ${body}`;
 
return [{
  json: {
    ticketId: ticket.id,
    existingTags: ticket.tags || [],
    text: combined,
  }
}];

Step 4: Classify the ticket with a Switch node

Add a Switch node to route based on keyword matches:

  • Mode: Expression
  • Value to match: {{ $json.text }}

Cases:

CaseConditionOutput label
1Contains invoice OR payment OR refund OR overchargedbilling
2Contains shipping OR tracking OR delivery OR package OR lostshipping
3Contains return OR exchange OR cancel OR rmareturns
4Contains error OR bug OR broken OR not working OR crashtechnical
5Contains login OR password OR account OR lockedaccount
Default(no match)needs-triage
Switch routes to the first matching case only

n8n's Switch node exits on the first match. Order your cases from most specific to least specific so a ticket about "can't log in to track my order" hits the right branch (account/login) rather than a broader one.

Step 5: Fetch existing tags before updating

The Gorgias API replaces the entire tags array on update — it doesn't append. Add an HTTP Request node before the tag write to fetch the current ticket state:

  • Method: GET
  • URL: https://your-store.gorgias.com/api/tickets/{{ $('Code').item.json.ticketId }}
  • Authentication: Basic Auth
    • Username: your Gorgias email
    • Password: your Gorgias API key

Then add another Code node to merge the new tag with the existing ones:

const currentTags = $input.first().json.tags || [];
const newTag = $('Switch').item.json.tag; // pass tag from Switch output
 
// Avoid duplicate tags
const merged = [...currentTags, { name: newTag }].filter(
  (tag, i, arr) => arr.findIndex(t => t.name === tag.name) === i
);
 
return [{ json: { mergedTags: merged } }];

Step 6: Apply the tag via Gorgias API

Add an HTTP Request node to update the ticket:

  • Method: PUT
  • URL: https://your-store.gorgias.com/api/tickets/{{ $('Code').item.json.ticketId }}
  • Authentication: Basic Auth (same credentials)
  • Body (JSON):
{
  "tags": {{ $json.mergedTags }}
}
API key location

In Gorgias: Settings → API → REST API. Create a new key and copy it — it's only shown once. Store it in n8n as a credential, not inline in node config.

Step 7: Add error handling and activate

  1. Enable Retry On Fail on both HTTP Request nodes (2 retries, 5 second wait)
  2. Add an Error Workflow to alert you via email or Slack if the workflow fails
  3. Run a test by creating a ticket in Gorgias that matches one of your keyword cases
  4. Toggle the workflow to Active

Troubleshooting

Common questions

Why does the Switch node route to only one case, not multiple?

n8n's Switch node exits on the first matching case. If a ticket about "I want to return my order and get a refund" matches both "returns" and "billing" cases, it gets whichever comes first. Order your cases from most specific to least specific. If you need multiple tags, replace the Switch with a Code node that checks all categories and returns an array of matching tags.

Can I use the n8n AI Agent node for smarter classification?

Yes. Replace the Switch node with an AI Agent or HTTP Request node that calls Claude or GPT to classify the ticket semantically. This catches edge cases like "this isn't what I ordered" (which is a returns issue even though it doesn't contain the word "return"). The trade-off is latency (1-2 seconds per API call) and cost ($0.001-0.01 per ticket).

How do I handle tickets created via chat vs. email?

The webhook payload includes the ticket channel. Add an IF node early in the workflow to route chat tickets (which tend to be shorter and more informal) through a different classification path or to a dedicated chat queue without triage.

Cost

  • n8n Cloud: Each ticket creates ~5 node executions. 500 tickets/month = ~2,500 executions. Within the Starter plan limit.
  • Self-hosted: Free.

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.