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:

1

Access AI Builder

Log in to your Prisme.ai account and navigate to the AI Builder product

2

Create a New Workspace

Click the “Create Workspace” button to start a new project

3

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:

1

Create a New Page

In your workspace, navigate to the Pages section and click “Create Page”

2

Configure Page Properties

  • Name your page “Contact Us Form”
  • Set the slug to “contact-us” (this will be used in the URL)
3

Add a Form Block

Add a Form block to your page for inquiries with the following configuration:

slug: contact-us
name: Contact Us Form
blocks:
  - slug: Form
    schema:
      type: object
      properties:
        name:
          type: string
          title: Name
          description: Fill your first name please
          placeholder: John doe
        message:
          type: string
          title: Message
          description: Fill your message
          placeholder: your message
          ui:widget: textarea
        email:
          type: string
          placeholder: john.doe@example.com
          description: your email
        attachement:
          type: string
          ui:widget: upload
          title: Attachement
          description: Attach a file if needed
          placeholder: Your file
    onSubmit: formSubmit
4

Set the Form Submission Event

In the form configuration, set the “onSubmit” field to “formSubmit” - this event name will trigger our automation

5

Save Your Page

Save your page configuration. Your form should now be ready to collect user inquiries

6

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:

1

Access the App Store

Navigate to the “Apps” section in your workspace

2

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
3

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:

1

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”
2

Configure the Event Trigger

Set up the automation to trigger on the “formSubmit” event (the same event we configured in our form)

3

Set Default Recipient

Add a “Set var” instruction:

  • Variable name: “recipient”
  • Value: “hello@example.com” (a default email in case routing fails)
4

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”
5

Extract AI Response

Add another “Set var” instruction:

  • Variable name: “routingDecision”
  • Value: "{{result.choices[0].message.content}}"
6

Create Conditional Routing

Add a “conditions” instruction with the following branches:

  • Condition: {{routingDecision}} = "sales"
  • Condition: {{routingDecision}} = "support"
  • Condition: {{routingDecision}} = "careers"
7

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}}
8

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:

1

Access Your Contact Form

Navigate to your contact form using the URL you obtained earlier

2

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”)
3

Verify Email Routing

Check that each test inquiry is routed to the correct department email

4

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:

1

Pull Your Changes

Use the “Pull” button in your workspace to create a new version

2

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:

1

Monitor Activity Logs

Review the activity logs to track form submissions and routing decisions

2

Review Classification Accuracy

Periodically check if inquiries are being routed correctly and refine your system as needed

3

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:

slug: form-submission-handler
name: Form Submission Handler
do:
  - set:
      name: recipient
      value: hello@example.com
  - OpenAI.chat-completion:
      stream:
        options:
          persist: true
      model: mistral-small
      messages:
        - role: user
          content: '{{payload.message}}'
        - role: system
          content: 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.
      output: result
  - set:
      name: routingDecision
      value: '{{result.choices[0].message.content}}'
  - conditions:
      '{{routingDecision}} = "sales"':
        - set:
            name: recipient
            value: sales@example.com
      '"{{routingDecision}}" = "support"':
        - set:
            name: recipient
            value: support@example.com
      '"{{routingDecision}}" = "careers"':
        - set:
            name: recipient
            value: careers@example.com
      default: []
  - SendMail.sendMail:
      to: '{{recipient}}'
      replyTo: '{{payload.email}}'
      subject: New Contact Form Submission
      body: 'Message: {{payload.message}}, Name: {{payload.name}}, Attachment: {{payload.attachment}}'
output: '{{routingDecision}}'
when:
  events:
    - formSubmit

Next Steps