customer-support-bot avatar

customer-support-bot

AI support agent handling customer inquiries with knowledge base integration and intelligent escalation

customer-supporthelpdeskknowledge-baseticketingmulti-channeldm-enabledgroup-chatescalation
by openhatchabout 2 months ago

Quick Start

# Install and run
openhatch run @openhatch/customer-support-bot

Template Contents

Browse files before installing this template.

Loading template files…

About

Customer Support Bot

An intelligent AI support agent that handles customer inquiries across DMs and group channels with knowledge base integration and ticket escalation.

Overview

The Customer Support Bot is a versatile AI assistant designed to provide 24/7 customer support across multiple messaging platforms. It combines a searchable knowledge base, conversation memory, and intelligent escalation to deliver professional, consistent support experiences.

Unlike simple chatbots, this agent:

  • Learns from interactions — Builds institutional knowledge over time
  • Handles multiple channels — DMs for private issues, groups for public Q&A
  • Escalates intelligently — Knows when to loop in human support
  • Maintains context — Remembers customer history and preferences
  • Provides accurate answers — Searches knowledge base before responding

Key Features

🎯 Multi-Channel Support

  • DM sessions: Private 1:1 support with full conversation history
  • Group channels: Public Q&A in Discord/Telegram servers
  • Pairing mode: Approve DM users before engagement (prevents spam)

📚 Knowledge Base Integration

  • Pre-seeded with your product/service documentation
  • Semantic search over knowledge articles
  • Updates knowledge base as new issues are resolved
  • Cites sources in responses

🎫 Smart Escalation

  • Recognizes when issues require human intervention
  • Creates structured escalation reports
  • Tracks unresolved issues in memory/escalations.json
  • Notifies operator of urgent cases

💬 Natural Conversations

  • Warm, professional tone (not robotic)
  • Asks clarifying questions when needed
  • Provides step-by-step troubleshooting
  • Follows up on resolved issues

🔒 Privacy & Security

  • Sandboxed DM/group sessions (no shell access)
  • Customer data stored separately per user
  • Option to anonymize transcripts
  • Secure credential handling

Quick Start

1. Install via Hatchery

hatchery run @openclaw/customer-support-bot my-support-bot

2. Configure Environment

Copy .env.example to .env and configure:

# Required: Anthropic API key
ANTHROPIC_API_KEY=sk-ant-xxx

# Required: Messaging platform credentials
# Choose one or more:
TELEGRAM_BOT_TOKEN=123456:ABC-DEF...    # From @BotFather
DISCORD_BOT_TOKEN=MTk4NjIyNDgzNDc...   # From Discord Developer Portal
SLACK_BOT_TOKEN=xoxb-...                # From Slack App settings

# Optional: Business hours (for escalation urgency)
BUSINESS_HOURS_START=09:00
BUSINESS_HOURS_END=17:00
BUSINESS_TIMEZONE=America/New_York

# Optional: Escalation webhook
ESCALATION_WEBHOOK_URL=https://hooks.slack.com/services/xxx

3. Customize Knowledge Base

Edit MEMORY.md to include your product's knowledge base:

## Product Knowledge

### How to reset password
1. Visit https://yourapp.com/reset
2. Enter your email address
3. Check email for reset link (valid 1 hour)
4. Create new password (min 8 characters)

### Common Error Codes
- **E101**: Database connection failed → Check internet connection
- **E202**: Invalid API key → Regenerate key in dashboard
...

4. Start the Agent

cd ~/.hatchery/instances/my-support-bot
docker-compose up -d

5. Approve DM Users (Pairing Mode)

When a new user messages the bot, you'll receive a pairing request in your main session. Reply:

Approve DM access for @username

Configuration

Session Policies

DM Policy (default: pairing):

  • pairing: Require operator approval for each new DM user (recommended)
  • open: Accept DMs from anyone (use for public bots)

Group Policy:

  • Responds only when @mentioned (prevents spam)
  • Read-only access (cannot modify knowledge base from groups)
  • No access to customer-specific data

Escalation Triggers

Edit AGENTS.md to customize when the bot escalates:

## When to Escalate
1. **Immediate**: Security issues, data breaches, payment failures
2. **Urgent**: Service outages affecting multiple users
3. **Normal**: Feature requests, complex technical issues
4. **Low**: General feedback, questions for product team

Response Templates

Add common response templates to memory/templates.md:

### Refund Request Template
Thank you for contacting support. I've escalated your refund request to our billing team.

Reference number: {TICKET_ID}
Expected response: 1-2 business days

Is there anything else I can help with?

Usage Examples

Example 1: Simple Q&A (Group Chat)

User: @SupportBot How do I export my data?

Bot: You can export your data from Settings → Privacy → Export Data.

The export includes:
• All your posts and comments
• Profile information
• Account settings

The export is delivered via email as a .zip file within 24 hours.

Need help with anything specific in the export process?

Example 2: Troubleshooting (DM)

User: I'm getting error E202 when I try to connect

Bot: Error E202 means your API key is invalid or expired. Let's fix that:

1. Go to https://yourapp.com/dashboard/api
2. Click "Regenerate API Key"
3. Copy the new key
4. Update it in your app settings

⚠️ Important: The old key will stop working immediately after regeneration.

Did that resolve the error?

User: Yes, working now!

Bot: Great! I've noted this solution in case other users encounter the same issue.

Example 3: Escalation (DM)

User: I was charged twice for my subscription

Bot: I'm sorry to hear that! Double-billing is a serious issue that requires immediate attention from our billing team.

I've created an escalation ticket:

**Ticket #1523**
Issue: Double charge on subscription
Priority: Urgent
Expected response: Within 4 business hours

Our billing team has been notified and will reach out to you directly at the email associated with your account.

In the meantime, can you tell me:
1. Which payment method was charged?
2. What were the charge amounts and dates?

This will help expedite the resolution.

Example 4: Knowledge Base Update (Main Session)

Operator: Add to knowledge base: New feature launched - dark mode toggle in Settings → Appearance

Bot: ✅ Knowledge base updated.

Added to MEMORY.md under "New Features":
- Dark mode toggle now available in Settings → Appearance
- Recorded: 2024-01-15

This will be included in future support responses.

Architecture

How It Works

┌─────────────────┐
│  User Message   │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Memory Search   │ ← Searches knowledge base
│ (Semantic)      │   for relevant articles
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Claude Sonnet   │ ← Generates response
│ (LLM)           │   with context
└────────┬────────┘
         │
         ▼
    ┌────┴─────┐
    │ Resolved? │
    └────┬─────┘
         │
    ┌────┴────┐
    │   Yes   │   No
    │         │
    ▼         ▼
 Response   Escalate
            to Human

Memory Structure

memory/
├── escalations.json      # Active and resolved escalations
├── customer-history/     # Per-customer conversation logs
│   ├── user-123.md
│   └── user-456.md
├── templates.md          # Response templates
└── knowledge-updates.md  # Running log of KB additions

Session Types

  • Main: Full operator control, can edit knowledge base, approve pairings
  • DM: Sandboxed support conversations, can search KB and create escalations
  • Group: Public Q&A only, read-only KB access

Troubleshooting

Bot doesn't respond in DMs

Cause: Pairing mode requires approval

Solution: Check your main session for pairing requests. Approve with:

Approve DM access for @username

Responses are slow

Cause: Knowledge base semantic search takes time

Solution:

  • Pre-index knowledge base (set memory.indexTranscripts: true)
  • Use Claude Haiku for faster responses (edit hatchery.yaml model)

Bot gives outdated information

Cause: Knowledge base not updated

Solution: Update MEMORY.md with current information:

Update knowledge base: [new information]

Escalations not triggering

Cause: Escalation keywords not recognized

Solution: Check AGENTS.md escalation rules. Add keywords like:

  • "charged twice", "can't login", "data loss", "security issue"

Advanced Customization

Multi-Language Support

Add language detection and responses in AGENTS.md:

## Language Support
- Detect user language from first message
- Respond in same language when possible
- Escalate to human for languages not supported (English, Spanish, French)

Integration with Ticketing Systems

Add webhook integration in skills/create-ticket/:

#!/bin/bash
# skills/create-ticket/create.sh
curl -X POST "$ZENDESK_API_URL/tickets.json" \
  -H "Authorization: Bearer $ZENDESK_TOKEN" \
  -d '{"ticket": {"subject": "'$1'", "comment": {"body": "'$2'"}}}'

Custom Analytics

Track support metrics in memory/analytics.json:

{
  "totalConversations": 247,
  "resolvedWithoutEscalation": 198,
  "averageResponseTime": "2.3 minutes",
  "commonIssues": [
    {"issue": "password reset", "count": 45},
    {"issue": "API key issues", "count": 32}
  ]
}

Best Practices

  1. Keep knowledge base current — Review and update weekly
  2. Monitor escalations — Review escalated tickets to improve KB
  3. Train on real conversations — Add successful resolutions to MEMORY.md
  4. Set clear boundaries — Define what the bot can/cannot do
  5. Human handoff — Make it easy for users to reach humans when needed

Contributing

Found a bug or want to improve this template?

  • Report issues: https://github.com/openclaw/templates/issues
  • Submit improvements: https://github.com/openclaw/templates/pulls

License

MIT License - Free to use and modify for your support needs.

Deploy to Hosted

Stats

Downloads0
Deployments0
Latest Version1.0.0
Runtime SupportAny
Size23.5 KB

Versions

1.0.0about 2 months ago