Build an AI Customer Support Agent

Build an AI support agent in n8n that classifies and logs customer messages.

Introduction

30 Second Summary

Businesses get flooded with customer support messages every day. Most follow predictable patterns like billing questions, technical issues, and general inquiries.

In this project, you will build an AI-powered customer support agent in n8n that classifies messages by category and urgency, generates helpful responses, and logs every interaction to a Google Sheet as a simple ticket tracker.

What You'll Build

You'll create an n8n workflow that connects a Chat Trigger to an AI Agent powered by Google Gemini, with automatic logging to Google Sheets.

By the end of this project, you'll have:

  • A working n8n workflow with a Chat Trigger, AI Agent node, and Google Gemini Chat Model integration.
  • A Google Sheet ticket log that automatically captures timestamps, categories, urgency levels, customer messages, and AI responses.
  • A published workflow you can demo to potential freelance clients.
  • Secret Mission: Add a Simple Memory node so your agent remembers context across multiple messages in the same conversation.

Are there any prerequisites?

You need a Google account for both Gemini API access and Google Sheets. No credit card or paid subscriptions are required.

Set Up n8n Cloud and Google Gemini API Key

Every AI agent needs somewhere to run, a model to power its responses, and a way to record what it does.

In this step, you'll create your n8n Cloud account, generate a Google Gemini API key, and set up a Google Sheets spreadsheet for ticket logging. All three are free for this project.

In this step, get ready to:
  • Sign up for an n8n Cloud free trial account.
  • Create a Google Gemini API key for AI capabilities.
  • Set up a Google Sheet to log support tickets.
Sign up for n8n Cloud

n8n Cloud is a hosted workflow automation platform. It lets you build, test, and run AI workflows in the browser with zero installation.

  • Open the n8n Cloud signup page: https://app.n8n.cloud/register
  • Fill in your email, name, and a password to create your account. No credit card is required.
  • Check your email inbox for a confirmation message from n8n.
  • Click the confirmation link in the email to verify your account.
  • Log in to n8n. You should land in the n8n workflow editor, which is a blank canvas where you'll build your AI agent.

What is n8n Cloud?

n8n is a workflow automation tool that lets you connect apps, AI models, and logic into automated workflows using a visual drag-and-drop editor. n8n Cloud is the hosted version, so you don't need to install or maintain anything yourself.

The free trial lasts 14 days and gives you Pro plan features with up to 1000 workflow executions. It auto-expires with no charges if you don't upgrade.

Can't find the confirmation email?

Check your spam or junk folder. The email comes from n8n and may take a minute to arrive. If it still doesn't show up, try clicking the resend link on the signup confirmation page.

Help me troubleshoot my n8n Cloud signup.

Get your Google Gemini API key

Google Gemini is the AI model that will power your support agent's brain. To connect it to n8n, you need an API key.

  • Open the Google AI Studio API key page: https://aistudio.google.com/apikey
  • Sign in with your Google account if prompted.
  • Click Create API Key.
  • Choose Create API key in new project (or select an existing project if you prefer).
  • Copy the generated key immediately. Save it somewhere secure like a password manager or a private note. You will need this key in the next step.

What is an API key?

An API key is a unique string that identifies your account when your application calls an external service. It lets Google track your usage and enforce security limits.

Keep your key private. Never share it publicly or commit it to a code repository.

Seeing a permission denied error?

If Google AI Studio shows a permission error when creating your key, try selecting Create API key in new project instead of choosing an existing project. New projects automatically grant you the required permissions.

Help me fix my Gemini API key creation error.

Prepare your Google Sheet

Your AI agent will log every customer interaction to a Google Sheet. This acts as a simple ticket tracker that records what the customer said and how the agent responded.

  • Open Google Sheets at https://sheets.google.com.
  • Click Blank spreadsheet to create a new sheet.
  • Click the sheet title ("Untitled spreadsheet" in the top left) and rename it to Support Tickets.
  • In Row 1, enter the following column headers, one per cell:
  • Cell A1: Timestamp
  • Cell B1: Category
  • Cell C1: Urgency
  • Cell D1: Customer Message
  • Cell E1: AI Response

Your sheet should now have five headers across Row 1 with no data in any other rows.

Why a Google Sheet?

Google Sheets works as a lightweight database for this project. It connects to n8n Cloud with a simple sign-in (no complex setup), and it gives you a visible log you can share with clients to demonstrate your agent's work.

Not sure if your headers are correct?

Double check that each header is in its own cell (A1 through E1), not all typed into a single cell. Click each cell individually to verify.

Help me verify my Google Sheet setup.

Your tools are ready. Next up, you'll build the Chat Trigger and AI Agent nodes that bring your support agent to life.

Build the Chat Trigger and AI Agent

Your accounts are set up and your tools are ready. Now it's time to build the brain of your customer support system.

Every AI agent in n8n needs two things: a trigger that kicks off the conversation, and an agent node that decides how to respond. In this step, you'll wire together a Chat Trigger, an AI Agent, and Google Gemini as the language model powering the responses.

In this step, get ready to:
  • Add a Chat Trigger node as your workflow's entry point.
  • Configure an AI Agent node with a System Message.
  • Connect Google Gemini as the AI model powering your agent.
Create a new workflow and add the Chat Trigger

The Chat Trigger node gives you a built-in chat interface to test your agent. No external tools or API clients needed.

  • In your n8n editor, click Create Workflow from the Workflows list on the Overview page. If you see a welcome screen instead, click Start from Scratch.
  • On the empty canvas, click Add first step to open the nodes panel.
  • Search for Chat Trigger in the search bar.
  • Select Chat Trigger from the results. n8n adds the node to your canvas.

What is a Chat Trigger?

A Chat Trigger starts your workflow whenever someone sends a chat message. It provides a built-in chat interface directly in the n8n editor for testing.

This means you can test your AI agent immediately without setting up webhooks, external chat tools, or curl commands.

You should see the Chat Trigger node sitting on your canvas with a green "trigger" label.

Add the AI Agent node and configure its System Message

The AI Agent node is the decision-maker in your workflow. It receives the customer's message from the Chat Trigger and uses a language model to generate a response.

  • Click the Add node connector (the small "+" icon) on the right side of your Chat Trigger node.
  • Search for AI Agent in the nodes panel.
  • Select AI Agent from the results. n8n adds the node and automatically connects it to the Chat Trigger.
  • Open the AI Agent node by double-clicking it.
  • In the Prompt dropdown, confirm it is set to Take from previous node automatically. This tells the agent to use the chat message from the Chat Trigger as its input.
  • Scroll down to Node options and find the System Message field.
  • Paste the following System Message into the field:
You are a helpful and professional customer support specialist for a SaaS company called TechFlow. You assist customers with billing questions, technical issues, and general inquiries. You classify each customer inquiry by category and urgency level. Always respond with empathy, provide clear and actionable answers, and maintain a friendly but professional tone.

What does this System Message do?

A System Message is a pre-conversation instruction sent to the AI model before any customer message arrives. It shapes the agent's personality and behavior for every response.

In this case, you're telling Gemini to act as a customer support specialist who classifies tickets and responds professionally. Without this message, the model would give generic responses with no customer-support focus.

  • Confirm both the Chat Trigger and AI Agent nodes are visible on your canvas, connected by a line.

Nodes not connected?

If you added the AI Agent node separately (not from the Chat Trigger's connector), drag from the Chat Trigger's output handle to the AI Agent's input handle to connect them manually.

help me connect my Chat Trigger to my AI Agent node

Connect the Google Gemini Chat Model

The AI Agent node needs a language model to generate responses. You'll connect Google Gemini as a sub-node so the agent can think and reply.

  • With the AI Agent node open, look for the Chat Model connector at the bottom of the node panel. Click it.
  • Search for Google Gemini Chat Model in the sub-node panel.
  • Select Google Gemini Chat Model. n8n adds it as a sub-node attached to the AI Agent.
  • In the Google Gemini Chat Model node, click the Credential to connect with dropdown, then select Create New Credential.
  • Paste your Gemini API key into the API Key field.
  • Leave the API Host as the default value (https://generativelanguage.googleapis.com).
  • Click Save to store your credential.
  • Back in the Google Gemini Chat Model node, click the Model dropdown. n8n dynamically loads available models from the API. Select a model from the list.

Why does the model list load dynamically?

The Google Gemini Chat Model node fetches the latest available models directly from the Google Gemini API using your credential. This means you always see the most current model options without needing to update n8n.

  • Close the sub-node panel. You should see the Google Gemini Chat Model attached below the AI Agent node on your canvas.

Credential error or no models loading?

Double-check that you pasted your full API key with no extra spaces. Open the credential again by clicking the pencil icon next to the dropdown and verify the key is correct.

If the Model dropdown stays empty, your API key might not have been activated yet. Return to Google AI Studio and confirm the key shows as active.

help me fix my Google Gemini credential in n8n

Your agent's core is wired together. Next up, you'll connect Google Sheets to log every customer interaction and add structured classification to your agent's responses.

Add Structured Output and Google Sheets Logging

Your AI Agent can now receive messages and generate responses. The next challenge is making those interactions trackable.

In this step, you will connect a Google Sheets node to log every customer interaction. You will also teach your agent to classify messages by category and urgency so each ticket is automatically organized.

In this step, get ready to:
  • Connect a Google Sheets node to log customer messages and AI responses.
  • Update the System Message to add classification tags to every response.
  • Test the full workflow end-to-end via the built-in chat interface.
Connect a Google Sheets node to your workflow

Every time your agent responds to a customer, you want a record in your spreadsheet. The Google Sheets node will append a new row to your "Support Tickets" sheet after each conversation.

  • Switch back to the n8n editor canvas where your workflow is open.
  • Click the + button on the right side of the AI Agent node to add a new node after it.
  • Search for Google Sheets in the node panel and select it.

What is the Google Sheets node?

The Google Sheets node lets you read, write, update, and append data in any Google spreadsheet directly from your n8n workflow. You are using the Append Row operation to log a new row each time your agent handles a customer message.

  • In the Credential to connect with dropdown, click Create New Credential.
  • Click Sign in with Google and authorize access to your Google account.
  • Once authorized, close the credential window to return to the node settings.

Why is there no Google Cloud Console setup?

On n8n Cloud, Google Sheets uses Managed OAuth2. n8n handles the OAuth application behind the scenes, so you just click Sign in with Google and authorize. No client ID or secret needed.

  • Set Resource to Sheet Within Document.
  • Set Operation to Append Row.
  • In the Document field, select your Support Tickets spreadsheet from the dropdown.
  • In the Sheet field, select the sheet (usually Sheet1 or whatever your tab is named).
  • Set Mapping Column Mode to Map Each Column Manually.

You should now see input fields for each column header in your spreadsheet. Map them as follows:

  • For the Timestamp column, click the field and switch it to Expression mode. Enter the expression {{ $now }}.
  • For the Customer Message column, switch to Expression mode and drag the chatInput field from the Chat Trigger input panel on the left, or type the expression manually.
  • For the AI Response column, switch to Expression mode and drag the output field from the AI Agent node's output panel.
  • Leave Category and Urgency empty for now. You will come back to map these after updating the System Message.

What does {{ $now }} do?

The {{ $now }} expression is an n8n built-in that returns the current date and time as an ISO-formatted timestamp. It uses the workflow's configured time zone.

Don't see your spreadsheet in the dropdown?

Make sure you authorized the correct Google account (the one that owns the "Support Tickets" sheet). If you used a different account, click the credential dropdown and create a new credential with the correct Google account.

Help me find my spreadsheet in n8n

Update your System Message to include classification tags

Right now your agent responds helpfully, but it does not categorize the ticket. You need the AI to prepend classification tags to every response so you can parse them into separate columns in your spreadsheet.

  • Click on the AI Agent node on your canvas to open it.
  • Open Node options (the gear icon or the Options section at the bottom).
  • Find the System Message field.
  • Replace the current System Message with the following text:
You are a helpful customer support specialist for a SaaS company. Your job is to:
1. Classify each customer message into exactly one category: billing, technical, or general.
2. Assess the urgency as: low, medium, or high.
3. Respond with a helpful, professional answer.

You MUST start every response with classification tags in this exact format:
[CATEGORY: billing] [URGENCY: high]

Then provide your helpful response on the next line. Always include both tags at the very start, before any other text.

What do the classification tags do?

By instructing the AI to prepend [CATEGORY: ...] and [URGENCY: ...] to every response, you create a predictable format you can parse. This is a prompt engineering technique that replaces the need for a separate structured output parser node.

Freelancers use this pattern because it keeps workflows simple while still delivering structured data to downstream systems.

  • Close the AI Agent node.
  • Return to the Google Sheets node.
  • For the Category column, switch to Expression mode and enter an expression that extracts the category from the AI response. You can use the AI Agent's output text and look for the pattern between [CATEGORY: and ].
  • For the Urgency column, do the same for the [URGENCY: pattern.

Keep it simple for now

If parsing with expressions feels complex, you can map the full AI response text to both the Category and Urgency columns for now. The tags will still be visible in the sheet. You can refine the parsing later in Step 4 when you iterate on the prompt.

Not sure how to write the expression?

Try dragging the AI Agent output field into the Category column, then clicking it to open the expression editor. You can use JavaScript string methods like .match() or .split() to extract the value between the brackets.

Help me write a parsing expression

Test your workflow end-to-end

With the Google Sheets node connected and your System Message updated, it is time to verify everything works together.

  • Click the Chat button in the bottom-left corner of the n8n editor to open the built-in chat panel.
  • Type the following test message and press Enter:
I was charged twice for my subscription last month
  • Wait for the AI to respond. The response should start with classification tags like [CATEGORY: billing] [URGENCY: high] followed by a helpful message.
  • Open your Support Tickets Google Sheet in a new browser tab.
  • Check that a new row has appeared with the timestamp, customer message, AI response, and (if you configured parsing) the category and urgency values.

What should I see?

In the n8n chat panel, your agent responds with something like: [CATEGORY: billing] [URGENCY: high] I'm sorry to hear about the double charge.... The exact wording will vary each time because the AI generates it dynamically.

In your Google Sheet, Row 2 should now contain data across the Timestamp, Customer Message, and AI Response columns at minimum. The Category and Urgency columns may also be populated depending on your expression setup.

No new row in your Google Sheet?

Check that the Google Sheets node shows a green checkmark after execution. If it shows a red error, click the node to read the error message. Common causes include selecting the wrong spreadsheet or sheet tab.

Also confirm that the connection line between the AI Agent node and the Google Sheets node is solid (not dashed). A dashed line means the nodes are not properly connected.

Help me debug my Google Sheets connection

Your agent now classifies messages and logs them automatically. Next up, you will test with different message types and refine the prompt to handle edge cases.

Refine the Agent and Publish

Your agent handled a billing message in the last step. That's a great start, but real customer support agents need to handle all kinds of requests.

In this step, you'll stress-test your agent with different message types, refine the System Message based on the results, and publish your workflow so it's live and shareable.

In this step, get ready to:
  • Test your agent with technical, general, and urgent billing messages.
  • Refine your System Message to improve classification accuracy.
  • Publish your workflow so the Chat Trigger is permanently active.
Test with different message types

A well-built support agent needs to handle more than just billing questions. You'll send three different message types to see how your agent classifies and responds to each one.

  • In the n8n editor, open the Chat panel to test your workflow.
  • Type the following technical question and send it:
My dashboard won't load and shows a 500 error
  • Wait for the agent's response. Check that it includes a [CATEGORY: technical] tag and a relevant urgency level.
  • Send a general inquiry next:
What are your business hours?
  • Verify the agent classifies this as [CATEGORY: general] with a low urgency level.
  • Send an urgent billing issue:
I need a refund immediately, I was charged $500 for a plan I cancelled last week
  • Verify the agent classifies this as [CATEGORY: billing] with [URGENCY: high].
  • Switch to your Google Sheets tab in your browser and confirm all three interactions appear as new rows in your Support Tickets sheet.

What should I see in my Google Sheet?

Each row should have all five columns populated: Timestamp, Category, Urgency, Customer Message, and AI Response. You should now see at least four rows of data (including your earlier billing test).

Messages not appearing in your sheet?

Make sure you clicked Execute Workflow before sending messages. The Google Sheets node only runs when the workflow is actively executing.

Also check that the Google Sheets node shows a green checkmark after each run. If it shows red, click on the node to see the error details.

Help me troubleshoot why my Google Sheets node isn't logging messages from my n8n AI Agent workflow.

Refine your System Message based on test results

Your test results reveal how well your agent classifies messages. If any categories or urgency levels were wrong, the fix is in the System Message.

  • Review each response from the three test messages. Note any misclassifications or overly generic replies.
  • Double-click your AI Agent node to open it.
  • Scroll down to the System Message field in the node options.
  • Add more specific instructions to address any issues you found. For example, you can add guidance like: messages mentioning error codes or loading failures should be classified as technical, requests for refunds or charge disputes should always be high urgency, and questions about hours or policies should be general with low urgency.
  • Close the node and test again with the same messages to verify your refinements improved the results.

Why is this called prompt engineering?

This iterative process of testing, reviewing results, and refining your System Message is exactly how professionals tune AI Agents in production. Each refinement makes the agent more reliable without changing any code or adding complex tooling.

Freelance clients pay for this skill. The ability to shape an AI's behavior through well-crafted prompts is what separates a demo from a deployable solution.

Publish your workflow

Your workflow currently only runs when you manually execute it. Publishing makes the Chat Trigger permanently active so it responds to messages without you clicking anything.

  • Look at the top of the n8n editor for the Publish toggle.
  • Click the Publish toggle to activate your workflow.
  • The toggle should turn to the active state, confirming your workflow is now live.

What does publishing do?

Production webhooks and triggers only fire when a workflow is published. Before publishing, your Chat Trigger only works during manual test executions.

After publishing, the Chat Trigger becomes permanently accessible. This is how you'd demo your agent to a freelance client or connect it to an external chat widget.

Don't see the Publish toggle?

Make sure you've saved your workflow first. The Publish toggle appears at the top of the editor once the workflow has been saved at least once.

Help me find and activate the Publish toggle for my n8n workflow.

Secret mission

Add Conversation Memory

Right now, your agent treats every message as a brand new conversation. It has no idea what the customer said 30 seconds ago. In this secret mission, you'll add a Simple Memory sub-node so your agent can remember context across multiple messages in the same session.

Clean Up Your Resources

Clean Up Your Resources

This project runs entirely on free-tier cloud services, so there are no ongoing costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.

Resources you used:

  • n8n Cloud account (free 14-day trial, auto-expires with no charge).
  • Google Gemini API key (free tier, stored as a credential in n8n Cloud).
  • Google Sheet Support Tickets (free with your Google account).

Keep everything running

No action needed. Choose this if you are still actively building or want to demo your agent to someone.

  • Your workflow stays active during the 14-day trial. You can share the chat URL to demo it to potential clients.
  • The Gemini API key remains on the free tier with no charges for normal usage.
  • Your Google Sheet continues to log new interactions whenever someone uses the chat.

Pause - I'll come back to this later

Shut down your workflow so it stops responding to messages, but keep everything saved for later.

  • In the n8n editor, click the Publish toggle at the top of the editor to switch it off. Your workflow stays saved but the Chat Trigger stops accepting messages.
  • Your Gemini API key and Google Sheet remain untouched and ready for when you return.

Delete - I don't want to use this again

Remove all project resources and start fresh. Follow each step below.

  • Download your workflow JSON first. In the n8n editor, click the three-dot menu in the upper right corner and select Download. This saves the workflow as a JSON file to your computer.
  • Delete the workflow in n8n. After downloading, you can delete it from your workspace. The n8n Cloud trial auto-expires after 14 days with no charge, so the account itself requires no manual deletion. You have 90 days after the trial ends to download your workflows.
  • Delete your Gemini API key. Open the Google Cloud API Credentials page, find the API key you created for this project, click the Actions icon, and select Delete API key. Confirm by clicking Delete in the modal.
  • Also remove the credential from n8n. In the n8n editor, go to Credentials in the left sidebar, find your Google Gemini credential, and delete it.
  • Delete the Google Sheet. Open Google Drive, find the Support Tickets spreadsheet, right-click it, and select Move to trash.

That's a Wrap!

That's a Wrap!

Nice work. You just built a fully functional AI customer support agent in n8n from scratch. This is the exact type of AI workflow automation that businesses are hiring freelancers to build right now.

You've learned how to:

  • Built an AI Agent workflow using the Chat Trigger node for instant chat interfaces and Google Gemini as the language model powering your agent's responses.
  • Configured a System Message to control the agent's personality and classification behavior, using prompt engineering to produce structured output without complex tooling.
  • Integrated Google Sheets to log and track customer interactions as a ticket system, then published a live workflow you can demo to potential clients.
  • Secret Mission: Added conversation memory so your agent maintains context across multiple messages in the same session.

Ready to quiz yourself?