Crea un AGENTE AI con n8n [Tutorial per principianti]

Crea un AGENTE AI con n8n [Tutorial per principianti]

How to Create Your First Agent with N8N

Introduction to N8N

  • The tutorial focuses on creating a first agent using N8N, building upon previous content that introduced basic automation.
  • The environment of N8N is similar to other automation tools like Zapier and Make, where users can create automations by adding nodes.

Setting Up N8N

  • The presenter uses the hosted version of N8N on Hostinger, highlighting three ways to use it: local installation, via the official site with a subscription, or hosting on a VPS.
  • Using Hostinger's VPS starts at $4.99/month compared to $24/month for the basic subscription on the official site, offering significant savings.

Promotional Offer

  • A promotional code "Gito VPS" provides an additional 10% discount when signing up for Hostinger’s services.
  • Users can apply this discount during checkout in the designated box on Hostinger's payment screen.

Benefits of Using a VPS

  • Hosting N8N on a VPS allows for advanced project management and workflow automation while providing features like real-time snapshots and automatic backups.
  • Additional benefits include AI assistance for managing the VPS, firewall protection against DDoS attacks, and global data center access for improved performance.

Creating an Agent in N8N

  • The tutorial transitions into creating an agent within N8N, starting from understanding what an agent is before moving into practical creation steps.

AI Integration in N8N: A Step-by-Step Guide

Introduction to AI Agents in N8N

  • The integration of AI within N8N offers numerous possibilities, particularly through the dedicated AI section that includes various blocks designed for automation.
  • The tutorial focuses on using a simple AI agent, making it accessible for users who may not be advanced in technical skills.

Configuring the AI Agent

  • Each AI agent consists of components such as the chat model, where users can select from options like Antropic or OpenAI; Gemini is chosen here due to its free usage.
  • For testing purposes, the 2.5 flash model is selected to allow functionality without incurring costs associated with more advanced models.

Memory Component Setup

  • The memory component is optional; however, it can enhance functionality by retaining previous interactions. In this example, Simple Memory is utilized.
  • Users can set how many previous messages should be remembered; the default is five, but it can be adjusted up to ten for better context retention.

Demonstrating Basic Functionality

  • After configuration, users can interact with the agent via an open chat interface. Initial queries demonstrate basic responses from Gemini.
  • The agent retains information about previous messages (e.g., user name), showcasing how memory enhances conversational continuity.

Advanced Features and Tool Integration

  • Users have access to a variety of tools that the agent can utilize during interactions, including integrations with platforms like Asana and Google services.
  • This flexibility allows agents to perform tasks across multiple applications seamlessly while providing results back to users.

Conclusion and Call to Action

Creating an Automated Newsletter Summarizer

Initial Setup and Agent Creation

  • The speaker discusses the importance of supporting the video to enhance visibility on YouTube, indicating a clean slate for creating an agent.
  • The first step involves manually triggering the agent, with a promise of future videos explaining various triggers in detail.
  • The speaker adds an AI block to the workflow using N8N, specifically selecting the agent functionality while removing unnecessary chat messages.
  • A new button appears for executing workflows manually, shifting from chat-based activation to manual initiation of the automation process.
  • The speaker selects Google Gemini Chat Model version 2.5 for its cost-effectiveness and free daily call limits.

Defining Agent Instructions

  • The goal is to create an agent that summarizes unread newsletters from Gmail every Sunday evening and sends a summary email while marking them as read.
  • This setup aims to streamline email management by allowing users to focus only on important newsletters after receiving concise summaries.
  • The agent's behavior can be defined either through chat or custom instructions; here, custom instructions are preferred for automation purposes.
  • A prompt is crafted detailing the agent's role: summarizing unread newsletters using a specific format including author, date, and summary content without bullet points.
  • Emphasis is placed on avoiding lists in summaries; instead, concise sentences are preferred for clarity.

Accessing Gmail and Configuring Tools

  • To function correctly, the agent needs access to Gmail; this is set up through N8N’s tool section where credentials must be configured properly.
  • Users are instructed on how to connect their Gmail accounts if they haven't done so previously in earlier videos about N8N setup.
  • Instead of sending emails, the primary operation required is retrieving messages; thus, "get many" action is selected with a limit set for message retrieval (e.g., 10).

Organizing Email Workflows with Labels and Filters

Importance of Naming Conventions

  • The speaker emphasizes the need to rename blocks for clarity, using "recupera newsletter non lette" as an example to ensure easy identification of tasks.

Managing Complex Agents

  • When dealing with complex agents that handle numerous tasks, clear naming helps in understanding each node's function. The speaker suggests using mnemonic names for easier reference.

Demonstration of Email Management

  • A demonstration is provided using a Gmail account where the speaker tests email functionalities with sample emails, highlighting the importance of practical application.

Recommendations for Newsletters

  • The speaker recommends newsletters from friends Matteo Aliotta and Luca Barboni, noting their quality and relevance to the audience.

Setting Up Filters in Gmail

  • Before executing workflows, it's crucial to set up filters in Gmail. The speaker explains how labeling emails (e.g., "newsletter") aids in organization and retrieval.

Filtering Unread Emails

  • To avoid retrieving old newsletters, the speaker sets filters to only include unread emails. This ensures that only relevant content is processed by the agent.

Workflow Execution Process

  • After setting up filters, the workflow execution begins. The agent retrieves specified unread newsletters based on established criteria.

Monitoring Agent Activity

  • During execution, viewers can observe how the agent identifies its role and processes emails accordingly. It retrieves newsletters from both recommended sources effectively.

Output Review and Corrections

  • The output includes minor errors due to forwarding emails but highlights that these will self-correct when used regularly without manual intervention.

Marking Emails as Read Post-Summary

Modifying the Agent's Behavior in Workflow Automation

Defining Tools and Actions

  • The speaker initiates the process by defining a new tool called "marca come letto" (mark as read), which will be integrated into the agent's instructions.
  • A new action is added to call this tool for each retrieved message, using the thread ID from previous results, specifically from Gmail.

Organizing Tool Names

  • The speaker emphasizes the importance of clear naming conventions for tools, renaming them to ensure clarity in their functions within the workflow.
  • After executing the workflow, it is expected that not only will summaries be generated but also that specific emails will be marked as read.

Execution and Real-Time Monitoring

  • During execution, real-time updates show that two emails have been marked as read and summaries have been completed successfully.
  • The significance of marking emails as read is highlighted; it prevents future retrieval of already processed messages.

Scheduling and Email Notifications

  • The current setup requires manual initiation; however, there’s a need to automate this process to run every Sunday evening.
  • An email notification feature is introduced where a summary of unread newsletters will be sent automatically after processing.

Finalizing Workflow Steps

  • The speaker discusses customizing email content with HTML formatting options for better presentation before sending out summaries.
  • A final step is added to send an email containing the summary once all tasks are completed. This node is renamed for clarity in its function within the workflow.

Testing and Confirmation

  • A test execution is performed to confirm that all steps work correctly, including marking emails as read again if necessary.
  • Upon completion, confirmation messages indicate successful summarization and marking of newsletters as read while also sending out an email summary.

Enhancing Email Formatting

  • Suggestions are made for improving email formatting by adding dates or weeks in subject lines for better organization.

How to Automate Email Summaries with N8N

Setting Up the Automation

  • The automation is designed to summarize emails and mark them as unread, sending the summary via email. It should operate automatically without manual intervention.
  • N8N allows for multiple triggers for the same automation, enabling it to activate under various conditions such as chat interactions or scheduled times.
  • The user sets a schedule for the automation to run weekly on Sundays at 10:00 PM, ensuring consistent operation.

Connecting Triggers and Finalizing Setup

  • After setting up the schedule, it's important to connect this trigger within the N8N interface. Keeping a manual trigger is recommended for testing purposes.
  • Users are reminded to switch their automation from Inactive to Active after setup. This step is crucial for ensuring that the automation runs as intended.

Customization and Additional Features

  • The user can rename their automation (e.g., "Prova YouTube primo agente") and make adjustments based on personal needs or preferences.
  • Viewers are encouraged to modify tools and prompts according to their requirements. Feedback is welcomed regarding interest in more N8N videos.

Promotional Information

  • A promotion from Hostinger offers viewers a discount on subscriptions when using a specific code, enhancing viewer engagement with potential savings opportunities.
Video description

Ottieni il 10% di sconto sul tuo VPS con il link https://www.hostinger.com/gaitovps e inserisci il coupon GAITOVPS A grande richiesta arriva il tutorial su come creare un agente AI usando n8n Avete adorato il primo tutorial di questa serie e in centinaia mi avete chiesto di mostrare come creare un semplice agente in totale autonomia Le potenti automazioni di n8n si possono facilmente integrare con l'intelligenza artificiale e possiamo creare degli agenti che svolgano operazioni in autonomia al posto nostro. In questo tutorial vi mostro come fare, come sempre in modo semplice e passo passo, accessibile anche a chi lo usa per la prima volta. Nel video parlo di: 00:00 Creare agenti in n8n 02:05 Un agente AI semplice 09:15 Un agente più avanzato: inizio 19:40 Aggiungere altri tool all'agente 26:11 Aggiungere altri trigger all'agente 🙏 Supporta il canale abbonandoti qui: https://www.youtube.com/channel/UCrebGs3b-Z7JLKQM2YOpUKA/join Video realizzato con Tella, usa questo link per il 30% di sconto: https://gaito.link/tella Hai bisogno di una VPN? Prova NordVPN da questo link e hai 4 mesi gratuiti extra: https://nordvpn.com/raffaelegaito Se vuoi sponsorizzare un tuo prodotto/servizio nei miei contenuti scrivi a raffaele.gaito@flatmatesagency.com Un grazie speciale a questi abbonati al canale: Vincenzo Paolo Stefania Giordani Alberto Negro Maria Francesca Belcaro Alessio Farinella #ad #ia #intelligenzaartificiale #n8n __________ 🤖 Entra GRATIS in IA360: https://gaito.link/y-ia360 📚 Scopri i miei libri: https://gaito.link/y-libri ✉️ Iscriviti alla mia newsletter: https://gaito.link/y-newsletter