AI Agent with Custom Tool for Email Handling
detail.loadingPreview
An AI agent workflow that uses a custom tool to handle user queries. It checks for an email address and either escalates to human support or prompts the user to provide an email.
About This Workflow
This workflow orchestrates an AI agent that interacts with users via chat. It leverages a custom tool to determine the next course of action based on whether the user has provided an email address in their query.
- Main Workflow: The AI agent (
AI Agentnode) is the central component, receiving chat messages. It can utilize various tools, including the custom 'dont_know_tool'. - Custom Tool (
dont_know_tool): This tool is designed to be invoked when the AI agent is unsure of an answer or lacks confidence. It triggers a sub-workflow that specifically handles user queries based on email presence. - Sub-workflow: This part of the flow is initiated when the AI agent calls the
dont_know_tool. It checks for an email address in the user's input.- If an email is found, it messages a Slack channel (
Message Slack for help) to escalate the issue to human support and confirms this action to the user (Confirm that we've messaged a human). - If no email is found, it prompts the user to rephrase their question and include an email address (
Prompt the user to provide an email).
- If an email is found, it messages a Slack channel (
- AI Components: Utilizes
OpenAI Chat Modelfor language generation andSimple Memoryfor conversational context.
Key Features
- AI-powered Chat Interaction: Responds to user queries via a chat interface.
- Conditional Logic: Dynamically decides actions based on user input (presence of an email).
- Custom Tool Integration: Allows the AI agent to invoke specific workflow logic.
- Email Detection: Uses regex to identify email addresses in user input.
- Human Escalation: Seamlessly integrates with Slack for human support when needed.
- User Guidance: Provides clear prompts to users when information is missing.
How To Use
- Configure Credentials: Ensure your OpenAI API credentials and Slack API credentials are set up in n8n (
Sticky Note5,Sticky Note4). - Main Workflow Trigger: This workflow can be triggered in two ways:
- Chat Trigger: Use the
When chat message receivednode to initiate the workflow from a chat interface. - External Workflow Trigger: Use the
When Executed by Another Workflownode to call this workflow from another n8n workflow, passingchatInputas a parameter.
- Chat Trigger: Use the
- AI Agent Configuration: The
AI Agentnode (395349d1-1715-4550-a0c8-1388d17b4386) is pre-configured with an OpenAI model (OpenAI Chat Model) and memory (Simple Memory). It also has access to thedont_know_tool(61ddb25a-f7f2-4691-94d5-3f32c183ec46). - Custom Tool Logic: The
dont_know_toolis designed to be used when the AI agent is uncertain. It calls theWhen Executed by Another Workflownode, which then passes thechatInputto theCheck if user has provided emailnode. - Email Check: The
Check if user has provided emailnode (a807ca29-65bf-4d97-b89f-5ce16cd05347) uses a regular expression to detect email addresses. - Response Paths:
- Email Found: The workflow proceeds to
Message Slack for help(b9c552ce-4c58-48dd-b168-5e277de89954) and thenConfirm that we've messaged a human(644a05fc-ac7e-4ea9-ab03-3b6fbf7a3654). - No Email Found: The workflow proceeds to
Prompt the user to provide an email(38e81aa5-30b3-48f9-88e8-1039f607f3e7).
- Email Found: The workflow proceeds to
- Testing: You can test by sending messages through the chat interface or by executing the
When Executed by Another Workflownode with appropriatechatInput.
Apps Used
Workflow JSON
{
"id": "928b06f4-15de-4ab0-aae5-c70f16a5a93a",
"name": "AI Agent with Custom Tool for Email Handling",
"nodes": 7,
"category": "AI",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 928b06f4-15de...
About the Author
Crypto_Watcher
Web3 Developer
Automated trading bots and blockchain monitoring workflows.
Statistics
Related Workflows
Discover more workflows you might like
Build an AI Documentation Expert Chatbot with Gemini RAG
This n8n workflow automates the creation of an AI-powered expert chatbot capable of answering questions based on your documentation. It intelligently ingests, cleans, and processes your knowledge base, preparing it for a Retrieval Augmented Generation (RAG) pipeline with Google Gemini.
Generate Multilingual Image Captions and Overlay
This workflow generates captions for images using Google Gemini and overlays them onto the image, with support for multilingual output.
LangChain Workflow Retriever Example
Demonstrates using LangChain's Retriever QA Chain to query data retrieved from another workflow.