How I’d Teach a 10 Year Old to Build AI Agents (No Code, n8n)

How I'd Teach a 10 Year Old to Build AI Agents
AI Agent

AI Agent

1. Introduction to AI Agents

AI agents are

"entities"

or

"employees"

that can understand instructions and take actions. They are designed to be conversational and perform tasks based on user input.

Key Components of an AI Agent:

  • Brain (Large Language Model - LLM): This is the core intelligence of the agent, comparable to models like ChatGPT or Claude 3.5. It processes information and determines responses or actions.

    "the two main components within one are the brain which is basically a large language model like ChatGPT CLA 3.5 something like that"

  • Memory: Provides context to the agent by retaining past conversation history. This makes interactions more

    "human-like"

    and ensures future responses and actions are relevant.

    "memory just basically means giving the agent context of what's been going on in a conversation that way it feels more human-like it's more conversational"

    Example: A

    "window buffer memory"

    can be configured to remember a specific number of past messages (e.g., five messages).
  • Instructions (System Prompt/Message): Defines the agent's role, behavior, available tools, and how it should take action. This is a static set of rules that guides the agent's overall operation.

    "instructions within an AI agent basically just to fine this is your role this is what you should be doing this is how you act these are the tools you have this is how you take action"

    Distinction: Not to be confused with

    "user messages,"

    which are the dynamic inputs from the user.
  • Input: The user's query or message to the agent.

    "the user message is the actual input this is how we're talking to the agent"

  • Output: The agent's response or confirmation of an action taken.

    "finally of course it outputs something to us whether that's hey you know we were able to take action for you or whether that's explicitly using a tool like a vector database to pull information back and then returning you that information there's usually some aspect of output"

  • Tools: This is where AI agents become powerful. Tools allow the LLM to

    "actually take action."

    An agent can utilize multiple tools to perform diverse functions.

    "when you start to introduce tools this is where the magic really happens because now the large language model has the ability to actually take action"

    The agent uses its

    "brain in combination with the instructions to understand what just came in what was the user message what tool do I need to do because what tool does what function and then how do I actually go out there and take action."

---

2. Building an AI Agent with n8n (No-Code Example)

This demonstrates how to build a simple email agent using n8n, a no-code automation platform.

Step-by-Step Construction:

  • Start with the AI Agent Node: In n8n, drag and drop the "AI agent" node. It automatically connects to a "chat message receive" trigger for user input.
  • Add a Chat Model (Brain): The agent needs a "brain" to respond. Add a "chat model" subnode (e.g., OpenAI Chat Model).
  • API Key Integration: Connect your OpenAI API key as a credential to access their models. Ensure sufficient funds in your OpenAI account to avoid "insufficient funds" errors. Example: Using

    "GPT for mini"

    as the model.
  • Add Memory: To give the agent context, add a "memory" subnode.

    "Window buffer memory"

    is recommended for chat-based interactions, as it's easy to set up and references the chat trigger node for session ID and context window length. Demonstration: Without memory, the agent won't remember previous conversational turns (e.g., forgetting the user's name). With memory, it can recall past information.
  • Add Tools: Tools enable the agent to perform specific actions.
    • Gmail Tool (Sending Emails):
      • Connect Google credentials.
      • Configure

        "To," "Subject,"

        and

        "Message"

        fields as

        "expressions"

        using the from AI function. This allows the AI to dynamically extract this information from the user's query. Example from AI keys: email recipient, subject, email body.
      • Name the node (e.g.,

        "send email"

        ) for clarity in the system prompt.
      • Optional: Turn off

        "append and attribute"

        to remove n8n branding from emails.
    • Google Sheets Tool (Contact Database):
      • Connect Google credentials.
      • Select the relevant Google Sheet (e.g.,

        "contact database"

        ) and sheet within it.
      • Name the node (e.g.,

        "contact database"

        ) for the agent to reference it.
      • Purpose: Allows the agent to retrieve contact information (like email addresses) from a database based on a person's name, rather than requiring the user to type the email address every time. This can be extended to CRMs, AirTable, or Vector databases.
  • Configure System Message (Instructions): This is crucial for guiding the agent's behavior and tool usage.
    • Add a

      "system message"

      option to the AI agent node.
    • Use a custom GPT (or similar tool) to craft a detailed system message that includes:
      • Overview: General role (e.g., "helpful assistant").
      • Context: What the agent does.
      • Instructions: How it should act and respond.
      • Tools: Explicitly define each tool, its name, and its function (e.g.,

        "send email tool to send emails," "contact database tool retrieves contact data such as email addresses"

        ).
      • Examples: Provide example interactions.
      • Standard Operating Procedure (SOP).
      • Final Notes: Any specific directives (e.g.,

        "always sign off the emails from Frank"

        ).
    • Paste the markdown-formatted system message into n8n as an expression.
---

3. Agent Operation and Logs

Workflow: User Input -> AI Agent (Brain + System Message + Memory) -> Tool Action (e.g., Send Email, Lookup Contact) -> Output.

Logs:

n8n provides detailed logs within the AI agent node, showing the steps the agent took:

  • User message saved to memory.
  • Chat model processes input, references prompt, and identifies necessary tools.
  • Tool parameters are created using AI (e.g., email recipient, subject, email body).
  • Tool executes (e.g., Gmail sends email).
  • Response from tool is received (e.g., email ID from Gmail).
  • Chat model crafts response to user based on action.
  • Memory is updated.
---

4. Expanding Agent Capabilities

  • Dynamic Inputs and Outputs: While demonstrated with n8n's internal chat, agents can be connected to various external platforms:
    • Inputs: Telegram, phone, Slack, etc. (acting as triggers).
    • Outputs: Pushing responses to other services.
  • Backend Applications: AI agents can function as complete backend applications.
  • Real-world Example: An email agent connected to ElevenLabs for a phone conversation, allowing real-time voice commands to send emails.

    "I actually just made a video very similar to this about a email agent where I connected the input and the output to 11 Labs so that I was having a phone conversation basically with this agent and in real time when I was asking it to send emails it was doing so and we kind of saw it take place and then it would respond to me after the email was sent and say I sent that off for you"

---

5. Conclusion

Building AI agents, even complex ones, can be quick and straightforward, especially with no-code tools like n8n and functions like from AI. Understanding the core components (brain, memory, instructions, tools) is key to designing effective agents capable of taking dynamic actions based on user queries.

AI Agent: FAQ

AI Agent: FAQ

What is an AI Agent and its core components?

An AI agent can be thought of as an entity, like a human or an employee, that can understand instructions and take action. Its two main internal components are the "brain" and "memory." The brain is typically a large language model (LLM) such as ChatGPT or Claude 3.5, which processes information and understands instructions. Memory provides context by retaining past conversation history, allowing the agent to provide more human-like, coherent responses and actions.

How do "system prompts" and "user messages" differ in the context of an AI agent?

A "system prompt" (also known as a system message) defines the AI agent's role, behavior, and available tools. These are static instructions that guide the agent's overall function and do not change during an interaction. In contrast, a "user message" is the actual input from the user, representing a dynamic query or instruction that changes with each interaction.

How do "tools" enhance the capabilities of an AI agent beyond a basic chatbot?

While a basic AI agent with a brain and memory can engage in conversational interactions (similar to ChatGPT), the introduction of "tools" allows the agent to perform actions in the real world. Tools give the large language model the ability to understand a user's request, identify which tool is needed for a specific function (e.g., sending an email, retrieving data from a database), and then execute that action. This transforms the agent from a purely conversational entity into an active participant capable of practical tasks.

What is n8n and how does it facilitate building AI agents without code?

n8n is a platform that allows users to build AI agents through a visual, no-code interface. It provides pre-built nodes for components like AI agents, chat models, memory, and various tools (e.g., Gmail, Google Sheets). Users can drag and drop these nodes, connect them, and configure their settings, making it accessible to create and deploy AI agents without writing traditional programming code.

How are external services like Google Sheets and Gmail integrated into an n8n AI agent?

External services like Gmail and Google Sheets are integrated into an n8n AI agent as "tools." This involves adding a specific node for the service (e.g., "Gmail tool," "Google Sheets tool") within the n8n workflow. To enable communication, users must connect their credentials (e.g., Google API keys) to n8n. Once connected, the agent can use AI to dynamically extract necessary information from the user's query (e.g., email recipient, subject, email body, contact name) and pass it to the external service to perform the desired action.

How does the "from AI" function in n8n enable dynamic data extraction for tools?

The "from AI" function is a powerful feature in n8n that allows the AI agent to dynamically extract specific pieces of information from the user's input (query) to populate the parameters of a tool. By defining a "key" (e.g., "email recipient," "subject," "email body"), the AI agent uses its understanding to parse the user message and pull out the relevant data needed to execute the tool's function, making the agent highly adaptable to varying user requests.

What is the purpose of "memory" in an AI agent, and how is it implemented in n8n?

Memory in an AI agent provides context by storing a running history of past interactions. This prevents the agent from "forgetting" previous parts of a conversation, leading to more natural and coherent dialogue and actions. In n8n, memory can be implemented using options like "window buffer memory." This type of memory retains a specified number of recent messages (e.g., the last five messages) to give the agent context for its current responses or actions, often linked to a "session ID" to manage conversation threads.

How can the input and output methods of an AI agent be expanded beyond the n8n environment?

While an AI agent built in n8n can handle chat inputs and outputs within the n8n environment itself, its flexibility allows for integration with various external platforms. Inputs can be configured to come from triggers like Telegram, phone calls (via services like 11 Labs for voice interaction), or Slack. Similarly, outputs can be pushed to these same platforms or serve as a backend application, enabling the agent to interact with users and deliver results through diverse communication channels.

Posts Gallery

Posts Gallery

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top