AI Contact Routing
Build an intelligent contact form that automatically routes inquiries to the right department using Gen.AI
This tutorial guides you through creating an intelligent contact form powered by generative AI. The system automatically analyzes the content of submitted inquiries and routes them to the appropriate department within your organization—be it sales, support, or careers—enhancing operational efficiency and customer response times.
What You’ll Build
A complete AI-powered contact routing system with:
- A customizable contact form for your website or application
- Intelligent content analysis using OpenAI
- Automated routing to department-specific email addresses
- Attachment handling capabilities
- Easy maintenance and monitoring
This solution demonstrates how Prisme.ai can combine AI models with automation workflows to create intelligent business processes that scale with your organization’s needs.
Prerequisites
Before starting this tutorial, make sure you have:
- An active Prisme.ai account
- The SendMail app installed in your workspace
Step 1: Creating Your Workspace
First, let’s set up a dedicated workspace for our contact routing system:
Access AI Builder
Log in to your Prisme.ai account and navigate to the AI Builder product
Create a New Workspace
Click the “Create Workspace” button to start a new project
Configure Workspace Settings
- Name your workspace “AI Contact Routing” (or a name of your choice)
- Add a description like “Intelligent contact form with AI-based routing”
- Select an appropriate icon for your workspace
- Configure any additional settings as needed
Step 2: Building the Contact Form
Now, let’s create a user-friendly contact form that will collect information from your visitors:
Create a New Page
In your workspace, navigate to the Pages section and click “Create Page”
Configure Page Properties
- Name your page “Contact Us Form”
- Set the slug to “contact-us” (this will be used in the URL)
Add a Form Block
Add a Form block to your page for inquiries with the following configuration:
Set the Form Submission Event
In the form configuration, set the “onSubmit” field to “formSubmit” - this event name will trigger our automation
Save Your Page
Save your page configuration. Your form should now be ready to collect user inquiries
Get the Page URL
Click the share icon to get your page’s URL. The format will be: workspace-slug.pages.host/lang/contact-us
Step 3: Installing Required Apps
Before creating our automation, we need to install the necessary apps from the Prisme.ai App Store:
Access the App Store
Navigate to the “Apps” section in your workspace
Install the SendMail App
- Click the ”+” button to browse available apps
- Search for “SendMail” and click to install it
- Follow the on-screen instructions to complete the installation
Install the OpenAI App
- Again, click the ”+” button in the Apps section
- Search for “OpenAI” and click to install it
- During configuration, enter your OpenAI API key
Step 4: Creating the Form Submission Handler
Now, let’s build the automation that will process form submissions and route them based on AI analysis:
Create a New Automation
- Navigate to the “Automations” section of your workspace
- Click “Create Automation”
- Name it “Form Submission Handler”
- Set the slug to “form-submission-handler”
Configure the Event Trigger
Set up the automation to trigger on the “formSubmit” event (the same event we configured in our form)
Set Default Recipient
Add a “Set var” instruction:
- Variable name: “recipient”
- Value: “hello@example.com” (a default email in case routing fails)
Add OpenAI Analysis
Add an “OpenAI.chat-completion” instruction:
- Model: Select “gpt-4” (or another appropriate model)
- Messages:
- System role: “Given the following customer inquiry, categorize it as either sales, support, or careers. Provide your categorization based on the content. Answer only with category nothing else.”
- User role:
"{{payload.message}}"
- Output: “result”
Extract AI Response
Add another “Set var” instruction:
- Variable name: “routingDecision”
- Value:
"{{result.choices[0].message.content}}"
Create Conditional Routing
Add a “conditions” instruction with the following branches:
- Condition:
{{routingDecision}} = "sales"
- Action: Set recipient to “sales@example.com”
- Condition:
{{routingDecision}} = "support"
- Action: Set recipient to “support@example.com”
- Condition:
{{routingDecision}} = "careers"
- Action: Set recipient to “careers@example.com”
Configure Email Notification
Add a “SendMail.sendMail” instruction:
- To:
"{{recipient}}"
(the dynamically set department email) - ReplyTo:
"{{payload.email}}"
(the submitter’s email) - Subject: “New Contact Form Submission”
- Body: “Message:
{{payload.message}}
, Name:{{payload.name}}
, Attachment:{{payload.attachment}}
”
Set Output and Save
- Set the automation output to
{{routingDecision}}
- Save your automation
Step 5: Testing Your Contact Routing System
Now it’s time to test your AI contact routing system:
Access Your Contact Form
Navigate to your contact form using the URL you obtained earlier
Submit Test Inquiries
Fill out the form with different types of inquiries to test the routing:
- A sales-related inquiry (e.g., “I’m interested in pricing for your enterprise plan”)
- A support-related inquiry (e.g., “I’m having trouble logging into my account”)
- A careers-related inquiry (e.g., “I’d like to apply for the marketing position”)
Verify Email Routing
Check that each test inquiry is routed to the correct department email
Test Attachment Handling
Submit a form with an attachment to ensure files are properly included in the emails
Step 6: Version Control and Deployment
To finalize your contact routing system:
Pull Your Changes
Use the “Pull” button in your workspace to create a new version
Set Up Access Controls
Configure Role-Based Access Control (RBAC) to determine who can access and modify your contact routing system
Monitoring and Optimization
After deployment, regularly check the system’s performance:
Monitor Activity Logs
Review the activity logs to track form submissions and routing decisions
Review Classification Accuracy
Periodically check if inquiries are being routed correctly and refine your system as needed
Optimize the AI Prompt
If necessary, adjust the OpenAI prompt to improve classification accuracy for your specific use case
Extending Your Contact Routing System
Consider these enhancements to make your system even more powerful:
- Multi-level Classification: Add subcategories to route inquiries to specific teams within departments
- Priority Detection: Use AI to identify urgent inquiries and flag them for immediate attention
- Sentiment Analysis: Detect the emotional tone of inquiries to handle frustrated customers appropriately
- Automated Responses: Send automated acknowledgment emails based on the inquiry type
- CRM Integration: Connect with your CRM system to log inquiries as leads or support tickets
- Slack Integration: Send notifications to Slack channels for real-time team collaboration
Complete YAML Configuration
Here’s the complete YAML for the Form Submission Handler automation:
Next Steps
Build a Document Classification System
Learn how to classify and organize documents with AI
Create Webhook Integrations
Connect your contact system to external services using webhooks
Implement RAG Agents
Build a knowledge base to provide automated responses to common inquiries
Explore Custom Applications
Develop more sophisticated applications using AI Builder