AI Agent Human Handoff Using Custom Workflow Tool - n8n Workflow

Deploy an intelligent AI agent using this n8n workflow. It features a custom n8n tool to manage human handoff via Slack when the model is unsure, ensuring continuous customer support and capturing user emails.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users looking for advanced n8n templates utilizing AI Agents.
Automation specialists needing seamless AI-to-Human customer support escalation.
Developers building custom tools for n8n AI agents.
Organizations wanting to integrate AI customer service with Slack.

Overview

This comprehensive n8n workflow provides a robust solution for deploying an AI chat agent capable of intelligent decision-making regarding human assistance. While the primary function of the n8n agent is to answer queries, it is configured with a powerful custom tool: a secondary n8n workflow. When the AI model (running on an OpenAI Chat Model n8n node) encounters a question it is unsure about, it utilizes this custom tool. This tool intelligently checks the user's message for an email address. If an email is present, it automatically messages the support team via a Slack n8n node. If not, it prompts the user to provide contact information, ensuring no support request is lost. This is an excellent example of utilizing specialized n8n templates for critical business logic.

How it Works

This automation consists of two interconnected n8n workflows: the Main Agent and the Custom Tool Sub-workflow.


  1. Input and Agent Processing: The Main workflow is activated by the When chat message received n8n trigger. The input flows into the AI Agent n8n node, which uses the OpenAI Chat Model (GPT-4o-mini) and Simple Memory to maintain conversation context.

  2. Tool Call: If the agent is unable to provide a confident answer, it executes the Not sure? Workflow Tool, passing the user's original chatInput to the secondary n8n workflow.

  3. Sub-workflow Trigger: The Sub-workflow is started by the When Executed by Another Workflow n8n trigger, capturing the user's message.

  4. Email Check: The Check if user has provided email If n8n node runs a regular expression check on the input to determine if a valid email address is included.

  5. Path A (Email Found): If the email is found, the Message Slack for help n8n node sends a notification to the designated Slack channel (#general) with the user's message. The Confirm that we've messaged a human Code n8n node returns a confirmation response to the Main workflow.

  6. Path B (No Email Found): If no email is found, the Prompt the user to provide an email Code n8n node returns a message asking the user to re-submit their query along with their email address. This ensures the best use of this powerful n8n workflow logic.

Installation Guide

To deploy this advanced n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON and import it into your n8n instance.

  2. OpenAI Credentials: Locate the OpenAI Chat Model n8n node in the Main workflow. Set your OpenAI API credentials. Note: This n8n node uses gpt-4o-mini.

  3. Slack Credentials: In the Sub-workflow, locate the Message Slack for help n8n node. Configure your Slack API credentials and ensure the channelId (currently set to #general) matches your support channel.

  4. Workflow Tool Configuration: The Not sure? n8n node is pre-configured to call the Sub-workflow using the current workflow ID. Ensure both workflows are active.

  5. Execution: Activate both n8n workflows. Use the 'Chat' interface in the Main workflow to test the agent. To trigger the custom tool, use a prompt like: "Hi! Please respond to this as if you don't know the answer to my query."

Node Details

This intricate automation relies on several specialized n8n node types:

When chat message received (n8n trigger): The primary n8n trigger for the agent, initiating the conversation.
OpenAI Chat Model (n8n node): Serves as the Large Language Model, using GPT-4o-mini to process and respond to user queries.
AI Agent (n8n node): The core orchestrator. It manages the conversation flow, maintains memory (via Simple Memory), and decides when to invoke the Not sure? tool.
Not sure? (Workflow Tool n8n node): A custom tool that connects the Main workflow to the Sub-workflow, passing chatInput data when the AI is uncertain. This is key to extending the capabilities of the n8n agent.
When Executed by Another Workflow (n8n trigger): The specific n8n trigger that starts the Sub-workflow, receiving data from the parent agent via the custom tool.
Check if user has provided email (If n8n node): Executes conditional logic, using a regex pattern to validate the presence of an email address in the user input before proceeding with human handoff.
Message Slack for help (Slack n8n node): Sends the user query to a predefined Slack channel for human support staff intervention, a crucial action in this n8n workflow.
Code (n8n node - two instances): Used to craft specific JSON response objects for the agent, either confirming human handoff or prompting the user for an email.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by

Technical writer

Featured*