n8n AI Agent Setup Guide

Aug 10, 2025

Summary

  • The session provided a detailed, step-by-step walkthrough of building a beginner-friendly AI agent in n8n to automate drafting emails, searching contacts, and scheduling calendar events.
  • The process included integrating Google Sheets, Gmail, Google Calendar, and a Telegram connection for interacting with the agent via text and voice.
  • Key decisions included using draft mode for emails, configuring memory for chat continuity, and ensuring the system fetches contact info before performing actions.
  • The tutorial covered practical troubleshooting steps and emphasized the importance of detailed tool descriptions and proper node configuration.

Action Items

  • Set up an n8n account and workspace.
  • Create and connect the necessary Google services (Gmail, Sheets, Calendar) and Telegram bot credentials to n8n.
  • Prepare a Google Sheet with contact information.
  • Add detailed descriptions to each n8n node to clarify its function for the AI agent.
  • Adjust system messages and node configurations to fetch contact details before performing tasks.
  • Test each step of the workflow (chat, email draft, calendar scheduling, Telegram text/voice triggers) for expected behavior.
  • Troubleshoot and resolve node/linking errors as they arise during setup.

n8n Agent Workflow Setup

  • Begin by signing up for an n8n account and opening a new workspace.
  • Create a new workflow, starting with a chat trigger to accept input messages.
  • Visualize the process using a flowchart: input message → AI agent → draft email or schedule meeting.
  • Add an AI agent node, link it to an OpenAI chat model (e.g., GPT-4o mini), and input your OpenAI API key.
  • Set up memory for the agent using window buffer memory (context window length of 5 or 10 recommended).

Google Sheets, Gmail, and Calendar Integration

  • Prepare a Google Sheet containing contact names and email addresses.
  • Add and connect Google Sheets and Gmail nodes to n8n, ensuring proper authentication.
  • For Gmail, set the tool description to clarify it drafts/sends email; configure it to save emails as drafts for review.
  • Allow the AI agent to define email subject and body dynamically; later, configure it to assign the recipient's address pulled from Google Sheets.
  • Set the system message for the agent to require contact data retrieval before sending emails or scheduling events.
  • Rename tools/nodes for clarity (e.g., “get contact tool” for the Sheets node).
  • Integrate Google Calendar, connecting it to n8n and configuring fields (attendees, start/end time, event summary) to be AI-populated.
  • Provide current date/time info to the agent via n8n for accurate scheduling.

Telegram Integration for Text and Voice Commands

  • Remove the n8n chat trigger and add a Telegram trigger for message handling.
  • Generate a Telegram bot through BotFather, retrieve its access token, and connect to n8n.
  • Configure workflow branches using a "switch" node to differentiate between text and voice (audio) messages.
  • For voice messages, add nodes to download and transcribe the audio using OpenAI’s transcription model.
  • Merge the text and transcribed audio streams back together before passing them to the AI agent.
  • Ensure memory tracking is updated to use Telegram chat IDs for conversation continuity.

Testing and Troubleshooting

  • Test the agent’s ability to draft emails (including subject, body, and recipient), retrieve contact information, and schedule calendar events.
  • Test both text and voice commands from Telegram.
  • Tweak system prompts, node descriptions, and parameters as necessary to ensure robust performance.
  • Troubleshoot issues such as missing memory context or incorrect node wiring as they occur.

Decisions

  • Use email draft mode before sending — Adopted to prevent accidental sending and allow for human review, especially in professional or client scenarios.
  • Require contact info retrieval before actions — Ensures accuracy by fetching contact data from Google Sheets before performing any email or scheduling tasks.
  • Integrate Telegram with text/voice support — Chosen to enable convenient agent interaction from anywhere.

Open Questions / Follow-Ups

  • None explicitly mentioned. Further enhancements such as embedding links or customizing email language may be explored after initial setup.