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.Documentation Index
Fetch the complete documentation index at: https://docs.prisme.ai/llms.txt
Use this file to discover all available pages before exploring further.
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 a governed agent
- 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
- The Agent Factory App installed in your workspace
- An Agent Factory API key generated in Agent Creator (open any agent → Settings → API Keys) and pasted into the Agent Factory App’s configuration field
apiKeyafter installing it. This is required when the contact form is public — without it,Agents.sendMessagereturns401 UNAUTHORIZEDfor unauthenticated submissions. - A routing agent created in Agent Creator with system instructions like: Given the following customer inquiry, categorize it as either sales, support, or careers. Provide your categorization based on the content. Answer with the category only.
Step 1: Creating Your Workspace
First, let’s set up a dedicated workspace for our contact routing system:
Step 2: Building the Contact Form
Now, let’s create a user-friendly contact form that will collect information from your visitors. In v27, each Builder workspace has a single editable page calledindex — a React + Vite + Tailwind + Radix SPA, not a block canvas.
If you came from the legacy Pages model, the block YAML (
slug: Form, onSubmit: formSubmit, etc.) is gone. Pages are now React SPA source trees; the platform compiles and previews them inside Builder. Form submission is done with fetch against a webhook automation, not by emitting a Prisme.ai event.Open Pages
In your workspace, select Pages in the Builder sidebar. Open the editable
index page — that’s the workspace’s React app.Switch to Code mode
Use the page toolbar to switch to Code. You should see the source tree with files such as:
src/App.tsxsrc/main.tsxsrc/styles/globals.cssindex.htmlpackage.jsonvite.config.ts
Replace src/App.tsx with the contact form
Open
src/App.tsx in the editor and replace its content with the SPA below. It renders a Tailwind-styled form with name, email, message, and an optional attachment file input. On submit, it reads the file as a base64 data URL (simple option for small attachments) and POSTs everything as JSON to a webhook automation called submit-contact.
src/App.tsx is in place, the contact form appears in the right pane.
Step 3: Installing Required Apps
Before creating our automation, we need to install the necessary apps from the Prisme.ai App Store:Open the Imports panel
In your workspace sidebar, open Imports and click the + button to browse the marketplace.
Install the SendMail App
Search for “SendMail” and click to install it. Follow the on-screen instructions to complete the installation.
Step 4: Creating the Form Submission Handler
Now, let’s build the webhook automation that processes form submissions and routes them based on AI analysis. The page calls it viafetch, so we expose it as an HTTP endpoint and read the form fields from body.*.
Create a New Automation
- Navigate to the “Automations” section of your workspace
- Click “Create Automation”
- Name it “Submit Contact”
- Set the slug to
submit-contact— it must match the URL the SPA POSTs to
Configure the Webhook Trigger
Set the trigger to a webhook (HTTP endpoint) instead of an event. In YAML this is
when: { endpoint: true }. The page reaches it at ${sdk.host}/workspaces/slug:${workspace.slug}/webhooks/submit-contact.Set Default Recipient
Add a “Set var” instruction:
- Variable name: “recipient”
- Value: “hello@example.com” (a default email in case routing fails)
Call the Routing Agent
Add an
Agents.sendMessage instruction:agent_id:{{config.routingAgentId}}(set the agent ID under workspace Configuration)message:{ parts: [{ type: text, text: '{{body.message}}' }] }- Output:
result
Extract Agent Response
Add another “Set var” instruction:
- Variable name: “routingDecision”
- Value:
'{{result.task.output.messages[0].parts[0].text}}'
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:
"{{body.email}}"(the submitter’s email) - Subject: “New Contact Form Submission”
- Body: “Message:
{{body.message}}, Name:{{body.name}}, Attachment:{{body.attachment.name}}”
Step 5: Testing Your Contact Routing System
Now it’s time to test your AI contact routing system. You have two ways to do it:- In Builder Preview — open the
indexpage in Preview mode. The compiled SPA runs inside Builder with the workspace context already injected, so thefetchcall tosubmit-contactworks without deploying. This is the fastest first-run check. - On the deployed page — once the workspace is deployed, the public URL is
<workspace-slug>.pages.prisme.ai.
Access Your Contact Form
Open the form in Builder’s Preview, or navigate to
<workspace-slug>.pages.prisme.ai if the workspace is deployed.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. The success banner in the SPA also shows the resolved
routed_to and category returned by the automation.
runtime.automations.executed event with a correlation ID — drill into one to see the Agents.sendMessage and SendMail.sendMail sub-calls.
Step 6: Version Control and Deployment
To finalize your contact routing system:Push Your Changes
Use the Push button in your workspace to create a new version. See Versioning for details.
Set Up Access Controls
Configure Role-Based Access Control to determine who can access and modify your contact routing system. See RBAC for details.
Monitoring and Optimization
After deployment, regularly check the system’s performance:Review Classification Accuracy
Periodically check if inquiries are being routed correctly and refine your system as needed
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 thesubmit-contact webhook 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 Builder