What This Workflow Does
This workflow reads customer chat messages, tries to answer them using AI, and handles cases when AI can’t reply well.
It asks users to share their email if missing and sends complicated questions to a Slack channel.
This saves time by automating simple answers and alerts humans only when needed.
The workflow uses AI memory to keep chat context and checks emails with a regular expression.
It sends polite messages back to the customer for follow-up or confirmation.
Tools and Services Used
- OpenAI GPT-4o-mini model: Generates chat answers and understanding.
- n8n AI Agent Chat Trigger node: Starts workflow when a chat message arrives.
- Simple Memory Buffer node: Keeps track of previous messages for better replies.
- Custom Tool Workflow node: Handles uncertain AI answers with email checks and Slack alerts.
- Slack Node: Posts complex questions to a Slack support channel.
- If Node: Detects valid emails using regex.
- Code Node: Sends confirmation or request messages back to the user.
Beginner Step-by-Step: How to Use This Workflow in Production
Step 1: Import the Workflow
- Download the workflow file using the Download button on this page.
- Open the n8n editor and click Import from File.
- Select the downloaded workflow JSON to import.
Step 2: Configure Credentials and Settings
- Add your OpenAI API Key under Credentials in n8n.
- Add your Slack bot token and set the target Slack channel (like
#general) in the Slack node. - Check and update any email regex or text prompts inside Code nodes if needed.
Step 3: Test the Workflow
- Send a sample chat message using the webhook URL from the When chat message received node.
- Check the logs and Slack channel to see if correct actions happen.
Step 4: Activate for Production
- Turn on the workflow toggle in the n8n editor.
- Monitor performance from the execution dashboard.
- If self hosting n8n, make sure the server is publicly accessible for webhook calls. Visit self-host n8n for help.
How This Workflow Works
Inputs
- Customer chat message sent to the webhook provided by the When chat message received node.
- Includes text that may have user question and optional email.
Processing Steps
- The chat message triggers the AI Agent node to process the input.
- The AI Agent uses the OpenAI GPT-4o-mini model for understanding and generating answers.
- The Simple Memory node keeps conversation history to answer with context.
- If AI is unsure, it calls the fallback tool workflow (Not sure?) to check for an email.
- The If node uses regex to detect valid emails.
- If email found, message posts to Slack support channel.
- If no email found, the chat bot prompts the user to provide an email.
- Confirmation or prompt messages are sent back to the user using Code nodes.
Outputs
- AI-generated reply to the user for simple questions.
- Slack message in support channel for complex or ambiguous queries with user email.
- User prompt requesting email if missing.
- Polite confirmation message acknowledging that human help will follow.
Customization Ideas
- Change Slack channel in the Slack node to your support team’s channel.
- Adjust the email regex pattern inside the If node to match more email formats.
- Add other AI tools or fallback workflows for different handling of difficult questions.
- Edit the confirmation and prompt messages inside the Code nodes to suit your tone.
Troubleshooting Common Issues
- Workflow not triggered: Check the webhook URL on the When chat message received node is active and accessible.
- Slack message not sent: Confirm Slack API credentials and channel ID are correct in the Slack node.
- Email regex not matching: Test and adjust the regex pattern in the If node.
Pre-Production Checklist
- Test OpenAI API connection with a simple prompt.
- Verify Slack integration and permissions.
- Send test chat messages through the webhook.
- Try inputs with and without email to confirm fallback works.
- Ensure Slack notifications trigger on unclear queries.
Code Snippets Used for User Messages
These Code nodes generate replies sent back to the customer.
Confirmation Message Code
const response = {"response": "Thank you for getting in touch. I've messaged a human to help."}
return response;
This message tells users a human team member will contact them soon.
Prompt for Email Message Code
const response = {"response":"I'm sorry I don't know the answer. Please repeat your question and include your email address so I can request help."};
return response;
This asks users nicely to add their email if missing.
Summary and Benefits
✓ Automates answering simple chat questions using AI.
✓ Checks and requests user email for follow-up when needed.
✓ Sends hard questions directly to a Slack channel for human support.
✓ Saves time by reducing manual message triage.
✓ Keeps conversations clear with AI memory context.
✓ Sends polite messages to users for better experience.
→ Your support team handles fewer routine questions.
→ Customers get faster replies and follow-up without waiting.
→ Workflow runs automatically once set up and activated.
