1. Opening Problem Statement
Meet Sarah, a small business owner who runs a growing e-commerce website using WordPress. Every day, she receives dozens of customer inquiries submitted through the Contact Form 7 (CF7) plugin on her site. These messages range from requests about product information to questions on order status, as well as miscellaneous requests and complaints.
Sarah spends hours manually sorting through each submission, trying to understand the intent, drafting appropriate replies for each category, and logging all this information into her spreadsheets for record-keeping. The process is tedious, time-consuming, and prone to human error—some inquiries get delayed or missed entirely, leading to frustrated customers and lost sales.
She needs a reliable system that automatically classifies these incoming messages, drafts professional responses tailored to each inquiry type, and archives the data for easy tracking—freeing her time to focus on growing her business.
2. What This Automation Does
This specialized n8n workflow does exactly what Sarah needs by integrating WordPress CF7 submissions with advanced AI and cloud tools. Here’s what happens when the workflow runs:
- Automatically capture new form submissions via a secure webhook from the WordPress site using the CF7 to Webhook plugin.
- Extract and set key form fields such as first name, last name, email, phone, and message for further processing.
- Classify the inquiry message content intelligently using the Google Gemini Chat Model and a LangChain-based text classifier to categorize into “Product Info,” “Order Info,” or “Other.”
- Generate tailored email drafts for each inquiry category using specialized Google Gemini AI chat models with customized system prompts guiding professional, courteous responses.
- Compose Gmail drafts automatically in the connected Gmail account, ready for review and sending.
- Log all inquiries and AI-generated responses into a Google Sheet for transparent, centralized records and post-communication analysis.
This workflow helps save several hours daily, eliminates manual classification errors, standardizes customer communications, and provides reliable data archiving.
3. Prerequisites ⚙️
- WordPress site with the CF7 to Webhook plugin installed and configured to send POST requests to n8n.
- n8n account (cloud or self-hosted) to run this automation.
- Google Palm API credentials for Google Gemini Chat models integration.
- Gmail account with OAuth2 setup for sending and saving email drafts.
- Google Sheets account with OAuth2 access configured for data logging.
4. Step-by-Step Guide
Step 1: Set up WordPress Webhook for CF7
Install the CF7 to Webhook WordPress plugin, then navigate to its settings tab. Paste the n8n webhook URL (found in the “From WordPress” webhook node) as the target URL and choose the POST method to send form submissions in real-time.
Common mistake: Forgetting to enable POST on the webhook settings will cause submissions not to trigger the workflow.
Step 2: Configure the n8n Webhook Trigger
In n8n, open the “From WordPress” Webhook node parameters. Confirm the webhook ID and path are unique and accessible. You should see a status indicating “Webhook listening” once activated.
Step 3: Map Fields from Form Submission
The “Set Fields” node extracts relevant user data from the incoming webhook JSON payload. It assigns values to first_name, last_name, email, phone, and message fields using expressions like =<=$json.body.first_name>.
Step 4: Classify the Message Content
The “Google Gemini Chat Model” node runs the received message through Google Gemini AI. It feeds the text to the “Message Classifier” LangChain node which uses a system prompt to decide among categories Product Info, Order Info, or Other based solely on the content.
Step 5: Generate Email Draft for Each Category
- For Product Info requests: The workflow feeds the data to the “Email writer (Product info)” chain LLM node with a detailed system prompt creating a professional reply draft.
- For Order Info: It sends the data to “Email writer (Order info)” similarly tailored for order-related inquiries.
- For Others: The “Email writer (Others)” node handles miscellaneous questions with a courteous, helpful response.
Step 6: Parse Subject and Body Text of Email
Each email writer node outputs a structured JSON with subject and text fields. These are parsed by separate “Subject and Text” output parser nodes so drafts can be composed correctly.
Step 7: Create Gmail Drafts
Each parsed email draft is fed into the corresponding “Email draft – Product info,” “- Order info,” or “- Other info” Gmail node. Drafts include the generated message plus all submitted form data for context. These drafts go to the appropriate company email ready for review or sending.
Step 8: Save Inquiry and Draft to Google Sheets
The workflow appends the details of each inquiry and AI-generated draft reply to a Google Sheet tab named “Contact Form 7.” This serves as a reliable log for all communications handled.
5. Customizations ✏️
- Add more classification categories: Edit the “Message Classifier” LangChain node to include new categories by modifying its categories JSON array. This allows handling different inquiry types like complaints or technical support.
- Change email recipients: In each Gmail draft node, update the sendTo field to match specific department emails (e.g., [email protected] for product info).
- Customize email tone and style: Update the system prompt in each “Email writer” chain LLM node to alter response tone, add company branding, or change the format of replies.
- Extend data logging: Add more fields to the Google Sheets nodes if you want to record additional form inputs or AI classifications.
- Use other AI models: Replace Google Gemini nodes with other LangChain-compatible AI models for different language models or response behaviors.
6. Troubleshooting 🔧
Problem: “Webhook not triggered on form submission.”
Cause: Incorrect webhook URL or CF7 to Webhook plugin misconfiguration.
Solution: Double-check the URL in the WordPress webhook settings. Ensure POST request method is enabled. Test webhook trigger in n8n by sending test data.
Problem: “Email draft nodes are not generating drafts.”
Cause: Missing or incorrect Google Palm API credentials or Gmail OAuth credentials.
Solution: Confirm all API keys and OAuth credentials are valid and active in n8n credentials settings. Reauthorize if necessary.
Problem: “Message classification always returns ‘other’.”
Cause: System prompt or categories not set properly in the Message Classifier node.
Solution: Review and update the categories in the classifier system prompt. Test classification with known example messages.
7. Pre-Production Checklist ✅
- Verify WordPress plugin is sending POST requests to the exact n8n webhook URL.
- Test the webhook node in n8n by submitting a test form.
- Confirm Google Palm API and Gmail OAuth credentials are configured and authorized in n8n.
- Ensure Google Sheets document ID and permissions are correctly set for appending data.
- Run test submissions for each classification category to verify proper flow and email drafts creation.
8. Deployment Guide
Once you have tested the workflow thoroughly, activate it in n8n by toggling the “active” status on the main workflow screen. Monitor incoming submissions and drafts through your connected Gmail account for quality review.
Consider setting up n8n’s internal logs or using external monitoring tools to track execution status and errors for long-term reliability.
9. FAQs
Q: Can I use a different AI model other than Google Gemini?
A: Yes, you can replace Google Gemini nodes with any LangChain-compatible LLM, such as OpenAI’s GPT models, provided you adjust the prompt and credentials accordingly.
Q: Does this workflow consume a lot of API credits?
A: The AI classification and email generation do use API requests. Volume depends on submission frequency, so plan accordingly in your API usage.
Q: Is my customer data safe in this process?
A: Yes, all communications happen through secured APIs and OAuth mechanisms. Ensure your n8n instance is secure and credentials are safely stored.
10. Conclusion
By following this guide, you have created a powerful automated system that seamlessly manages WordPress CF7 customer inquiries by classifying messages, generating AI-crafted professional responses, drafting emails in Gmail, and logging all communication data reliably in Google Sheets.
This automation reduces Sarah’s daily manual workload by hours, improves response consistency, and enhances customer satisfaction. Next, you could extend this workflow to integrate SMS notifications for urgent queries or link it to a CRM system for advanced customer tracking.
Keep experimenting with n8n and AI to build smarter, more responsive business workflows!