Train Your AI Agent

Train Your AI Agent #

Training your AI Agent is the process of building its knowledge base so it can accurately answer customer questions. Support Unicorn provides multiple ways to add knowledge, configure custom actions, and set up automated workflows.

Knowledge Sources #

Your AI Agent's knowledge base can be built from four types of sources. Each source type is automatically processed, embedded, and indexed for semantic search.

File Data Sources #

Upload documents directly to your agent's knowledge base.

Supported File Types:
- PDF: Product manuals, guides, reports
- DOCX: Microsoft Word documents
- TXT: Plain text files
- Markdown: Documentation files
- PPTX: PowerPoint presentations
- HTML: Web pages and help articles

File Size Limit: 50 MB per file

How It Works:

  1. Upload: Select files from your computer or drag and drop
  2. Processing: Files are sent to Unstructured.io for parsing and chunking
  3. Embedding: Each chunk is converted to vector embeddings via OpenAI
  4. Indexing: Embeddings are stored in Turbopuffer for instant semantic search
  5. Ready: The content is immediately available to your AI Agent

Processing Time: Typically 1-5 minutes depending on file size and complexity

Chunking Strategies:
- Auto: Intelligent chunking based on document structure (recommended)
- Fast: Quick processing with basic chunking
- Hi-Res: More accurate with OCR for scanned documents

Best Practices:
- Upload source documents (not exports or copies)
- Ensure PDFs are text-based (not scanned images)
- Keep files focused on specific topics
- Remove unnecessary boilerplate or footers
- Update files when content changes

Managing Files:
- View all uploaded files in the "Sources" tab
- See processing status (processing, completed, failed)
- Delete files that are outdated or incorrect
- Re-upload updated versions (old version is replaced)

Text Data Sources #

Add custom text content directly without uploading files.

Use Cases:
- Company policies that change frequently
- Quick answers that don't exist in documentation
- Temporary information (holiday hours, promotions)
- Internal procedures and guidelines
- Supplementary context for AI responses

How to Add Text Sources:

  1. Navigate to your agent's "Sources" tab
  2. Click "Add Text Source"
  3. Enter a title (for your reference)
  4. Write or paste the content
  5. Save - the text is immediately indexed

Formatting Tips:
- Use clear headings to structure content
- Break up long text into paragraphs
- Use bullet points for lists
- Include relevant keywords naturally
- Be specific and factual

Example Text Source:

Title: Refund Policy

We offer a 30-day money-back guarantee on all purchases.

To request a refund:
1. Email support@example.com with your order number
2. Provide reason for refund (optional but helpful)
3. We'll process your refund within 5-7 business days

Refunds are issued to the original payment method.

Exceptions:
- Digital products: 14-day guarantee only
- Sale items: Final sale, no refunds
- Custom orders: No refunds unless defective

Benefits:
- Instant updates (no file upload/processing)
- Easy to maintain and edit
- Perfect for frequently changing information
- Good for testing new content

Website Data Sources #

Crawl and index content from your website or help center.

How It Works:

  1. Enter URL: Provide your website or help center URL
  2. Configure: Set crawl depth and page limits
  3. Crawl: System visits pages and extracts text content
  4. Process: Content is chunked and embedded
  5. Index: Made available to your AI Agent

Crawl Settings:

  • Starting URL: Homepage or specific section
  • Max Pages: Limit number of pages (default: 100)
  • Depth: How many links deep to follow (default: 3)
  • Respect robots.txt: Follow crawling guidelines (recommended)

What Gets Indexed:
- Main content text
- Headings and subheadings
- Lists and tables
- Meta descriptions

What's Excluded:
- Navigation menus
- Footers and headers
- Advertisements
- Comments and social media widgets

Best Practices:
- Start with specific sections (e.g., /help, /docs)
- Exclude irrelevant pages (blog, marketing)
- Re-crawl periodically to get updates
- Monitor for broken links or errors

Limitations:
- Cannot crawl password-protected pages
- JavaScript-heavy SPAs may not render fully
- Some dynamic content may be missed

Manual Trigger:
Click "Crawl Now" to refresh the content from your website anytime.

Question & Answer Pairs (Q&A) #

Add specific question-answer pairs for common customer inquiries.

When to Use Q&A:
- You know the exact questions customers ask
- Answers are short and specific
- Faster than creating full documentation
- Testing AI responses on specific topics

Creating Q&A Pairs:

  1. Go to "Sources" → "Q&A"
  2. Click "Add New Q&A"
  3. Enter the question exactly as customers ask it
  4. Write the answer (supports rich text formatting)
  5. Save - indexed immediately

Rich Text Editor:
- Bold and italic formatting
- Bullet and numbered lists
- Links to external resources
- Headings for structure

Example Q&A Pairs:

Q: What are your business hours?
A: We're open Monday-Friday 9 AM to 6 PM EST, and Saturday 10 AM to 4 PM EST. We're closed on Sundays and major holidays.

Q: Do you ship internationally?
A: Yes! We ship to over 50 countries worldwide. International shipping takes 7-14 business days. See our shipping page for rates and countries.

Q: How do I reset my password?
A: Click "Forgot Password" on the login page, enter your email address, and we'll send you a reset link. The link expires in 24 hours.

Best Practices:
- Write questions as customers would ask them
- Include variations (abbreviations, synonyms)
- Keep answers concise but complete
- Link to detailed documentation when appropriate
- Test the Q&A in the agent testing interface

Bulk Import:
Have many Q&A pairs? Export from your existing FAQ system as CSV and import in bulk.


Actions #

Actions allow your AI Agent to perform tasks beyond just answering questions. When properly configured, your agent can look up information, create records, and trigger external systems.

Stripe Actions #

Integrate with Stripe to enable AI-powered billing assistance.

Available Stripe Actions:

1. Lookup Customer
- Find customer records by email
- Display subscription status
- Show payment history
- Retrieve account balance

2. Create Invoice
- Generate invoices on demand
- Apply discounts or credits
- Send invoice emails automatically
- Track invoice status

3. Process Refund
- Issue full or partial refunds
- Automatic notification to customer
- Update account balance
- Audit trail in Stripe dashboard

4. Update Subscription
- Change subscription plan
- Update quantity or pricing
- Schedule cancellation
- Apply proration

Setup:

  1. Navigate to agent "Actions" tab
  2. Click "Add Stripe Actions"
  3. Enter your Stripe API key (from Stripe dashboard)
  4. Select which actions to enable
  5. Configure permissions and limits
  6. Test each action before going live

Security Considerations:
- Use restricted API keys (limit permissions)
- Set monetary limits (max refund amount)
- Require human approval for large transactions
- Monitor action logs regularly

Example Conversation:

Customer: "I need a refund for order #12345"
AI Agent: Looks up order, verifies eligibility
AI Agent: "I can process that refund for $49.99 to your original payment method. It will appear in 5-7 business days. Should I proceed?"
Customer: "Yes please"
AI Agent: Processes refund via Stripe API
AI Agent: "Done! Your refund has been processed. Confirmation email sent to you@email.com."

Custom HTTP Actions #

Connect your AI Agent to any external API or webhook.

Use Cases:
- Look up order status in your e-commerce system
- Check inventory availability
- Create support tickets in Zendesk/Jira
- Update CRM records (Salesforce, HubSpot)
- Schedule appointments
- Trigger automation workflows

Configuration:

  1. Action Name: Descriptive name (e.g., "Check Order Status")
  2. HTTP Method: GET, POST, PUT, DELETE
  3. Endpoint URL: Your API endpoint
  4. Headers: Authentication, content-type, etc.
  5. Request Body: Template with variables
  6. Response Mapping: How to parse the response

Authentication Methods:
- API Key (header or query parameter)
- Bearer Token
- Basic Auth
- OAuth 2.0 (coming soon)

Example: Order Lookup Action

{
  "name": "Lookup Order",
  "method": "GET",
  "url": "https://api.yourstore.com/orders/{{order_id}}",
  "headers": {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  "response_mapping": {
    "status": "$.status",
    "tracking_number": "$.tracking.number",
    "estimated_delivery": "$.tracking.estimated_delivery"
  }
}

Testing Actions:
Use the built-in action tester to verify:
- API connectivity
- Authentication
- Request formatting
- Response parsing
- Error handling

Error Handling:
Configure what happens when actions fail:
- Show generic error to customer
- Escalate to human agent
- Retry automatically
- Log for later review


Workflows #

Workflows automate multi-step processes and allow your AI Agent to trigger sequences of actions based on conversation events.

What Are Workflows? #

A workflow is a series of automated steps that execute when specific conditions are met during a conversation.

Example Workflow: New Customer Onboarding

Trigger: Customer says "I'm new here"

Steps:
1. Send welcome message with resources
2. Create customer record in CRM
3. Subscribe to newsletter via email API
4. Schedule follow-up check-in for 3 days
5. Notify sales team via Slack

Workflow Triggers #

Choose what starts your workflow:

Conversation-Based Triggers:
- Message contains specific keywords
- Customer asks about particular topic
- Sentiment analysis detects frustration
- Conversation tagged with specific label

Time-Based Triggers:
- Customer inactive for X minutes
- Business hours start/end
- Scheduled follow-up time reached

Action-Based Triggers:
- After completing specific action (e.g., refund processed)
- When action fails
- When escalating to human

Workflow Steps #

Each workflow can include multiple types of steps:

1. Send Message
- Automated message to customer
- Can include dynamic variables
- Supports rich formatting

2. Execute Action
- Run Stripe action
- Call custom HTTP endpoint
- Update internal records

3. Update Conversation
- Add tags or labels
- Change priority
- Assign to specific team/person
- Close conversation

4. Wait/Delay
- Pause workflow for specified time
- Wait for customer response
- Business hours only

5. Conditional Branch
- If/then logic
- Different paths based on variables
- Check API responses

6. Notify Team
- Send Slack notification
- Email notification
- Webhook to external system

Creating a Workflow #

  1. Navigate to agent "Workflows" tab
  2. Click "Create New Workflow"
  3. Name your workflow
  4. Define trigger conditions
  5. Add workflow steps in sequence
  6. Configure each step
  7. Test with sample conversations
  8. Activate when ready

Example Workflows #

Escalation Workflow:

Trigger: AI confidence score < 0.5
Steps:
1. Send message: "Let me connect you with a specialist"
2. Update conversation: Add tag "needs_human"
3. Notify team: Slack channel #support
4. Wait: 2 minutes for human response
5. If no response: Send "We'll get back to you within 1 hour"

Order Issue Workflow:

Trigger: Message contains "order problem" OR "item missing"
Steps:
1. Execute action: Lookup order by email
2. If order found:
- Send order details to customer
- Ask: "Which item is the issue?"
3. If order not found:
- Ask for order number
- Tag conversation: "order_lookup_needed"

Off-Hours Workflow:

Trigger: New conversation outside business hours
Steps:
1. Send message: "Thanks for reaching out! We're currently offline but will respond when we're back at 9 AM EST."
2. If message contains "urgent":
- Notify on-call team via SMS
- Escalate immediately
3. Else:
- Schedule for review at 9 AM
- Add to priority queue

Workflow Best Practices #

Start Simple
- Begin with 2-3 step workflows
- Test thoroughly before adding complexity
- Monitor performance before scaling

Be Specific with Triggers
- Use multiple conditions to reduce false positives
- Test trigger patterns with real conversations
- Adjust based on actual usage

Handle Errors Gracefully
- Always have fallback steps
- Notify team when workflows fail
- Don't leave customers hanging

Monitor and Iterate
- Review workflow execution logs
- Track success/failure rates
- Optimize based on data


System Prompts #

The system prompt defines your AI Agent's personality, tone, and behavior guidelines.

Default System Prompt:

You are a helpful customer support agent. Answer questions accurately based on the knowledge base provided. Be polite, professional, and concise. If you don't know the answer, say so and offer to connect the customer with a human agent.

Customizing Your System Prompt:

Include directives for:
- Tone: Formal, casual, friendly, professional
- Length: Concise or detailed responses
- Format: Use bullets, numbered lists, paragraphs
- Brand Voice: Specific phrases or communication style
- Limitations: What not to do or discuss
- Escalation: When to involve humans

Example Custom Prompts:

E-commerce Store:

You are Emma, a friendly shopping assistant for [Brand Name]. Help customers find products, answer questions about orders, shipping, and returns. Always be enthusiastic and helpful. Use emojis sparingly. If customers are unhappy, empathize and resolve their issue or escalate to our support team. Never make promises about shipping dates or inventory without checking first.

B2B SaaS:

You are a technical support specialist for [Product Name]. Provide accurate, detailed answers to technical questions using the knowledge base. Use technical terminology when appropriate, but explain complex concepts clearly. For bug reports or feature requests, gather details and create a support ticket. Escalate to engineering for critical issues.

Healthcare:

You are a patient support assistant for [Clinic Name]. Help with appointment scheduling, general information, and frequently asked questions. Always be professional, empathetic, and HIPAA-compliant. Never provide medical advice. For medical questions, health concerns, or prescription issues, immediately connect the patient with a healthcare professional.

Testing Your Prompts:
Use the Test interface to see how different prompts affect AI responses.


Next Steps #

Once you've trained your AI Agent with knowledge sources, actions, and workflows:

  1. Test Your Agent - Verify responses before going live
  2. Integrate Channels - Connect communication channels
  3. Analyze Performance - Monitor and improve over time

FAQ #

How much content should I add to my knowledge base? #

Start with 10-20 key documents covering your most common questions. It's better to have highly accurate, focused content than huge volumes of information. Expand based on what customers actually ask.

How long does it take to process uploaded files? #

Most files process in 1-5 minutes. Large PDFs or presentations may take up to 15 minutes. You'll see processing status in the Sources tab.

Can I update content without deleting and re-uploading? #

For files, yes - just upload the new version with the same filename. For text sources and Q&A pairs, edit them directly. Website content updates when you trigger a new crawl.

What happens if I have conflicting information in different sources? #

The AI uses the most relevant source based on semantic similarity to the question. If sources conflict, the AI may surface both answers or prioritize based on recency. Best practice: keep your knowledge base consistent.

How do I know which sources the AI is using for responses? #

In the conversation analytics, you can see which knowledge base chunks were retrieved for each AI response. This helps you understand what content is being used and identify gaps.

Can actions make changes without asking the customer first? #

You configure this per action. Some actions (like lookups) don't require confirmation. Others (like refunds) should always ask for confirmation first. Use the action settings to control this behavior.