Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Attendance CRM Template (attendance-crm.gbai)

A hybrid AI + Human support template that combines intelligent bot routing with human attendant management and full CRM automation. This template demonstrates the power of General Bots as an LLM orchestrator for customer service operations.


Overview

The Attendance CRM template provides:

  • Intelligent Routing - Bot analyzes sentiment and auto-transfers frustrated customers
  • LLM-Assisted Attendants - AI tips, message polish, smart replies for human agents
  • Queue Management - Automated queue monitoring and load balancing
  • CRM Automations - Follow-ups, collections, lead nurturing, pipeline management
  • Multi-Channel Support - Works on WhatsApp, Web, and other channels

Key Features

FeatureDescription
Sentiment-Based TransferAuto-transfers when customer frustration is detected
AI Copilot for AttendantsReal-time tips, smart replies, message polishing
Queue Health MonitoringAuto-reassign stale conversations, alert supervisors
Automated Follow-ups1-day, 3-day, 7-day follow-up sequences
Collections WorkflowPayment reminders from due date to legal escalation
Lead Scoring & NurturingScore leads and re-engage cold prospects
Pipeline ManagementWeekly reviews, stale opportunity alerts

Package Structure

attendance-crm.gbai/
├── attendance-crm.gbdialog/
│   ├── start.bas                 # Main entry - intelligent routing
│   ├── queue-monitor.bas         # Queue health monitoring (scheduled)
│   ├── attendant-helper.bas      # LLM assist tools for attendants
│   └── crm-automations.bas       # Follow-ups, collections, nurturing
├── attendance-crm.gbot/
│   └── config.csv                # Bot configuration
└── attendant.csv                 # Attendant team configuration

Configuration

config.csv

name,value

# Bot Identity
bot-name,Attendance CRM Bot
bot-description,Hybrid AI + Human support with CRM integration

# CRM / Human Handoff - Required
crm-enabled,true

# LLM Assist Features for Attendants
attendant-llm-tips,true
attendant-polish-message,true
attendant-smart-replies,true
attendant-auto-summary,true
attendant-sentiment-analysis,true

# Bot Personality (used for LLM assist context)
bot-system-prompt,You are a professional customer service assistant. Be helpful and empathetic.

# Auto-transfer triggers
auto-transfer-on-frustration,true
auto-transfer-threshold,3

# Queue Settings
queue-timeout-minutes,30
queue-notify-interval,5

# Lead Scoring
lead-score-threshold-hot,70
lead-score-threshold-warm,50

# Follow-up Automation
follow-up-1-day,true
follow-up-3-day,true
follow-up-7-day,true

# Collections Automation
collections-enabled,true
collections-grace-days,3

# Working Hours
business-hours-start,09:00
business-hours-end,18:00
business-days,1-5

# Notifications
notify-on-vip,true
notify-on-escalation,true
notify-email,support@company.com

attendant.csv

Attendants can be identified by any channel: WhatsApp phone, email, Microsoft Teams, or Google account.

id,name,channel,preferences,department,aliases,phone,email,teams,google
att-001,João Silva,all,sales,commercial,joao;js;silva,+5511999990001,joao.silva@company.com,joao.silva@company.onmicrosoft.com,joao.silva@company.com
att-002,Maria Santos,whatsapp,support,customer-service,maria;ms,+5511999990002,maria.santos@company.com,maria.santos@company.onmicrosoft.com,maria.santos@gmail.com
att-003,Pedro Costa,web,technical,engineering,pedro;pc;tech,+5511999990003,pedro.costa@company.com,pedro.costa@company.onmicrosoft.com,pedro.costa@company.com
att-004,Ana Oliveira,all,collections,finance,ana;ao;cobranca,+5511999990004,ana.oliveira@company.com,ana.oliveira@company.onmicrosoft.com,ana.oliveira@company.com
att-005,Carlos Souza,whatsapp,sales,commercial,carlos;cs,+5511999990005,carlos.souza@company.com,carlos.souza@company.onmicrosoft.com,carlos.souza@gmail.com

Column Reference

ColumnDescriptionExample
idUnique attendant IDatt-001
nameDisplay nameJoão Silva
channelPreferred channels (all, whatsapp, web, teams)all
preferencesSpecialization areasales, support, technical
departmentDepartment for routingcommercial, engineering
aliasesSemicolon-separated nicknames for matchingjoao;js;silva
phoneWhatsApp number (E.164 format)+5511999990001
emailEmail address for notificationsjoao@company.com
teamsMicrosoft Teams UPNjoao@company.onmicrosoft.com
googleGoogle Workspace emailjoao@company.com

The system can find an attendant by any identifier - phone, email, Teams UPN, Google account, name, or alias.


---

## Scripts

### start.bas - Intelligent Routing

The main entry point analyzes every customer message and decides routing:

```basic
' Analyze sentiment immediately
sentiment = ANALYZE SENTIMENT session.id, message

' Track frustration
IF sentiment.overall = "negative" THEN
    frustration_count = frustration_count + 1
END IF

' Auto-transfer on high escalation risk
IF sentiment.escalation_risk = "high" THEN
    tips = GET TIPS session.id, message
    result = TRANSFER TO HUMAN "support", "urgent", context_summary
END IF

Key behaviors:

  • Analyzes sentiment on every message
  • Tracks frustration count across conversation
  • Auto-transfers on explicit request (“falar com humano”, “talk to human”)
  • Auto-transfers when escalation risk is high
  • Auto-transfers after 3+ negative messages
  • Passes AI tips to attendant during transfer

queue-monitor.bas - Queue Health

Scheduled job that runs every 5 minutes:

SET SCHEDULE "queue-monitor", "*/5 * * * *"

What it does:

  • Finds conversations waiting >10 minutes → auto-assigns
  • Finds inactive assigned conversations → reminds attendant
  • Finds conversations with offline attendants → reassigns
  • Detects abandoned conversations → sends follow-up, then resolves
  • Generates queue metrics for dashboard
  • Alerts supervisor if queue gets long or no attendants online

attendant-helper.bas - LLM Assist Tools

Provides AI-powered assistance to human attendants:

' Get tips for current conversation
tips = USE TOOL "attendant-helper", "tips", session_id, message

' Polish a message before sending
polished = USE TOOL "attendant-helper", "polish", session_id, message, "empathetic"

' Get smart reply suggestions
replies = USE TOOL "attendant-helper", "replies", session_id

' Get conversation summary
summary = USE TOOL "attendant-helper", "summary", session_id

' Analyze sentiment with recommendations
sentiment = USE TOOL "attendant-helper", "sentiment", session_id, message

' Check if transfer is recommended
should_transfer = USE TOOL "attendant-helper", "suggest_transfer", session_id

crm-automations.bas - Business Workflows

Scheduled CRM automations:

' Daily follow-ups at 9am weekdays
SET SCHEDULE "follow-ups", "0 9 * * 1-5"

' Daily collections at 8am weekdays
SET SCHEDULE "collections", "0 8 * * 1-5"

' Daily lead nurturing at 10am weekdays
SET SCHEDULE "lead-nurture", "0 10 * * 1-5"

' Weekly pipeline review Friday 2pm
SET SCHEDULE "pipeline-review", "0 14 * * 5"

BASIC Keywords Used

Queue Management

KeywordDescriptionExample
GET QUEUEGet queue status and itemsqueue = GET QUEUE
NEXT IN QUEUEGet next waiting conversationnext = NEXT IN QUEUE
ASSIGN CONVERSATIONAssign to attendantASSIGN CONVERSATION session_id, "att-001"
RESOLVE CONVERSATIONMark as resolvedRESOLVE CONVERSATION session_id, "Fixed"
SET PRIORITYChange prioritySET PRIORITY session_id, "urgent"

Attendant Management

KeywordDescriptionExample
GET ATTENDANTSList attendantsattendants = GET ATTENDANTS "online"
GET ATTENDANT STATSGet performance metricsstats = GET ATTENDANT STATS "att-001"
SET ATTENDANT STATUSChange statusSET ATTENDANT STATUS "att-001", "busy"

LLM Assist

KeywordDescriptionExample
GET TIPSGenerate AI tipstips = GET TIPS session_id, message
POLISH MESSAGEImprove messagepolished = POLISH MESSAGE text, "empathetic"
GET SMART REPLIESGet reply suggestionsreplies = GET SMART REPLIES session_id
GET SUMMARYConversation summarysummary = GET SUMMARY session_id
ANALYZE SENTIMENTSentiment analysissentiment = ANALYZE SENTIMENT session_id, message

Customer Journey

KeywordDescriptionExample
TAG CONVERSATIONAdd tagsTAG CONVERSATION session_id, "vip"
ADD NOTEAdd internal noteADD NOTE session_id, "Customer is VIP"
GET CUSTOMER HISTORYPrevious interactionshistory = GET CUSTOMER HISTORY user_id
TRANSFER TO HUMANHandoff to humanTRANSFER TO HUMAN "support", "high", context

Sample Conversations

Auto-Transfer on Frustration

Customer: Olá, preciso de ajuda com meu pedido

Bot: Olá! Claro, ficarei feliz em ajudar com seu pedido.
     Qual é o número do pedido?

Customer: #12345

Bot: Encontrei seu pedido #12345. Está em trânsito e deve
     chegar amanhã. Posso ajudar com mais alguma coisa?

Customer: Amanhã?! Isso é ridículo! Já deveria ter chegado há 3 dias!

Bot: [Sentiment: negative, Escalation Risk: medium]
     Entendo sua frustração. Peço desculpas pelo atraso.
     Se preferir falar com um atendente humano, é só me avisar.

Customer: SIM! Quero falar com alguém de verdade AGORA!

Bot: [Auto-transfer triggered]
     Estou transferindo você para Maria Santos.
     Um momento, por favor.

     [Tips sent to Maria:]
     ⚠️ Customer frustrated - 3 negative messages
     🎯 Issue: Delayed order #12345
     ✅ Offer compensation for delay

Attendant Using LLM Assist

[Customer message arrives]
Customer: não consigo acessar minha conta faz 2 dias!!

[AI Tips appear in attendant UI:]
💡 Tips:
   ⚠️ Customer frustrated - use empathetic tone
   🎯 Intent: Account access issue
   ✅ Verify account status, offer password reset

[Attendant types response:]
Attendant: oi, vou verificar sua conta

[Clicks ✨ Polish button:]
Polished: "Olá! Entendo como isso pode ser frustrante.
          Vou verificar sua conta agora mesmo e resolver
          isso para você."

[Attendant sends polished message]

Automation Workflows

Follow-up Sequence

DayActionTemplate
1Thank you messagefollow_up_thanks
3Value propositionfollow_up_value
7Special offer (if score ≥50)follow_up_offer

Collections Workflow

Days OverdueActionEscalation
0 (due today)Friendly reminderWhatsApp template
3First noticeWhatsApp + Email
7Second notice+ Notify collections team
15Final notice + late fees+ Queue for human call
30+Send to legal+ Suspend account

WhatsApp Templates Required

Configure these in Meta Business Manager:

TemplateVariablesPurpose
follow_up_thanksname, interest1-day thank you
follow_up_valuename, interest3-day value prop
follow_up_offername, discount7-day offer
payment_due_todayname, invoice_id, amountDue reminder
payment_overdue_3name, invoice_id, amount3-day overdue
payment_overdue_7name, invoice_id, amount7-day overdue
payment_final_noticename, invoice_id, total15-day final

Metrics & Analytics

The template automatically tracks:

  • Queue Metrics: Wait times, queue length, utilization
  • Attendant Performance: Resolved count, active conversations
  • Sentiment Trends: Per conversation and overall
  • Automation Results: Follow-ups sent, collections processed

Access via:

  • Dashboard at /suite/analytics/
  • API at /api/attendance/insights
  • Stored in queue_metrics and automation_logs tables

Best Practices

1. Configure Sentiment Thresholds

Adjust auto-transfer-threshold based on your tolerance:

  • 2 = Very aggressive (transfer quickly)
  • 3 = Balanced (default)
  • 5 = Conservative (try harder with bot)

2. Set Business Hours

Configure business-hours-* to avoid sending automated messages at night.

3. Train Your Team

Ensure attendants know the WhatsApp commands:

  • /tips - Get AI tips
  • /polish <message> - Improve message
  • /replies - Get suggestions
  • /resolve - Close conversation

4. Monitor Queue Health

Set up alerts for:

  • Queue > 10 waiting
  • No attendants online during business hours
  • Average wait > 15 minutes

See Also