mirror of
https://github.com/khoaliber/n8nworkflows.xyz.git
synced 2026-04-28 00:29:22 +00:00
creation
This commit is contained in:
+366
@@ -0,0 +1,366 @@
|
||||
Automated Customer Support with GPT-4o-mini AI Triage for Google Forms & Gmail
|
||||
|
||||
https://n8nworkflows.xyz/workflows/automated-customer-support-with-gpt-4o-mini-ai-triage-for-google-forms---gmail-10469
|
||||
|
||||
|
||||
# Automated Customer Support with GPT-4o-mini AI Triage for Google Forms & Gmail
|
||||
|
||||
### 1. Workflow Overview
|
||||
|
||||
This workflow automates customer support responses by integrating Google Forms, AI-powered triage, and Gmail. It targets organizations receiving customer inquiries via Google Forms and aims to:
|
||||
|
||||
- Automatically analyze each inquiry using GPT-4o-mini AI for urgency, category, sentiment, and keywords.
|
||||
- Route inquiries based on urgency into high, medium, or low priority paths.
|
||||
- Generate contextually appropriate email replies tailored to the priority and inquiry content.
|
||||
- Send personalized auto-replies via Gmail.
|
||||
- Alert support teams on Slack for high-priority cases.
|
||||
- Log all interactions into a Google Sheets tracking document for audit and analytics.
|
||||
|
||||
**Logical Blocks:**
|
||||
|
||||
- **1.1 Input Reception:** Trigger on new Google Form responses and map form columns.
|
||||
- **1.2 AI Processing:** Analyze inquiry text with OpenAI GPT-4o-mini for triage classification.
|
||||
- **1.3 Result Parsing & Routing:** Parse AI output, route by urgency level.
|
||||
- **1.4 Response Generation:** Generate email replies tailored to priority level.
|
||||
- **1.5 Email Preparation & Sending:** Extract email subject/body and send via Gmail.
|
||||
- **1.6 Data Logging & Team Alerts:** Prepare data for tracking, send Slack alerts for high urgency, log to Google Sheets.
|
||||
|
||||
---
|
||||
|
||||
### 2. Block-by-Block Analysis
|
||||
|
||||
#### 1.1 Input Reception
|
||||
|
||||
**Overview:**
|
||||
Monitors a Google Sheets document linked to a Google Form and triggers the workflow on new row additions. Then maps the form column names to workflow variables for standardized referencing.
|
||||
|
||||
**Nodes Involved:**
|
||||
- Google Form Responses Trigger
|
||||
- Map Form Column Names
|
||||
|
||||
**Node Details:**
|
||||
|
||||
- **Google Form Responses Trigger**
|
||||
- Type: Google Sheets Trigger
|
||||
- Role: Watches for new rows added in the form response sheet every minute.
|
||||
- Configuration: Monitors a specified Google Sheet and sheet name linked to the Google Form responses. Uses polling mode "every minute".
|
||||
- Input: None (trigger node)
|
||||
- Output: New row data as JSON.
|
||||
- Edge Cases: If Google Sheets API quota exceeded, trigger may fail; empty or malformed rows might cause issues.
|
||||
|
||||
- **Map Form Column Names**
|
||||
- Type: Set Node
|
||||
- Role: Assigns user-defined form column names ("Email Address", "Inquiry", "Name") to variables for consistent use downstream.
|
||||
- Configuration: Defines three string variables: `emailColumnName`, `inquiryColumnName`, and `nameColumnName`.
|
||||
- Input: Output from Google Form Responses Trigger
|
||||
- Output: Passes original data with added mapped column names.
|
||||
- Edge Cases: If form column names differ from defaults and are not updated here, data extraction will fail.
|
||||
|
||||
---
|
||||
|
||||
#### 1.2 AI Processing
|
||||
|
||||
**Overview:**
|
||||
Sends inquiry data to OpenAI's GPT-4o-mini model for triage analysis, classifying urgency, category, sentiment, extracting keywords, and summarizing the inquiry.
|
||||
|
||||
**Nodes Involved:**
|
||||
- Analyze with AI Triage
|
||||
|
||||
**Node Details:**
|
||||
|
||||
- **Analyze with AI Triage**
|
||||
- Type: OpenAI (Langchain node)
|
||||
- Role: Performs natural language processing to classify and summarize the inquiry.
|
||||
- Configuration: Uses GPT-4o-mini model with a detailed prompt instructing strict urgency classification rules, predefined categories, sentiment analysis, and output in strict JSON format with no markdown.
|
||||
- Key Expression: Prompt includes dynamic injection of customer name, email, and inquiry from JSON inputs.
|
||||
- Input: Mapped form data from previous block.
|
||||
- Output: AI JSON response embedded in OpenAI node output structure.
|
||||
- Edge Cases: AI response may be malformed, JSON parse errors possible; API rate limits or auth failures may occur.
|
||||
- Version Notes: Requires OpenAI credentials and GPT-4o-mini model availability.
|
||||
|
||||
---
|
||||
|
||||
#### 1.3 Result Parsing & Routing
|
||||
|
||||
**Overview:**
|
||||
Parses AI JSON response to extract triage data, then routes the flow based on urgency (high, medium, low).
|
||||
|
||||
**Nodes Involved:**
|
||||
- Parse AI Analysis Results
|
||||
- Route by Priority Level
|
||||
|
||||
**Node Details:**
|
||||
|
||||
- **Parse AI Analysis Results**
|
||||
- Type: Code Node (JavaScript)
|
||||
- Role: Extracts and parses the AI JSON response and merges it with original form data and mapped column names for normalized output.
|
||||
- Key Expressions: Uses `JSON.parse` on AI response text; fallback defaults to medium/general/neutral if parsing fails.
|
||||
- Input: Output from AI node.
|
||||
- Output: JSON with keys: email, inquiry, name, urgency, category, sentiment, keywords, summary, timestamp.
|
||||
- Edge Cases: Parsing errors logged; missing fields defaulted.
|
||||
- Version Notes: Uses n8n 2.x+ JavaScript APIs.
|
||||
|
||||
- **Route by Priority Level**
|
||||
- Type: Switch Node
|
||||
- Role: Routes data flow based on `urgency` field into three output branches: High, Medium, Low Priority.
|
||||
- Configuration: Case-sensitive string match on urgency field with renamed outputs for clarity.
|
||||
- Input: Parsed triage data.
|
||||
- Output: One of three possible routes.
|
||||
- Edge Cases: If urgency is missing or unexpected, no route matched (may cause flow interruption).
|
||||
|
||||
---
|
||||
|
||||
#### 1.4 Response Generation
|
||||
|
||||
**Overview:**
|
||||
Generates personalized email responses for each priority level using separate OpenAI nodes with distinct prompt instructions.
|
||||
|
||||
**Nodes Involved:**
|
||||
- Generate Urgent Response (High Priority)
|
||||
- Generate Standard Response (Medium Priority)
|
||||
- Generate Friendly Response (Low Priority)
|
||||
|
||||
**Node Details:**
|
||||
|
||||
- **Generate Urgent Response**
|
||||
- Type: OpenAI node
|
||||
- Role: Creates a polite, professional, and urgent email response acknowledging urgency, negative sentiment, and outlining next steps with fast response commitment.
|
||||
- Configuration: GPT-4o-mini with prompt including customer name, category, sentiment, inquiry, and explicit formatting instructions (SUBJECT and BODY).
|
||||
- Input: High priority routed data.
|
||||
- Output: AI-generated text with subject/body.
|
||||
- Edge Cases: AI response format might deviate; fallback handling needed downstream.
|
||||
|
||||
- **Generate Standard Response**
|
||||
- Type: OpenAI node
|
||||
- Role: Creates a polite, professional standard reply for medium priority inquiries.
|
||||
- Configuration: Similar prompt structure tailored for professional tone without urgency emphasis.
|
||||
- Input: Medium priority routed data.
|
||||
- Output: AI-generated subject/body text.
|
||||
- Edge Cases: Same as above.
|
||||
|
||||
- **Generate Friendly Response**
|
||||
- Type: OpenAI node
|
||||
- Role: Generates a polite, friendly email for low priority inquiries (e.g., compliments, casual questions).
|
||||
- Configuration: Friendly tone prompt with required output formatting.
|
||||
- Input: Low priority routed data.
|
||||
- Output: AI-generated subject/body text.
|
||||
- Edge Cases: Same as above.
|
||||
|
||||
---
|
||||
|
||||
#### 1.5 Email Preparation & Sending
|
||||
|
||||
**Overview:**
|
||||
Extracts email subject and body from AI-generated text, then sends the reply via Gmail.
|
||||
|
||||
**Nodes Involved:**
|
||||
- Extract Email Subject and Body
|
||||
- Send Auto-Reply via Gmail
|
||||
|
||||
**Node Details:**
|
||||
|
||||
- **Extract Email Subject and Body**
|
||||
- Type: Code Node (JavaScript)
|
||||
- Role: Parses AI response text to separate SUBJECT and BODY sections using regex and string splits. Also merges triage metadata for email context.
|
||||
- Key Expressions: Regex to extract "SUBJECT:" line and "BODY:" content. Defaults subject if missing.
|
||||
- Input: AI response from one of the generation nodes.
|
||||
- Output: Structured JSON including subject, body, email, name, urgency, category, sentiment, keywords, summary, inquiry, timestamp.
|
||||
- Edge Cases: Missing or malformed SUBJECT/BODY may cause incomplete emails; fallback applied.
|
||||
|
||||
- **Send Auto-Reply via Gmail**
|
||||
- Type: Gmail Node
|
||||
- Role: Sends the composed email to the customer's email address using Gmail OAuth2 credentials.
|
||||
- Configuration: Uses dynamic expressions from input JSON for recipient, subject, and message body; disables attribution footer for professionalism.
|
||||
- Input: Extracted email data.
|
||||
- Output: Confirmation of email sent.
|
||||
- Edge Cases: Gmail auth failures, quota limits, or invalid email addresses could cause errors.
|
||||
|
||||
---
|
||||
|
||||
#### 1.6 Data Logging & Team Alerts
|
||||
|
||||
**Overview:**
|
||||
Prepares data for tracking, conditionally alerts support team on Slack if high priority, and logs all inquiries into a Google Sheet tracking document.
|
||||
|
||||
**Nodes Involved:**
|
||||
- Prepare Data for Tracking
|
||||
- Is High Priority?
|
||||
- Alert Team on Slack
|
||||
- Log to Tracking Sheet
|
||||
|
||||
**Node Details:**
|
||||
|
||||
- **Prepare Data for Tracking**
|
||||
- Type: Set Node
|
||||
- Role: Consolidates all triage and email data into a structured format suitable for logging and alerting.
|
||||
- Configuration: Assigns fields like name, email, urgency, category, sentiment, summary, keywords, subject, inquiry, timestamp from previous nodes.
|
||||
- Input: Output from Send Auto-Reply node.
|
||||
- Output: Structured data for routing.
|
||||
- Edge Cases: Missing data fields if previous parsing failed.
|
||||
|
||||
- **Is High Priority?**
|
||||
- Type: If Node
|
||||
- Role: Checks if `urgency` equals "high" to branch flow for alerts.
|
||||
- Input: Prepared tracking data.
|
||||
- Output: True branch triggers Slack alert and log; False branch only logs.
|
||||
- Edge Cases: Case sensitivity handled; unknown urgency defaults to false.
|
||||
|
||||
- **Alert Team on Slack**
|
||||
- Type: Slack Node
|
||||
- Role: Sends formatted Slack message alerting team of high priority inquiry with customer info and summary.
|
||||
- Configuration: Uses OAuth2 Slack authentication; channel ID specified in settings; message formatted with markdown and emojis.
|
||||
- Input: True branch from Is High Priority node.
|
||||
- Output: Slack message confirmation.
|
||||
- Edge Cases: Slack auth failure, incorrect channel ID, rate limits.
|
||||
|
||||
- **Log to Tracking Sheet**
|
||||
- Type: Google Sheets Node
|
||||
- Role: Appends a new row with all tracking data to a dedicated Google Sheet for analytics and auditing.
|
||||
- Configuration: Document ID and sheet name specified; operation set to "append".
|
||||
- Input: Both True and False branches from Is High Priority node converge here.
|
||||
- Output: Append confirmation.
|
||||
- Edge Cases: API quota exceeded, sheet not found, permission errors.
|
||||
|
||||
---
|
||||
|
||||
### 3. Summary Table
|
||||
|
||||
| Node Name | Node Type | Functional Role | Input Node(s) | Output Node(s) | Sticky Note |
|
||||
|-----------------------------|----------------------------|-----------------------------------------------|-----------------------------|----------------------------------------------|----------------------------------------------------------------------------------------------------|
|
||||
| Google Form Responses Trigger | Google Sheets Trigger | Triggers on new Google Form submission | None | Map Form Column Names | Step 1: Form Response Trigger - setup Google Form response sheet and polling every minute |
|
||||
| Map Form Column Names | Set Node | Maps form fields to workflow variables | Google Form Responses Trigger | Analyze with AI Triage | Step 2: Map Column Names - customize form column names if different |
|
||||
| Analyze with AI Triage | OpenAI (Langchain) | Analyzes inquiry text for urgency, category, sentiment | Map Form Column Names | Parse AI Analysis Results | Step 3: AI Triage Analysis - urgency, category, sentiment, keywords, summary |
|
||||
| Parse AI Analysis Results | Code Node | Parses AI JSON response and merges form data | Analyze with AI Triage | Route by Priority Level | |
|
||||
| Route by Priority Level | Switch Node | Routes inquiry based on urgency (high/med/low) | Parse AI Analysis Results | Generate Urgent/Standard/Friendly Response | Step 4: Priority Routing - routes inquiries by urgency to appropriate response templates |
|
||||
| Generate Urgent Response | OpenAI (Langchain) | Generates urgent, empathetic email response | Route by Priority Level (High) | Extract Email Subject and Body | Step 5: Generate AI Response - priority-specific templates with personalizations |
|
||||
| Generate Standard Response | OpenAI (Langchain) | Generates standard professional email response | Route by Priority Level (Medium) | Extract Email Subject and Body | |
|
||||
| Generate Friendly Response | OpenAI (Langchain) | Generates friendly, polite email response | Route by Priority Level (Low) | Extract Email Subject and Body | |
|
||||
| Extract Email Subject and Body | Code Node | Parses AI-generated email subject and body | Generate Urgent/Standard/Friendly Response | Send Auto-Reply via Gmail | |
|
||||
| Send Auto-Reply via Gmail | Gmail Node | Sends personalized auto-reply email | Extract Email Subject and Body | Prepare Data for Tracking | Step 6: Send Auto-Reply - uses Gmail OAuth2, disables attribution footer |
|
||||
| Prepare Data for Tracking | Set Node | Consolidates data for logging and alerts | Send Auto-Reply via Gmail | Is High Priority? | |
|
||||
| Is High Priority? | If Node | Checks if urgency is high for alerting | Prepare Data for Tracking | Alert Team on Slack / Log to Tracking Sheet | |
|
||||
| Alert Team on Slack | Slack Node | Sends Slack alert for high-priority inquiries | Is High Priority? (True branch) | Log to Tracking Sheet | Step 7: Team Alerts & Tracking - Slack alerts for high priority, recommended manual follow-up |
|
||||
| Log to Tracking Sheet | Google Sheets Node | Logs all inquiries and metadata to tracking sheet | Alert Team on Slack / Is High Priority? (False branch) | None | Step 7: Team Alerts & Tracking - logs all cases with full data for audit and analytics |
|
||||
| Sticky Note - Workflow Overview | Sticky Note | Documentation of overall workflow purpose and steps | None | None | AI-Powered Customer Support Automation description with setup and customization notes |
|
||||
| Sticky Note - Step 1 | Sticky Note | Describes setup of form response trigger | None | None | Details on Google Form trigger setup |
|
||||
| Sticky Note - Step 2 | Sticky Note | Describes mapping of Google Form columns | None | None | Instructions to customize column names |
|
||||
| Sticky Note - Step 3 | Sticky Note | Describes AI triage analysis | None | None | Explains AI analysis outputs and customization |
|
||||
| Sticky Note - Step 4 | Sticky Note | Describes priority routing | None | None | Explains routing logic and priority criteria |
|
||||
| Sticky Note - Step 5 | Sticky Note | Describes AI response generation | None | None | Notes on AI response templates and output format |
|
||||
| Sticky Note - Step 6 | Sticky Note | Describes sending auto-reply email | None | None | Gmail OAuth2 setup and email sending details |
|
||||
| Sticky Note - Step 7 | Sticky Note | Describes team alerts and tracking | None | None | Slack alert setup and logging instructions |
|
||||
|
||||
---
|
||||
|
||||
### 4. Reproducing the Workflow from Scratch
|
||||
|
||||
1. **Create Google Form** with fields: Name, Email Address, Inquiry.
|
||||
|
||||
2. **Connect Google Form to Google Sheets:** The form responses should auto-populate a Google Sheet.
|
||||
|
||||
3. **Create "Google Form Responses Trigger" node:**
|
||||
- Type: Google Sheets Trigger
|
||||
- Configure with your Google Sheet Document ID and sheet name corresponding to form responses.
|
||||
- Set event to "Row Added" and polling to "Every Minute".
|
||||
- Connect your Google API credentials.
|
||||
|
||||
4. **Create "Map Form Column Names" node:**
|
||||
- Type: Set Node
|
||||
- Add three string fields:
|
||||
- `emailColumnName` = "Email Address"
|
||||
- `inquiryColumnName` = "Inquiry"
|
||||
- `nameColumnName` = "Name"
|
||||
- Enable "Include Other Fields" to pass all form data.
|
||||
- Connect input from Google Form Responses Trigger.
|
||||
|
||||
5. **Create "Analyze with AI Triage" node:**
|
||||
- Type: OpenAI (Langchain)
|
||||
- Set model to "gpt-4o-mini"
|
||||
- Paste the detailed prompt that instructs classification by urgency, category, sentiment, keywords extraction, and summary.
|
||||
- Use expressions to inject customer Name, Email, and Inquiry from mapped variables.
|
||||
- Connect input from Map Form Column Names.
|
||||
- Configure OpenAI API credentials.
|
||||
|
||||
6. **Create "Parse AI Analysis Results" node:**
|
||||
- Type: Code Node
|
||||
- Use JavaScript to parse AI JSON response embedded in the output, with fallback defaults.
|
||||
- Extract urgency, category, sentiment, keywords, summary, and merge with original form data.
|
||||
- Connect input from Analyze with AI Triage.
|
||||
|
||||
7. **Create "Route by Priority Level" node:**
|
||||
- Type: Switch Node
|
||||
- Add three rules:
|
||||
- Output "High Priority" if urgency equals "high"
|
||||
- Output "Medium Priority" if urgency equals "medium"
|
||||
- Output "Low Priority" if urgency equals "low"
|
||||
- Connect input from Parse AI Analysis Results.
|
||||
|
||||
8. **Create three OpenAI nodes for response generation:**
|
||||
- **Generate Urgent Response:** GPT-4o-mini, prompt for urgent, empathetic tone, outputs SUBJECT and BODY. Connect from "High Priority" route.
|
||||
- **Generate Standard Response:** GPT-4o-mini, prompt for professional, neutral tone, outputs SUBJECT and BODY. Connect from "Medium Priority" route.
|
||||
- **Generate Friendly Response:** GPT-4o-mini, prompt for friendly, casual tone, outputs SUBJECT and BODY. Connect from "Low Priority" route.
|
||||
- All three require OpenAI credentials.
|
||||
|
||||
9. **Create "Extract Email Subject and Body" node:**
|
||||
- Type: Code Node
|
||||
- Parse AI generated text to extract SUBJECT and BODY using regex.
|
||||
- Merge triage and form data from Parse AI Analysis Results node.
|
||||
- Connect inputs from all three AI response generation nodes (merge outputs).
|
||||
|
||||
10. **Create "Send Auto-Reply via Gmail" node:**
|
||||
- Type: Gmail Node
|
||||
- Set recipient email, subject, and message body from extracted data using expressions.
|
||||
- Disable attribution footer for professionalism.
|
||||
- Connect input from Extract Email Subject and Body.
|
||||
- Connect Gmail OAuth2 credentials.
|
||||
|
||||
11. **Create "Prepare Data for Tracking" node:**
|
||||
- Type: Set Node
|
||||
- Assign fields: name, email, urgency, category, sentiment, summary, keywords, subject, inquiry, timestamp from Parse AI results and extracted email data.
|
||||
- Connect input from Send Auto-Reply via Gmail.
|
||||
|
||||
12. **Create "Is High Priority?" node:**
|
||||
- Type: If Node
|
||||
- Condition: Check if urgency equals "high" (case insensitive).
|
||||
- Connect input from Prepare Data for Tracking.
|
||||
|
||||
13. **Create "Alert Team on Slack" node:**
|
||||
- Type: Slack Node
|
||||
- Configure OAuth2 Slack credentials.
|
||||
- Select channel to post alert.
|
||||
- Message content includes customer name, email, category, sentiment, summary, original inquiry, and note about auto-reply and manual follow-up.
|
||||
- Connect input from True branch of Is High Priority?.
|
||||
|
||||
14. **Create "Log to Tracking Sheet" node:**
|
||||
- Type: Google Sheets Node
|
||||
- Configure with tracking Google Sheet document ID and sheet name.
|
||||
- Operation: Append row with all tracking data fields.
|
||||
- Connect input from both:
|
||||
- Slack alert node (True branch)
|
||||
- False branch of Is High Priority? (direct)
|
||||
|
||||
15. **Test the workflow thoroughly:**
|
||||
- Submit sample form entries covering all priority levels.
|
||||
- Validate AI triage accuracy, routing, email content, sending, Slack alerts, and logging.
|
||||
- Adjust AI prompts and column mappings as needed.
|
||||
|
||||
---
|
||||
|
||||
### 5. General Notes & Resources
|
||||
|
||||
| Note Content | Context or Link |
|
||||
|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
|
||||
| This workflow uses GPT-4o-mini, a cost-effective model with $0.001-0.002 per inquiry cost and supports multi-language. | AI Model choice and cost considerations |
|
||||
| Slack integration is optional but highly recommended for real-time team alerts on urgent inquiries. | Slack OAuth2 setup and channel selection |
|
||||
| Ensure Google Sheets API quotas are sufficient for polling and logging operations. | Google Sheets integration best practices |
|
||||
| Gmail node requires OAuth2 authorization with “Send email” scope enabled. | Gmail OAuth2 setup instructions |
|
||||
| Customize AI prompt templates to align with your brand voice, policies, and customer service standards. | AI prompt customization best practices |
|
||||
| For multi-language support, AI automatically detects language in inquiries without extra configuration. | Multi-language capability of GPT-4o-mini |
|
||||
| Tracking sheet columns should match all assigned fields for accurate logging and analytics. | Google Sheets tracking sheet column setup |
|
||||
| Slack alert messages use markdown formatting with emojis for better visibility. | Slack message formatting guidelines |
|
||||
| This workflow can be adapted to integrate with CRM or other notification channels (Discord, SMS) with additional nodes. | Extensibility options |
|
||||
| Setup time estimated at 15-20 minutes for experienced users familiar with n8n and API credentials. | Project setup estimate |
|
||||
|
||||
---
|
||||
|
||||
**Disclaimer:** The text provided is derived exclusively from an automated workflow created with n8n, an integration and automation tool. The processing strictly complies with current content policies and contains no illegal, offensive, or protected elements. All data handled is legal and public.
|
||||
Reference in New Issue
Block a user