Integrate Your AI Agent

Integrate Your AI Agent #

Once your AI Agent is trained and tested, it's time to integrate it with your communication channels and escalation systems. This allows your agent to handle real customer conversations across live chat, SMS, and WhatsApp, with seamless handoffs to human agents when needed.

Communication Channels #

Support Unicorn allows your AI Agent to respond across multiple channels. Each channel can be configured independently with its own settings and behavior.

Live Chat Widget #

Embed a chat widget on your website for real-time customer support.

Setup Steps:

  1. Create a Channel

    • Navigate to your agent's "Channels" tab
    • Click "Add Channel"
    • Select "Live Chat" as the channel type
  2. Configure the Widget

    • Widget Name: Internal name for reference (e.g., "Homepage Chat")
    • Domains: (Optional) Restrict to specific domains
    • Welcome Message: First message customers see
    • Placeholder Text: Input field placeholder
    • Theme Color: Match your brand
  3. Get the Embed Code
    html
    <script>
    (function(w,d,s,o,f,js,fjs){
    w['SupportUnicornWidget']=o;w[o]=w[o]||function(){
    (w[o].q=w[o].q||[]).push(arguments)};
    js=d.createElement(s),fjs=d.getElementsByTagName(s)[0];
    js.id=o;js.src=f;js.async=1;fjs.parentNode.insertBefore(js,fjs);
    }(window,document,'script','$supportUnicorn','https://supportunicorn.com/sdk.js'));
    $supportUnicorn('init', {widgetId: 'wid_abc123'});
    </script>

  4. Install on Your Website

    • Copy the code snippet
    • Paste before the closing </body> tag
    • Deploy your website changes
  5. Test the Widget

    • Visit your website
    • Click the chat bubble
    • Send a test message
    • Verify AI responses appear

Widget Features:

  • Persistent Sessions: Conversations persist across page loads
  • User Identification: Identify users with email, name, avatar
  • Custom Attributes: Add metadata (account type, user ID, etc.)
  • Multi-language: Automatically detects browser language
  • Mobile Responsive: Works on all devices
  • Offline Mode: Shows offline message outside business hours

Advanced Configuration:

// Identify the user
$supportUnicorn('setUser', 'user@example.com', {
  name: 'Jane Doe',
  email: 'user@example.com',
  avatar_url: 'https://example.com/avatar.jpg'
});

// Add custom attributes
$supportUnicorn('setCustomAttributes', {
  plan: 'pro',
  account_id: 'acc_123',
  signup_date: '2024-01-15'
});

// Customize colors
$supportUnicorn('setPrimaryColor', '#6366f1');

// Listen for events
$supportUnicorn('on', 'conversation:started', function() {
  console.log('User started a conversation');
});

Widget Customization:

  • Primary color (buttons, header)
  • Position (bottom-right, bottom-left)
  • Bubble visibility (show/hide)
  • Welcome messages
  • Offline messages
  • GDPR consent banner

SMS Channel (Twilio) #

Enable customer support via SMS text messages.

Prerequisites:
- Active Twilio account
- Twilio phone number (SMS-enabled)
- Account SID and Auth Token

Setup Steps:

  1. Create SMS Channel

    • Go to agent's "Channels" tab
    • Click "Add Channel"
    • Select "SMS (Twilio)"
  2. Enter Twilio Credentials

    • Account SID: From Twilio console
    • Auth Token: From Twilio console (keep secure)
    • Phone Number: Your Twilio number (E.164 format: +1234567890)
    • Display Name: (Optional) Name shown to customers
  3. Configure Webhook

    • Copy the webhook URL provided
    • In Twilio console, go to your phone number settings
    • Under "Messaging", set webhook URL for incoming messages
    • Set method to POST
  4. Test the Integration

    • Send an SMS to your Twilio number
    • Verify message appears in Slack
    • Send a reply from Slack
    • Verify customer receives the SMS

SMS Considerations:

  • Message Length: SMS is limited to 160 characters

    • AI responses may be truncated or split into multiple messages
    • Configure system prompt to keep responses concise for SMS
  • Costs: Twilio charges per message sent/received

    • Inbound: ~$0.0075/message
    • Outbound: ~$0.0079/message
    • Long codes support standard SMS volumes
  • Regulations: Comply with TCPA and carrier guidelines

    • Obtain consent before sending marketing messages
    • Provide opt-out instructions (e.g., "Reply STOP to unsubscribe")
    • Support standard keywords (STOP, HELP)

SMS Best Practices:

  • Keep AI responses short and scannable
  • Use line breaks for readability
  • Include links sparingly (use URL shorteners)
  • Test delivery across carriers
  • Monitor for delivery failures

WhatsApp Channel (Twilio) #

Provide support through WhatsApp Business.

Prerequisites:
- Twilio account with WhatsApp enabled
- Approved WhatsApp Business profile
- WhatsApp-enabled phone number from Twilio

Setup Steps:

  1. Apply for WhatsApp Access

    • In Twilio, request WhatsApp Business API access
    • Complete business verification
    • Set up WhatsApp Business Profile
    • Get approval (usually 1-2 weeks)
  2. Create WhatsApp Channel

    • Navigate to agent's "Channels" tab
    • Click "Add Channel"
    • Select "WhatsApp (Twilio)"
  3. Enter Configuration

    • Account SID: Your Twilio Account SID
    • Auth Token: Your Twilio Auth Token
    • WhatsApp Number: WhatsApp-enabled number (e.g., whatsapp:+14155238886)
    • Display Name: Business name shown to customers
  4. Configure Webhook

    • Copy the webhook URL
    • In Twilio WhatsApp settings, set incoming message webhook
    • Set method to POST
  5. Configure Message Templates

    • WhatsApp requires pre-approved templates for business-initiated messages
    • Create templates in Twilio console
    • Get them approved by WhatsApp
    • Use approved templates for outbound broadcasts

WhatsApp Features:

  • Rich Media: Send images, documents, location
  • Read Receipts: See when messages are read
  • Typing Indicators: Show when AI is responding
  • Templates: Pre-approved message templates for broadcasts
  • 24-Hour Window: Free-form messaging within 24 hours of customer message

WhatsApp Restrictions:

  • Template Requirement: Business-initiated messages must use approved templates
  • Rate Limits: Messaging tier determines max daily conversations
    • Tier 1: 1,000 conversations/day
    • Tier 2: 10,000 conversations/day (after proving good quality)
  • Quality Rating: Poor quality can limit or suspend your number
  • Content Policies: Strict content and spam policies

WhatsApp Best Practices:

  • Use rich media appropriately (product images, guides)
  • Respect 24-hour messaging window
  • Maintain high quality rating (low blocks/reports)
  • Use templates wisely for broadcasts
  • Provide clear opt-out instructions

Channel Management #

Activating/Deactivating Channels:

Toggle channels on/off without deleting configuration:
- Active: AI responds to messages on this channel
- Inactive: Channel paused, no AI responses

Use Cases for Deactivation:
- Temporarily pause during maintenance
- Test configuration changes safely
- Seasonal adjustments (disable when team is available)

Deleting Channels:

Permanently remove a channel and its configuration:
- All channel settings are lost
- Webhook connections are broken
- Active conversations are closed
- Cannot be undone

Multiple Channels:

Run multiple channels of the same type:
- Different chat widgets for different websites
- Multiple phone numbers for different regions
- Separate WhatsApp numbers for different departments

Each channel can route to the same or different Slack channels for team responses.


Escalation Paths #

Escalations allow your AI Agent to seamlessly hand off conversations to human agents or external systems when needed.

When to Escalate #

Configure when the AI should escalate:

Confidence-Based:
- AI confidence score below threshold (default: 0.5)
- Unable to find relevant information
- Ambiguous or unclear customer request

Intent-Based:
- Customer explicitly requests human agent
- "Can I talk to a person?"
- "I need to speak with someone"
- "Connect me to a human"

Sentiment-Based:
- Negative sentiment detected (anger, frustration)
- Escalating emotions mid-conversation
- Complaint or dissatisfaction indicators

Topic-Based:
- Specific topics flagged for human handling
- Refund requests
- Billing disputes
- Technical support issues
- Complaints or legal matters

Time-Based:
- Conversation duration exceeds threshold
- Too many back-and-forth exchanges without resolution
- Customer waiting too long for human response

Slack Escalation #

Route conversations to Slack channels for human team members to handle.

How It Works:

  1. Escalation Triggered

    • Based on configured rules above
    • AI detects need for human assistance
  2. Slack Notification

    • New message posted in designated Slack channel
    • Includes conversation history
    • Shows customer information and context
    • Provides action buttons (Take Over, Close, Re-enable AI)
  3. Human Takes Over

    • Team member clicks "Take Over" in Slack
    • AI automatically disabled for this conversation
    • Human responses sent to customer
    • Full bidirectional communication
  4. Resolution

    • Team member handles the conversation
    • Marks as resolved when done
    • Conversation closed or archived

Slack Configuration:

  • Escalation Channel: Which Slack channel receives escalations
  • Notification Format: Mention @channel, specific user, or silent
  • Escalation Message: Custom message to customer during handoff
    • "Let me connect you with our team..."
    • "I'm transferring you to a specialist..."

Slack Thread Management:

All messages in a conversation appear in a single Slack thread:
- Easy to follow conversation history
- Team can collaborate in thread
- Context is never lost
- Attachments and rich media included

Zendesk Escalation #

Create Zendesk support tickets automatically when escalating.

Prerequisites:
- Zendesk account (Professional plan or higher)
- API token from Zendesk
- Zendesk subdomain (e.g., yourcompany.zendesk.com)

Setup Steps:

  1. Connect Zendesk

    • Navigate to agent's "Escalations" tab
    • Click "Add Escalation"
    • Select "Zendesk"
  2. Enter Credentials

    • Subdomain: Your Zendesk subdomain
    • Email: Your Zendesk admin email
    • API Token: Generate in Zendesk settings
    • Test connection
  3. Configure Ticket Settings

    • Default Priority: Normal, High, Urgent
    • Default Type: Question, Incident, Problem, Task
    • Tags: Auto-apply tags (e.g., "ai-escalation")
    • Assignee: Auto-assign to group or individual
    • Custom Fields: Map conversation data to Zendesk fields

What Gets Created:

When escalating to Zendesk:
- New ticket with conversation history
- Customer email as requester
- Subject line auto-generated from first message
- All messages included in ticket comments
- Metadata as tags (source channel, AI confidence, etc.)

Bidirectional Sync:

  • Customer replies appear as ticket updates
  • Agent responses in Zendesk sent back to customer
  • Ticket status synced with conversation status
  • Closed tickets close conversations

Zendesk Escalation Rules:

Configure when to create tickets vs route to Slack:
- High priority → Zendesk
- Simple questions → Slack
- After hours → Create ticket for next day
- VIP customers → Both Zendesk and Slack notification

Custom Platform Escalation #

Integrate with any external system via webhook.

Supported Platforms:

While we provide native integrations for Slack and Zendesk, you can connect to:
- Jira (issue tracking)
- Salesforce (CRM cases)
- HubSpot (tickets)
- Freshdesk
- Intercom
- Custom internal systems

Setup Custom Escalation:

  1. Add Escalation

    • Go to "Escalations" tab
    • Select "Custom Platform"
  2. Configure Webhook

    • Webhook URL: Your endpoint
    • HTTP Method: POST (recommended)
    • Headers: Authentication, content-type
    • Payload Template: JSON structure
  3. Payload Mapping

Map conversation data to your system's API:

{
  "conversation_id": "{{conversation.id}}",
  "customer": {
    "email": "{{customer.email}}",
    "name": "{{customer.name}}"
  },
  "messages": {{messages_json}},
  "metadata": {
    "channel": "{{channel.type}}",
    "ai_confidence": {{ai_confidence}},
    "escalation_reason": "{{escalation_reason}}"
  },
  "created_at": "{{timestamp}}"
}
  1. Response Handling

Your webhook should return:
json
{
"success": true,
"ticket_id": "TICKET-123",
"url": "https://yoursystem.com/tickets/TICKET-123"
}

This allows Support Unicorn to:
- Link conversation to external ticket
- Show ticket URL in Slack thread
- Track escalation status

Authentication Methods:
- API Key (header or query parameter)
- Bearer Token
- Basic Authentication
- OAuth 2.0 (contact support for setup)

Error Handling:

Configure fallback behavior if webhook fails:
- Retry with exponential backoff
- Escalate to Slack as backup
- Email notification to team
- Log for manual handling

Testing Escalations #

Before going live, test each escalation path:

Test Connection:
- Use the built-in "Test Connection" button
- Verifies API credentials
- Checks network connectivity
- Validates payload formatting

Test Escalation Flow:

  1. Start a test conversation with your agent
  2. Trigger escalation (low confidence question, ask for human)
  3. Verify escalation appears in target system
  4. Check all data mapped correctly
  5. Test bidirectional communication
  6. Confirm resolution flow works

Common Issues:

  • Authentication failures: Double-check API keys/tokens
  • Network errors: Verify URLs and firewall rules
  • Payload errors: Check JSON formatting and required fields
  • Permission errors: Ensure API user has proper permissions

Multi-Channel Strategy #

Routing Rules #

Configure which conversations go where:

By Channel Type:
- Live chat → Slack #support channel
- SMS → Slack #sms-support channel
- WhatsApp → Slack #whatsapp-support

By Customer Attributes:
- VIP customers → Slack + Zendesk (high priority)
- Free tier users → AI-only (no Slack notification)
- Enterprise accounts → Direct to account manager

By Time:
- Business hours → Slack (humans available)
- After hours → AI-only + create Zendesk ticket
- Weekends → AI + email summary to team

By Topic:
- Billing questions → Escalate to billing specialist
- Technical issues → Create Jira ticket + Slack notification
- Sales inquiries → CRM (Salesforce/HubSpot)

Unified Conversations #

Customers identified across channels see unified experience:

Example Flow:
1. Customer starts conversation via live chat
2. Provides email address
3. Later texts your SMS number
4. System recognizes same customer
5. Conversation history maintained
6. Context preserved across channels

Customer Identification:
- Email address (primary)
- Phone number
- Custom user ID
- Session tracking (cookies for web)


Go-Live Checklist #

Before deploying your AI Agent to production:

Channels:
- [ ] All channels configured and tested
- [ ] Webhooks properly set up
- [ ] Widget installed on website (if using live chat)
- [ ] Test conversation on each channel
- [ ] Twilio balance funded (if using SMS/WhatsApp)

Escalations:
- [ ] At least one escalation path configured
- [ ] Escalation rules tested
- [ ] Team trained on handling escalated conversations
- [ ] Slack notifications working
- [ ] External system integrations tested

AI Configuration:
- [ ] Knowledge base comprehensive and accurate
- [ ] System prompt finalized
- [ ] AI mode selected (Auto/Hybrid/Fallback)
- [ ] Confidence thresholds configured
- [ ] Actions tested (if applicable)

Team Readiness:
- [ ] Support team trained on new workflow
- [ ] Escalation procedures documented
- [ ] Slack channels organized
- [ ] Response time expectations set

Monitoring:
- [ ] Billing credits sufficient
- [ ] Alert thresholds configured
- [ ] Team has access to analytics dashboard


Next Steps #

Your AI Agent is now integrated and ready to handle customer conversations:

  1. Analyze Performance - Monitor conversations and metrics
  2. Review Billing - Track credit usage and manage payments
  3. Continuous Improvement - Iterate based on real-world usage

FAQ #

Can I use multiple escalation paths simultaneously? #

Yes! You can configure both Slack and Zendesk escalations, or Slack + custom webhook. When escalation triggers, all configured paths are activated.

What happens if a webhook fails? #

Support Unicorn will retry failed webhooks (3 attempts with exponential backoff). If all retries fail, you'll receive a notification and the escalation will fall back to Slack if configured.

Can I change channels after conversations start? #

Yes, you can modify channel configurations at any time. Active conversations continue on their original channel, but new conversations use the updated settings.

How do I handle conversations across multiple channels? #

Enable customer identification via email or phone number. Support Unicorn automatically links conversations from the same customer, providing unified conversation history.

What if customers message multiple channels simultaneously? #

Each channel creates a separate conversation initially. Once the customer is identified (via email, phone, or ID), conversations can be linked or merged in the dashboard.

Can I temporarily disable AI for specific conversations? #

Yes! In the Slack thread for any conversation, use the "Disable AI" button. The conversation becomes human-only until you re-enable AI or close it.