Building a Simple Agent-to-Agent (A2A) Workflow with n8n and Gemini

If you're exploring agentic automation but don't want to start with something overwhelming, this is the project for you. In this post, I'll walk through how I built a simple Agent-to-Agent (A2A) pipeline using n8n and Google Gemini to automatically classify and respond to customer support tickets.

The entire workflow is just three connected agents in a straight line — no parallel branches, no merge logic, no complicated routing. It's the perfect "hello world" for A2A automation, and you can have it running in under 30 minutes.



The use case

A customer submits a support ticket. Instead of a human reading it, tagging it, and drafting a reply, three AI agents handle the whole thing:

  1. A Classifier Agent reads the ticket and tags it as billing, technical, or general.
  2. A Response Agent drafts a reply based on that category and the original message.
  3. An Email Agent sends the reply straight back to the customer.

Why this is a good starting project?

Compared to more complex A2A setups (like a meeting-transcription pipeline with parallel summary and action-item agents feeding into a merge node), this workflow is linear and easy to debug. Each agent's output feeds directly into the next one's input, so when something breaks, you know exactly where to look.

Step 1: Create the workflow

Open n8n community edition, click "New Workflow," and give it a name like "Customer Support Ticket Router"

Step 2: Add a Webhook trigger

This is the entry point for incoming tickets.

  • Add a Webhook node and set the method to POST
  • Copy the generated webhook URL — you'll use this to send test tickets
  • Expected payload: 
{
  "email": "customer@example.com",
  "subject": "Can't log in",
  "message": "I've been locked out of my account for 2 days."
}

Step 3: Add the Classifier Agent

This is your first AI node. It reads the ticket and outputs a single category tag.

  • Add an AI Agent node and connect it to the Webhook
  • Add a Google Gemini Chat Model node into the Chat Model slot (model: gemini-1.5-flash) is fast and cheap enough for this use case)
  • Set the prompt:
You are a support ticket classifier.

Ticket subject: {{ $json.body.subject }}
Ticket message: {{ $json.body.message }}

Respond with ONLY one of these three words and nothing else:
billing
technical
general

Step 4: Add the Response Agent

This agent drafts the actual reply, using the category from the previous step plus the original ticket content.

  • Add a second AI Agent node, connected to the Classifier Agent
  • Use a Google Gemini Chat Model node here too
  • Set the prompt:
You are a friendly customer support agent.

Ticket category: {{ $('Classifier Agent').item.json.output }}
Customer subject: {{ $('Webhook').item.json.body.subject }}
Customer message: {{ $('Webhook').item.json.body.message }}

Write a concise, helpful email reply to this customer.
Start with "Hi there," and end with "Best regards, Support Team".

Step 5: Add the Email Agent

This sends the drafted reply back to the customer.

  • Add a Gmail (or SMTP) node, connected to the Response Agent
  • Configure:
    • To Email: {{ $('Webhook').item.json.body.email }}
    • Subject: Re: {{ $('Webhook').item.json.body.subject }}
    • Email Format: HTML
    • HTML body: {{ $('Response Agent').item.json.output }}
  • Connect your Gmail credentials



Step 6: Test it

You can test the webhook using curl. On Windows, save the payload as a .json file first.

billing.json:

{

  "email": "alice@example.com",

  "subject": "Double charged on my account",

  "message": "I noticed two charges of $49 on my credit card this month. I only subscribed once. Please refund the extra charge."

Then run the command from command line like below: 

Pls make sure to execute the flow before running the below command. Why because, the webhook keep listening all the messages(json) to run the flow.

D:\>curl -X POST http://localhost:5678/webhook-test/<your-webhook-id> -H "Content-Type: application/json" -d @billing.json





Sample Email:



Step 7: Go live

Once everything checks out, toggle the workflow to Active. Your webhook is now live and will process incoming tickets in real time.

Closing thoughts

This three-agent pipeline is intentionally minimal, but it demonstrates the core idea behind A2A automation: each agent does one well-defined job, and its output becomes the next agent's input. Once this pattern feels natural, scaling up to more complex workflows — with parallel agents and merge steps — is a much smaller jump.


Popular posts from this blog

Connecting Claude to Pega Infinity 25.1.3 via MCP — Step-by-Step

itextpdf API to generate PDF doc from an image file using Pega PE

Understanding of Hugging Face platform for AI/ML platform