Salesforce AI Service Integration

Salesforce AI Service Integration provides powerful AI-powered text processing that you can use in Salesforce Flow to analyze, generate, and transform content intelligently. This AI assistant can understand context from your Salesforce records and provide structured responses that integrate seamlessly with your business processes.

What You Can Do

AI Processing Capabilities

  • Intelligent Content Analysis: Analyze text for sentiment, themes, and key information
  • Content Generation: Create personalized responses, summaries, and documentation
  • Data Extraction: Extract structured information from unstructured text
  • Context-Aware Processing: AI understands your Salesforce record context automatically
  • Custom Response Formats: Get AI responses in exactly the format you need
  • Async Processing: Handle complex AI operations without blocking your workflows

When to Use AI Services

  • Customer Service: Generate personalized responses and analyze customer communications
  • Content Creation: Create marketing copy, product descriptions, and documentation
  • Data Processing: Extract and structure information from documents and forms
  • Decision Support: Get AI insights for business decisions and recommendations
  • Quality Enhancement: Improve existing content with AI suggestions and corrections

AI Processing Parameters Explained

Required Fields

AI Instructions/Prompt
What it is: Instructions telling the AI what to do with your content
Format: Natural language descriptions of the task
Examples:
• "Summarize this case and identify the main issues"
• "Generate a professional email response to this customer inquiry"
• "Extract contact information from this document"
• "Analyze the sentiment of this survey response"
Prompt References: Use {{?PROMPTAPINAME}} to reference pre-configured prompts
• Example: "{{?EMAIL_RESPONSE_PROMPT}}" uses a saved prompt template
Execute Asynchronously
What it is: Whether AI processing should run in the background
Values:
true - Asynchronous
false - Synchronous

Optional Fields

User Message/Data
What it is: The main content for the AI to process
Examples:
• Customer email text: {!$Record.Description}
• Survey responses: {!$Record.Response_Text__c}
• Document content: {!documentText}
Record ID
What it is: Salesforce record ID to provide context to AI
Format: Standard Salesforce record ID (15 or 18 characters)
Benefits:
• AI can access record field values for context
• Enables automatic response schema generation
• Provides relevant business context
Example: {!$Record.Id} or {!caseId}
Example of using the AI Assistant in Flow Builder.

Response Schema Options

You can control AI response format in two ways:

Option 1: Object Field API Names (Recommended)

What it is: Comma-separated list of Salesforce field names
Format: "Field1__c,Field2__c,Field3__c"
Examples:
• Case fields: "Subject, Priority, Description"
• Contact fields: "FirstName, LastName, Email, Phone"
• Custom fields: "Sentiment__c, Key_Issues__c, Recommended_Actions__c"
Benefits: AI response matches your object structure exactly

Option 2: Custom Response Schema

What it is: Custom JSON schema defining response structure
Format: Must follow thfe system's schema wrapper format
When to Use: When you need custom structure not matching Salesforce objects

Example Schema:
{
  "schema": {
    "additionalProperties": false,
    "properties": {
      "contract_type": {
        "description": "Type of contract being analyzed",
        "readOnly": true,
        "type": "string"
      },
      "key_terms": {
        "description": "Important contract terms identified",
        "readOnly": true,
        "type": "string"ƒ
      "risk_level": {
        "description": "Overall risk assessment",
        "readOnly": true,
        "type": "string"
      },
      "missing_clauses": {
        "description": "Important clauses that are missing",
        "readOnly": true,
        "type": "string"
      },
      "recommendations": {
        "description": "Recommended actions or improvements",
        "readOnly": true,
        "type": "string"
      }
    },
    "type": "object"
  },
  "strict": false,
  "name": "contract_analysis"
}
Use Case API Name
What it is: Identifier for tracking different AI use cases
Examples: "customer_support", "lead_qualification", "content_analysis"
Benefits: Enables analytics and use case-specific configurations

Understanding AI Results

Synchronous Processing Results

When Execute Async = false, you get immediate results:
• AI Response: {!aiResults[0].finalResponseMessage}

Asynchronous Processing Results

When Execute Async = true, you get job tracking information:
• Run ID: {!aiResults[0].id}
• Thread ID: {!aiResults[0].thread_id}

You'll need to check for completion using the "SimpleT AI Async Response Awaiter" action.

Working with Asynchronous Processing

Setting Up Async Processing

Step 1: Start AI Processing
Action: SimpleT AI Service
• AI Instructions: {!instructions}
• User Message: {!content}
• Execute Async: true
• Store Output: {!asyncResults}

Step 2: Wait for Processing
Element: Wait
• Duration: 2 minutes (or appropriate interval)

Step 3: Check for Results
Action: SimpleT AI Async Response Awaiter
• Input: {!asyncResults}
• Store Output: {!finalResults}

Step 4: Handle Results
Decision: Check if processing complete
• Condition: {!finalResults[0]} Not Equal "No Content"
• True Path: Process AI results
• False Path: Return to Step 2 (wait longer)

Async Status Messages

"No Content": AI is still processing, check again later
Actual Response: Processing complete, contains final AI results
Error Message: Processing failed, contains error details
Fetching final result from asynchronous AI call.

Practical Examples

Example 1: Customer Email Response Generation

Scenario: Automatically generate professional responses to customer emails
Flow Setup:
• Trigger: Email-to-Case Created
• Variables: customerEmail: {!$Record.Description}, customerName: {!$Record.Contact.Name}
AI Processing:
• AI Instructions: "Generate a professional, empathetic response to this customer email. Be helpful and provide next steps."
• User Message: "Customer: {!customerName}\\nEmail: {!customerEmail}"
• Record ID: {!$Record.Id}
• Target Field API Names: "Response_Draft__c,Tone__c,Priority__c,Next_Steps__c"
• Execute Async: false
Actions:
• Update case with AI-generated response fields
• Create task for agent to review and send response
• Log AI processing for quality tracking

Example 2: Lead Qualification and Scoring

Scenario: Analyze inbound leads and provide qualification scores
Flow Setup:
• Trigger: Lead Created from Web Form
• Variables: leadInfo: {!$Record.Description}, companyName: {!$Record.Company}
AI Processing:
• AI Instructions: "{{?LEAD_QUALIFICATION_PROMPT}}"
• User Message: "Lead Information: {!leadInfo}\\nCompany: {!companyName}"
• Record ID: {!$Record.Id}
• Target Field API Names: "AI_Score__c,Qualification_Notes__c,Recommended_Actions__c"
• Execute Async: false
Decision Logic:
• High Score (>80): Route to senior sales rep
• Medium Score (50-80): Standard qualification process
• Low Score (<50): Marketing nurture campaign

Example 3: Document Analysis (Async)

Scenario: Analyze uploaded contracts for key terms and risks
Flow Setup:
• Trigger: Contract Document Uploaded
• Variables: documentContent: {!$Record.Document_Text__c}
AI Processing:
• AI Instructions: "Analyze this contract and identify key terms, potential risks, and missing clauses"
• User Message: {!documentContent}
• Custom Response Schema: Contract analysis schema with contract_type, key_terms, risk_level, missing_clauses, recommendations
• Execute Async: true
Async Monitoring:
• Check Status: SimpleT AI Async Response Awaiter
• Route based on risk level and generate legal review tasks

Best Practices

Writing Effective AI Instructions

Be Specific: Clear, detailed instructions help AI understand exactly what you need
Provide Context: Include relevant background information
Use Complete Information: Give AI all the details it needs
Ask Clear Questions: Frame requests as specific questions or tasks
Good Instructions:
"Analyze this customer support case and provide: 1) A brief summary, 2) Identified root cause, 3) Recommended resolution steps, 4) Estimated effort level (Low/Medium/High)"
Poor Instructions:
"Analyze this case"

Troubleshooting Guide

AI Processing Not Working:
• Check Instructions: Ensure AI instructions are clear and specific
• Verify Input Data: Confirm user message contains expected content
• Review Configuration: Validate all required parameters are provided
• Test Isolation: Test with simple, known content first
Poor AI Results Quality:
• Improve Instructions: Make instructions more specific and detailed
• Provide More Context: Include additional relevant information
• Adjust Schema: Ensure response schema matches desired output
• Test Variations: Try different instruction phrasings