Route refund requests from Gorgias 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)

Overview

This workflow listens for new Gorgias tickets via webhook, checks whether the ticket contains refund or return language, and if so assigns it to your refund team and applies a tag — all through the Gorgias API. Because n8n runs outside Gorgias, you can extend this workflow to also log refund requests to a spreadsheet, notify a Slack channel, or check the order value before routing.

Step 1: Create a Webhook trigger node

Add a Webhook node as the trigger:

  • HTTP Method: POST
  • Path: gorgias-refund-routing
  • Authentication: None

Copy the webhook URL — you'll register it in Gorgias next.

Step 2: Register the webhook in Gorgias

In Gorgias, go to Settings → Integrations → HTTP.

Click Add HTTP integration:

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

Save and enable the integration.

Webhook payload contents

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

Step 3: Extract 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,
    subject: ticket.subject,
    existingTags: ticket.tags || [],
    text: combined,
  }
}];

Step 4: Detect refund intent with an IF node

Add an IF node to check for refund-related keywords:

  • Condition type: String
  • Value: {{ $json.text }}
  • Operation: Contains

Check for these keywords (use OR logic — any match triggers the true branch):

refund, money back, return, send back, exchange, cancel order, wrong item, damaged, defective, reimburse, credit back

Use the 'contains' operator, not 'equals'

The IF node should check if the combined text contains each keyword, not whether it equals it. A message like "I want to return the jacket I bought last week" contains the word "return" but doesn't equal it.

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 to fetch the current ticket:

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

Then add a Code node to merge the new tag:

const currentTags = $input.first().json.tags || [];
const newTag = 'refund-request';
 
const merged = [...currentTags.map(t => t.name), newTag];
const unique = [...new Set(merged)];
 
return [{
  json: {
    ticketId: $('Code').first().json.ticketId,
    tags: unique.map(name => ({ name })),
  }
}];

Step 6: Assign team and apply tag via API

Add an HTTP Request node to update the ticket:

  • Method: PUT
  • URL: https://your-store.gorgias.com/api/tickets/{{ $json.ticketId }}
  • Authentication: Basic Auth (same credentials)
  • Body (JSON):
{
  "tags": {{ $json.tags }},
  "assignee_team": {
    "name": "Refund Team"
  }
}
Look up your team ID if name assignment fails

Some Gorgias API versions require a team ID rather than a name. Fetch your teams from GET /api/teams and use the numeric id field in the assignee_team object instead.

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 notify you via email or Slack if routing fails
  3. Test by creating a Gorgias ticket with body text like "I'd like a refund for my order"
  4. Verify the tag appears and the ticket is assigned to the Refund Team
  5. Toggle the workflow to Active

To extend this workflow, add a Slack notification node after the tag step to alert your refund team in real time, or add a Google Sheets node to log every refund request for reporting.

Cost

  • n8n Cloud: Each ticket triggers ~4 node executions. 300 refund tickets/month = ~1,200 executions — well within the Starter plan.
  • Self-hosted: Free.

Need help implementing this?

We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.