Build your first AI automation
An AI assistant that reads your customer sheet and writes email drafts. Ask it who your highest paying customer is, or ask for a thank you email. It looks up the answer in Google Sheets and leaves a draft in Gmail. No code.
0 of 8 steps done
Chat messageAI Agent
Add the chat trigger
- Click "Add first step".
- Search for "chat" and pick "Chat". On the canvas it is named "When chat message received".
- Click "Open chat" and send the message below.
- Click the trigger node. You should see three fields: action, sessionId and chatInput.
Chat message
Hello, my name is Svetlana.
- I searched "chatTrigger" and nothing came up
- Search for just "chat". The node is listed as "Chat", the first result.
Add the AI Agent
- Click the + on the right side of the trigger.
- Search for "AI Agent" and pick it.
- Leave "Source for Prompt" as "Connected Chat Trigger Node".
- Close the panel. A red warning under Chat Model is normal for now.
- Error: A Chat Model sub-node must be connected and enabled
- That is expected. The agent has no AI model yet. The next step fixes it.
Connect a model with OpenRouter
- Create an API key at openrouter.ai under Settings, API Keys. Keep it private.
- Click the + under Chat Model and pick "OpenRouter Chat Model".
- Create a new credential and paste your key.
- Pick a low cost model.
- Under Options, add "Maximum Number of Tokens" and set the value below.
Maximum Number of Tokens
1024
- Authorization failed, please check your credentials
- Paste the key again with no space before or after it. Check on OpenRouter that the key is switched on.
- Payment required: you requested up to 65536 tokens
- No token limit is set. Add "Maximum Number of Tokens" under Options and set it to 1024.
Add memory
- First say your name, then send the question below. The agent does not know the answer.
- Click the + under Memory and pick "Simple Memory".
- Leave Session ID as "Connected Chat Trigger Node".
- Set Context Window Length to 5.
- Say your name and ask again. Now it remembers.
Chat message
What's my name?
- It still forgets my name
- Both messages must be in the same chat session. Also check that Simple Memory is connected to the agent.
Connect Google Sheets
- Download the mock customer file below.
- Open sheets.new, then File, Import, Upload, and choose "Replace spreadsheet".
- In n8n click the + under Tool, pick Google Sheets, then "Get row(s) in sheet".
- Sign in with Google.
- Choose your document, then choose the tab under Sheet.
- Sheet with ID not found
- The Sheet field is empty. Set it to "From list" and pick your tab, or choose "By ID" and type 0.
- I cannot see my file in the Document list
- Switch Document to "By URL" and paste the address of your sheet. Check you signed in with the same Google account.
Give the agent its instructions
- Open the AI Agent node.
- Click "Add Option" and pick "System Message".
- Replace the text with the prompt below.
- Reset the chat session, then ask: Who is the highest-paying customer?
System message
You are a helpful customer support assistant.
Today's date and time: {{ $now.toISO() }}
You have access to a Google Sheets tool containing mock customer information and a Gmail tool for creating email drafts.
When the user asks about a customer, consult Google Sheets rather than inventing an answer.
When comparing customer spending, use the numeric spending values from the sheet.
When asked to create an email draft:
- Find and verify the customer's email in Google Sheets.
- Write a professional, friendly subject and email body.
- Use Gmail to create a draft only.
- Never send an email automatically.
- If an email address is missing or ambiguous, ask for clarification.
- Do not claim a draft was created unless the Gmail tool succeeds.
Keep your responses clear, short, and helpful.- The agent says it has no access to customer data
- The agent did not use the sheet. Check this prompt is saved, then reset the chat session so the old answer is gone from memory.
Connect Gmail for drafts
- Click the + under Tool, search for Gmail and pick "Create a draft".
- Sign in with Google. Only "Manage drafts and send emails" is needed.
- Click the sparkle button next to Subject and Message so the agent fills them in.
- Under Options add "To Email" and click the sparkle button there too.
- My Gmail node shows "Approval Options"
- That is the approval action. Delete the node and add Gmail again with "Create a draft".
- The draft has no recipient
- "To Email" is missing. Add it under Options and let the agent fill it in.
Create your first draft
- Reset the chat session.
- Send the prompt below.
- In the logs, Google Sheets should run first and Gmail second.
- Open Gmail and look in Drafts. Nothing was sent.
Chat message
Create a thank-you email draft for Elma. Thank her for being a valuable customer and for her continued support. Use the email address from our Google Sheet. Don't send the email.
- It found no customer named Elma
- Check the sheet has a row for Elma and that the Sheets tool has no filter, so it returns every row.
You built the whole workflow.
Next: find one task you repeat every week and automate it.
QUICK CHECK
You want a workflow to start every morning at 9:00. Is that a trigger or an action?
Pick one.
QUICK CHECK
The agent answers a customer question without calling Google Sheets. Where do you look first?
Pick one.