Flag repeat customer contacts in Gorgias and alert Slack using n8n

medium complexityCost: $0-24/moRecommended

Prerequisites

Prerequisites
  • n8n instance (cloud or self-hosted)
  • Gorgias account with REST API access
  • Gorgias API credentials: account email and API key
  • Slack Incoming Webhook URL or Slack API credentials
  • A "repeat-contact" tag created in Gorgias (optional but recommended)

Why n8n?

Gorgias Rules can match keywords and tags on individual tickets, but they cannot query a customer's ticket history or count contacts over time. Repeat contact detection requires cross-ticket aggregation — looking at how many tickets a customer has opened recently — which is only possible via the Gorgias API. n8n is the best tool for this because it can make the API call, count tickets, and alert Slack in a single workflow.

Self-hosted n8n is completely free with unlimited executions. n8n Cloud starts at $24/mo. Since this workflow fires on every new ticket but only alerts on the small percentage that are repeat contacts, execution costs stay very low.

How it works

  • Gorgias HTTP integration sends a webhook to n8n when a new ticket is created
  • Code node extracts the customer ID and ticket details from the webhook payload
  • HTTP Request node fetches the customer's recent tickets from the Gorgias API
  • Code node counts tickets in the past 7 days and sets an isRepeatContact flag
  • IF node branches on the threshold (default: 3 tickets in 7 days)
  • HTTP Request node tags the ticket repeat-contact in Gorgias
  • Slack node posts an alert with the customer's recent ticket history

Overview

This workflow fires every time a new Gorgias ticket is created. It looks up the customer's recent ticket history via the Gorgias API, counts how many tickets they've opened in the past 7 days, and — if the count hits your threshold — tags the ticket and posts a Slack alert with context about the customer's recent activity. The entire check happens in under two seconds, so your team gets flagged before an agent even opens the ticket.

Step 1: Set up the Webhook trigger

Add a Webhook node:

  • HTTP Method: POST
  • Path: gorgias-repeat-contact

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

Step 2: Register the webhook in Gorgias

Go to Settings → Integrations → HTTPAdd HTTP integration:

  • Name: n8n Repeat Contact Check
  • URL: Your n8n webhook URL
  • Events: Ticket created
  • Content-Type: application/json
Use a dedicated HTTP integration

Keep this separate from any other n8n integrations you have in Gorgias. This makes it easy to disable or debug the repeat contact check without affecting other workflows.

Step 3: Extract customer info from the webhook payload

Add a Code node to pull out the customer ID and ticket details:

const ticket = $input.first().json;
 
const customerId = ticket.customer?.id;
const customerEmail = ticket.customer?.email || 'unknown';
const customerName = ticket.customer?.firstname || customerEmail;
const ticketId = ticket.id;
const subject = ticket.subject || '(no subject)';
 
if (!customerId) {
  return []; // no customer attached — skip
}
 
return [{
  json: {
    customerId,
    customerEmail,
    customerName,
    ticketId,
    subject,
  }
}];

Step 4: Query the customer's recent tickets

Add an HTTP Request node to fetch the customer's tickets from the past 7 days:

  • Method: GET
  • URL: https://your-store.gorgias.com/api/tickets
  • Authentication: Basic Auth (Gorgias email + API key)
  • Query Parameters:
    • customer_id: {{ $json.customerId }}
    • limit: 50

This returns the customer's most recent tickets. You'll filter by date in the next step.

Step 5: Count tickets in the past 7 days

Add a Code node to count tickets within the 7-day window:

const tickets = $input.first().json.data || [];
const prevData = $('Code').first().json;
 
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
 
const recentTickets = tickets.filter(t => {
  const created = new Date(t.created_datetime);
  return created >= sevenDaysAgo;
});
 
return [{
  json: {
    ...prevData,
    recentTicketCount: recentTickets.length,
    recentTickets: recentTickets.map(t => ({
      id: t.id,
      subject: t.subject,
      created: t.created_datetime,
      status: t.status,
    })),
    isRepeatContact: recentTickets.length >= 3,
  }
}];

Step 6: Branch on the repeat contact threshold

Add an IF node:

  • Condition: {{ $json.isRepeatContact }} equals true

The true branch continues to tagging and Slack. The false branch ends — no action needed for customers below the threshold.

Adjust the threshold for your business

The default threshold of 3 tickets in 7 days works well for most e-commerce brands. If your product naturally generates more support volume (e.g., a subscription box with weekly shipments), raise this to 4 or 5 to avoid false positives.

Step 7: Tag the ticket in Gorgias

On the true branch, add an HTTP Request node:

  • Method: PUT
  • URL: https://your-store.gorgias.com/api/tickets/{{ $json.ticketId }}
  • Authentication: Basic Auth
  • Body (JSON):
{
  "tags": [{ "name": "repeat-contact" }]
}

This tag lets you create a dedicated Gorgias View that surfaces all repeat-contact tickets in one place.

Step 8: Post a Slack alert

Add a Slack node (or HTTP Request to a Webhook URL):

  • Channel: #support-escalations
  • Message:
:rotating_light: Repeat Contact Flagged
 
*{{ $json.customerName }}* ({{ $json.customerEmail }}) has opened *{{ $json.recentTicketCount }} tickets* in the last 7 days.
 
*Latest ticket:* #{{ $json.ticketId }} — {{ $json.subject }}
 
*Recent tickets:*
{{ $json.recentTickets.map(t => `• #${t.id}: ${t.subject} (${t.status})`).join('\n') }}
 
→ <https://your-store.gorgias.com/app/ticket/{{ $json.ticketId }}|View in Gorgias>
Include a summary of recent ticket subjects

Listing the subjects of all recent tickets in the Slack message gives the responding agent instant context. They can see at a glance whether the customer keeps asking about the same issue or has multiple unrelated problems.

Step 9: Activate and test

  1. Create a test customer in Gorgias (or use a test email)
  2. Submit 3 test tickets from that customer within a few minutes
  3. Verify the third ticket triggers the webhook, gets tagged, and posts a Slack alert
  4. Toggle the workflow to Active
  5. Add Retry On Fail on all HTTP Request nodes

Troubleshooting

Common questions

Does the ticket count include the current ticket or only previous ones?

The Gorgias API returns all tickets for the customer, including the one that just triggered the webhook. Your threshold of 3 means 2 previous tickets + the new one. If you want 3 previous tickets before flagging, set the threshold to 4.

How do I exclude known high-volume accounts like agencies?

Tag those customer profiles with high-volume-expected in Gorgias. In the Code node after extracting customer data, check for that tag and return an empty array to stop processing. This prevents agencies and resellers from triggering false positives.

Will this hit Gorgias rate limits on high-volume accounts?

Each new ticket triggers 1-2 API calls (customer ticket lookup + optional tag update). Gorgias allows roughly 2 requests/second. For accounts processing 500+ tickets/day, add a 1-second Wait node between API calls, or switch to a Schedule Trigger that runs every 15 minutes and batches the checks.

Cost

  • n8n Cloud: ~6 node executions per ticket check. If you process 500 new tickets/month and 10% are repeat contacts, that's roughly 3,000 executions/month — well within the free tier.
  • 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.