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
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:Access Builder
/builder.Create a New Workspace
Choose a Starting Point
Configure Workspace Settings
- Name your workspace AI Contact Routing
- Add a description like “Intelligent contact form with AI-based routing”
- Click Create Workspace

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.
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
index page — that’s the workspace’s React app.Switch to Code mode
src/App.tsxsrc/main.tsxsrc/styles/globals.cssindex.htmlpackage.jsonvite.config.ts
Replace src/App.tsx with the contact form
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.Save the page
Preview the form

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
Install the SendMail App
Install the Agent Factory App
Agents automation namespace.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
when: { endpoint: true }. The page reaches it at ${sdk.host}/workspaces/slug:${workspace.slug}/webhooks/submit-contact.Set Default Recipient
- Variable name: “recipient”
- Value: “hello@example.com” (a default email in case routing fails)
Call the Routing Agent
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
- Variable name: “routingDecision”
- Value:
'{{result.task.output.messages[0].parts[0].text}}'
Create Conditional Routing
- 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
- 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}}”
Return a Confirmation to the SPA
handleSubmit reads routed_to and category from the response and shows them in the success banner. Save the automation.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
<workspace-slug>.pages.prisme.ai if the workspace is deployed.Submit Test Inquiries
- 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
routed_to and category returned by the automation.Test Attachment Handling

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
Set Up Access Controls
Monitoring and Optimization
After deployment, regularly check the system’s performance:Monitor Activity Logs
Review Classification Accuracy
Optimize the Agent Instructions
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: