Back to Blog
2025-12-27 6 min read

The Inbox Iron Dome: Building AI Sentiment Analysis in FileMaker

Customer support teams often live in a state of reactive chaos. They wake up to an inbox flooded with 200 new tickets, ranging from "I forgot my password" (Low Priority) to "I am suing you because your product deleted my data" (Critical Priority).

Without automation, your most expensive support staff waste the first two hours of their day just reading emails to decide what to work on. Meanwhile, that critical "lawsuit" email sits buried on page 3.

In this article, we will build the Inbox Iron Dome: a FileMaker automated workflow that reads incoming emails, uses AI to analyze their sentiment and intent, and auto-assigns a priority score before a human ever sees them.

The Business Case: Why Build This?

Before we look at the code, let's look at the ROI. Implementing AI triage isn't just cool tech; it solves three specific business bleeds:

  1. Churn Reduction: Angry customers (Negative Sentiment) are flagged immediately. A manager can call them within minutes of the complaint, often saving the account.
  2. Staff Efficiency: Senior staff only look at "High Priority" tickets. Junior staff handle the "Low Priority" password resets.
  3. Triage Latency: The time between receiving an email and categorizing it drops from hours to seconds.

The Architecture

For this build, we assume you already have a method for ingesting emails into FileMaker (such as Claris Connect, an Outlook integration, or a plugin). Our focus here is strictly on the intelligence layer: taking that static text and transforming it into actionable data using FileMaker 2025's native AI script steps.

The Workflow:

  1. Trigger: An email arrives in your HelpDesk table.
  2. Analyze: A "OnRecordLoad" trigger or Scheduled Script initiates the analysis.
  3. Action: The AI returns a JSON object containing the Sentiment, Priority, and Summary. FileMaker parses this and routes the ticket accordingly.

Step 1: The System Prompt (The Brains)

The quality of your data depends entirely on the quality of your prompt. We don't just ask the AI to "read the email." We give it a strict persona and a rigid data contract.

We want the AI to return pure JSON so our scripts can parse it easily.

System Prompt:

Role: You are an expert Customer Support Triage Agent. Your job is to analyze incoming support tickets and categorize them for the engineering team.

Task: Analyze the user's email input and return a valid JSON object. Do not return markdown, prose, or explanations. Only return the JSON.

Output Format:
{
  "sentiment": "Positive" | "Neutral" | "Negative",
  "priority": "Low" | "Medium" | "High" | "Critical",
  "category": "Bug" | "Feature Request" | "Billing" | "Other",
  "summary": "A 1-sentence summary of the issue",
  "recommended_action": "Standard Reply" | "Escalate to Manager"
}

Constraints:
- If the user threatens legal action or churn, Priority is "Critical".
- If the user is reporting a system outage, Priority is "High".
- If the input is spam or nonsensical, set Category to "Other" and Priority to "Low".
- IMPORTANT: Return raw JSON only. Do not wrap the response in markdown code blocks (```json).

Step 2: The Native Script (The Code)

In FileMaker 2025, we utilize the Generate Response from Model script step. This approach is cleaner, faster, and more secure than older methods involving cURL and API keys stored in scripts.

Script Name: AI_Analyze_Ticket

# 1. Establish Context
# We grab the email body from the current record.
Set Variable [ $emailBody ; Value: HelpDesk::Description ]

# 2. Define the Prompt
# Combine the System Prompt (Rules) with the User Data (The Email)
# Tip: Store the "Role" text in a global field or Custom Function for easy editing.
Set Variable [ $prompt ; Value: 
   "Role: You are a Customer Support Triage Agent... [Insert full prompt from Step 1]..." & ¶ & 
   "--- BEGIN EMAIL ---" & ¶ & 
   $emailBody & ¶ & 
   "--- END EMAIL ---" 
]

# 3. Call the Model
# This uses the native v22 script step. 
# Ensure you have run 'Configure AI Account' in your startup script first.
Generate Response from Model [ 
    Account Name: "MyOpenAI_Account" ; 
    Model ID: "gpt-4o" ; 
    Prompt: $prompt ; 
    Target: $jsonResult 
]

# 4. Error Trapping
If [ Get(LastError) ≠ 0 ]
    Set Field [ HelpDesk::AI_Status ; "Error" ]
    Exit Script [ Text Result: "AI Call Failed" ]
End If

# 5. Data Hygiene (JSON Safety)
# Even with strict prompts, LLMs sometimes wrap JSON in Markdown (```json ... ```).
# We must strip these characters before parsing.
If [ Left ( $jsonResult ; 3 ) = "```" ]
    Set Variable [ $jsonResult ; Substitute ( $jsonResult ; ["```json" ; ""] ; ["```" ; ""] ) ]
End If

# 6. Parse and Update
# Now we can safely extract data using native JSON functions.
Set Field [ HelpDesk::Sentiment ; JSONGetElement ( $jsonResult ; "sentiment" ) ]
Set Field [ HelpDesk::Priority ; JSONGetElement ( $jsonResult ; "priority" ) ]
Set Field [ HelpDesk::Category ; JSONGetElement ( $jsonResult ; "category" ) ]
Set Field [ HelpDesk::AI_Summary ; JSONGetElement ( $jsonResult ; "summary" ) ]

# 7. Immediate Escalation Logic
If [ $priority = "Critical" ]
    Perform Script [ "Send SMS to Support Manager" ]
End If

Best Practices for Success

Sanitize Inputs

Users often paste screenshots, base64 images, or weird formatting characters into emails. To save on token costs and prevent parsing errors, ensure you filter the $emailBody to plain text (using GetAsURLEncoded or a Custom Function to strip non-text characters) before sending it to the AI.

Token Limits and Truncation

Do not send the entire email thread if it is 50 pages long. The sentiment is usually found in the most recent message. Truncate the text to the first 1,000 words to keep your API costs low and response times fast.

Human in the Loop

AI is probabilistic, not deterministic. Never let the AI delete a ticket or send an auto-reply without oversight. Always have a "Triage Review" layout where a human can quickly correct the AI if it marks a critical bug as "Low Priority."

Conclusion

By implementing the Inbox Iron Dome, you transform your FileMaker solution from a passive database into an active partner. Your support team stops being data entry clerks and starts being problem solvers. The technology is here, it is native to the platform, and the ROI is immediate.

Further Reading:

The Inbox Iron Dome: Building AI Sentiment Analysis in FileMaker | Jeffrey Henry