Crawler Summary

Facilit_Bot answer-first brief

Facilit_Bot is a WhatsApp Business automation server using CrewAI multi-agent orchestration. Implements a complete 14-step Portuguese (pt-BR) sales funnel for appliance wrapping and home services with Z-API messaging, Flask REST API + SSE streaming, factory-pattern crew/agent architecture, and thread-safe session management. πŸ€– FacilitBot **WhatsApp Customer Service Automation Bot** powered by a multi-agent AI system --- <p align="center"> <strong>Python 3.12+</strong> &nbsp;|&nbsp; <strong>Flask</strong> &nbsp;|&nbsp; <strong>CrewAI</strong> &nbsp;|&nbsp; <strong>Z-API</strong> &nbsp;|&nbsp; <strong>SSE Real-Time</strong> </p> --- πŸ“‹ Table of Contents - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 --- 🎯 Capability contract not published. No trust telemetry is available yet. 1 GitHub stars reported by the source. Last updated 10/9/2026.

Freshness

Last checked 10/9/2026

Best For

Facilit_Bot is best for crewai, multi-agent workflows where OpenClaw compatibility matters.

Not Ideal For

Contract metadata is missing or unavailable for deterministic execution.

Evidence Sources Checked

editorial-content, GITHUB REPOS, runtime-metrics, public facts pack

Agent DossierGITHUB REPOSSafety: 66/100

Facilit_Bot

Facilit_Bot is a WhatsApp Business automation server using CrewAI multi-agent orchestration. Implements a complete 14-step Portuguese (pt-BR) sales funnel for appliance wrapping and home services with Z-API messaging, Flask REST API + SSE streaming, factory-pattern crew/agent architecture, and thread-safe session management. πŸ€– FacilitBot **WhatsApp Customer Service Automation Bot** powered by a multi-agent AI system --- <p align="center"> <strong>Python 3.12+</strong> &nbsp;|&nbsp; <strong>Flask</strong> &nbsp;|&nbsp; <strong>CrewAI</strong> &nbsp;|&nbsp; <strong>Z-API</strong> &nbsp;|&nbsp; <strong>SSE Real-Time</strong> </p> --- πŸ“‹ Table of Contents - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 --- 🎯

OpenClawself-declared

Public facts

5

Change events

1

Artifacts

0

Freshness

Oct 9, 2026

Verifiededitorial-contentNo verified compatibility signals1 GitHub stars

Capability contract not published. No trust telemetry is available yet. 1 GitHub stars reported by the source. Last updated 10/9/2026.

1 GitHub starsTrust evidence available

Trust score

Unknown

Compatibility

OpenClaw

Freshness

Oct 9, 2026

Vendor

Vichagas07

Artifacts

0

Benchmarks

0

Last release

Unpublished

Executive Summary

Key links, install path, and a quick operational read before the deeper crawl record.

Verifiededitorial-content

Summary

Capability contract not published. No trust telemetry is available yet. 1 GitHub stars reported by the source. Last updated 10/9/2026.

Setup snapshot

  1. 1

    Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.

  2. 2

    Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Evidence Ledger

Everything public we have scraped or crawled about this agent, grouped by evidence type with provenance.

Verifiededitorial-content
Vendor (1)

Vendor

Vichagas07

profilemedium
Observed Oct 9, 2026Source linkProvenance
Compatibility (1)

Protocol compatibility

OpenClaw

contractmedium
Observed Oct 9, 2026Source linkProvenance
Adoption (1)

Adoption signal

1 GitHub stars

profilemedium
Observed Oct 9, 2026Source linkProvenance
Security (1)

Handshake status

UNKNOWN

trustmedium
Observed unknownSource linkProvenance
Integration (1)

Crawlable docs

6 indexed pages on the official domain

search_documentmedium
Observed Apr 15, 2026Source linkProvenance

Release & Crawl Timeline

Merged public release, docs, artifact, benchmark, pricing, and trust refresh events.

Self-declaredagent-index

Artifacts Archive

Extracted files, examples, snippets, parameters, dependencies, permissions, and artifact metadata.

Self-declaredGITHUB REPOS

Extracted files

0

Examples

6

Snippets

0

Languages

python

Executable Examples

text

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚     React Native App      β”‚
                          β”‚  (Companion Dashboard)    β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚ SSE Stream + REST API
                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Flask Server (port 5000)                   β”‚
β”‚                                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   /api/v1/*     β”‚  β”‚   /webhook       β”‚  β”‚   /health       β”‚  β”‚
β”‚  β”‚  REST API       β”‚  β”‚  Z-API Callback  β”‚  β”‚  Health Check   β”‚  β”‚
β”‚  β”‚  + SSE Stream   β”‚  β”‚                  β”‚  β”‚                 β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚           β”‚                    β”‚                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                    β”‚
            β–Ό                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      CrewAI Multi-Agent System                     β”‚
β”‚                                                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                  AtendimentoCrew (Main Flow)                  β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚ β”‚
β”‚  β”‚  β”‚Orchestr. β”‚  β”‚  Quote   β”‚  β”‚  Sales   β”‚  β”‚  Media   β”‚    β”‚ β”‚
β”‚  β”‚  β”‚  Agent   │─▢│  Agent   │─▢│  Agent   │─▢│  Agent   β”‚    β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   InterfaceCrew (Status) β”‚  β”‚  NotificacaoCrew (Alerts)     β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”

text

Step 0: WELCOME
  β”‚  Sends audio greeting + prompts for name
  β–Ό
Step 1: COLLECT NAME
  β”‚  Stores customer name + presents 9 product options
  β–Ό
Step 2: PRODUCT SELECTION
  β”‚  Routes to product-specific step based on customer choice
  β–Ό
Step 3-6: PRODUCT QUOTING
  β”‚  β”Œβ”€ Step 3: Fridge       β†’ Type (1-door/duplex) + Rust detection
  β”‚  β”œβ”€ Step 4: Stove        β†’ Burner count (4/5/6)
  β”‚  β”œβ”€ Step 5: Washing Mach β†’ Type (front/top loader)
  β”‚  └─ Step 6: Microwave    β†’ Size (small/medium/large)
  β–Ό
Step 6.5: PROMOTION DECISION
  β”‚  Presents promotional offer β†’ Yes/No
  β–Ό
Step 6.6: OFFER SELECTION (if accepted)
  β”‚  Two promotional bundles available
  β–Ό
Steps 7-9: YES/NO SERVICES
  β”‚  β”Œβ”€ Step 7:  Window Film β†’ Step 12 (measurement)
  β”‚  β”œβ”€ Step 8:  Door Film   β†’ Step 13 (measurement)
  β”‚  └─ Step 9:  Box Sticker β†’ Step 14 (measurement)
  β–Ό
Steps 10-11: DIRECT SERVICES
  β”‚  β”Œβ”€ Step 10: Wallpaper β†’ Media gallery + human alert
  β”‚  └─ Step 11: Furniture β†’ Media gallery + human alert
  β–Ό
Steps 12-14: MEASUREMENT
  β”‚  Collects size in meters β†’ Media gallery + human alert
  β–Ό
Step 99: COMPLETED
  β”‚  Human attendant notified; session archived
  β–Ό
RETORNO_1H: FOLLOW-UP (after 60 min inactivity)
  β”‚  Offers restart/new service/inquiry options

text

Facilit_bot/
β”‚
β”œβ”€β”€ facilit_bot/                     # Main application package
β”‚   β”‚
β”‚   β”œβ”€β”€ main.py                      # πŸš€ Entry point: Flask app factory, startup orchestration
β”‚   β”œβ”€β”€ config.py                    # βš™οΈ Centralized configuration (env vars, media paths, constants)
β”‚   β”œβ”€β”€ webhook_server.py            # πŸ“₯ Z-API webhook receiver (/webhook, /health)
β”‚   β”‚
β”‚   β”œβ”€β”€ api/                         # 🌐 REST API layer
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Module exports
β”‚   β”‚   β”œβ”€β”€ routes.py                #    All REST endpoints + SSE stream
β”‚   β”‚   β”œβ”€β”€ schemas.py               #    Pydantic request/response models
β”‚   β”‚   └── middleware.py            #    CORS setup + token authentication decorator
β”‚   β”‚
β”‚   β”œβ”€β”€ agents/                      # πŸ€– Individual AI agents (single-responsibility)
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Agent exports
β”‚   β”‚   β”œβ”€β”€ orchestrator_agent.py    #    Routes messages based on conversation step
β”‚   β”‚   β”œβ”€β”€ quote_agent.py           #    Collects product-specific data (type, size, etc.)
β”‚   β”‚   β”œβ”€β”€ sales_agent.py           #    Manages promotions and offer selection
β”‚   β”‚   β”œβ”€β”€ media_agent.py           #    Sends text/audio/image/video via Z-API
β”‚   β”‚   β”œβ”€β”€ alert_agent.py           #    System notifications + SSE alerts
β”‚   β”‚   └── retry_agent.py           #    1-hour inactivity follow-up monitor
β”‚   β”‚
β”‚   β”œβ”€β”€ crews/                       # πŸ‘₯ CrewAI crew compositions
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Crew factory exports
β”‚   β”‚   β”œβ”€β”€ atendimento_crew.py      #    Main 14-step customer service crew
β”‚   β”‚   β”œβ”€β”€ interface_crew.py        #    Bot state management + SSE broadcasting
β”‚   β”‚   └── notificacao_crew.py      #    Alert + retry notification crew
β”‚   β”‚
β”‚   β”œβ”€β”€ integrations/                # πŸ”Œ External service clients
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Client exports
β”‚   β”‚   └── zapi_client.py           #    Z-API HTTP client (send text, media)
β”‚   β”‚
β”‚   β”œβ”€β”€ state/                       # πŸ’Ύ Session 

bash

git clone https://github.com/your-org/facilit_bot.git
cd facilit_bot

bash

# Create virtual environment inside facilit_bot/ directory
python -m venv facilit_bot/venv

# Activate (Windows PowerShell)
facilit_bot\venv\Scripts\Activate.ps1

# Activate (Linux/macOS)
source facilit_bot/venv/bin/activate

bash

# Using pip
pip install -r facilit_bot/requirements.txt

# Or using Poetry
cd facilit_bot
poetry install

Docs & README

Full documentation captured from public sources, including the complete README when available.

Self-declaredGITHUB REPOS

Docs source

GITHUB REPOS

Editorial quality

ready

Facilit_Bot is a WhatsApp Business automation server using CrewAI multi-agent orchestration. Implements a complete 14-step Portuguese (pt-BR) sales funnel for appliance wrapping and home services with Z-API messaging, Flask REST API + SSE streaming, factory-pattern crew/agent architecture, and thread-safe session management. πŸ€– FacilitBot **WhatsApp Customer Service Automation Bot** powered by a multi-agent AI system --- <p align="center"> <strong>Python 3.12+</strong> &nbsp;|&nbsp; <strong>Flask</strong> &nbsp;|&nbsp; <strong>CrewAI</strong> &nbsp;|&nbsp; <strong>Z-API</strong> &nbsp;|&nbsp; <strong>SSE Real-Time</strong> </p> --- πŸ“‹ Table of Contents - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 - $1 --- 🎯

Full README

πŸ€– FacilitBot

WhatsApp Customer Service Automation Bot powered by a multi-agent AI system


<p align="center"> <strong>Python 3.12+</strong> &nbsp;|&nbsp; <strong>Flask</strong> &nbsp;|&nbsp; <strong>CrewAI</strong> &nbsp;|&nbsp; <strong>Z-API</strong> &nbsp;|&nbsp; <strong>SSE Real-Time</strong> </p>

πŸ“‹ Table of Contents


🎯 Overview

FacilitBot is a production-grade WhatsApp automation server that handles customer service conversations end-to-end. It replaces manual chat operators with an intelligent multi-agent system built on CrewAI, capable of guiding customers through a 14-step sales funnel β€” from greeting to product quoting, promotional offers, and final handoff to a human attendant.

The system integrates with WhatsApp via the Z-API service, provides a fully-featured REST API for a companion React Native mobile dashboard, and streams real-time updates through Server-Sent Events (SSE). All conversation state is persisted to disk with thread-safe access, making it resilient across restarts and concurrent webhook processing.

Target Audience: Small-to-medium businesses that want to automate WhatsApp customer service, generate quotes for products/services, and provide a seamless bridge between automated bots and human operators.


✨ Features

Core Capabilities

| Feature | Description | |---|---| | Multi-Agent AI | 6 specialized agents (Orchestrator, Quote, Sales, Media, Alert, Retry) working in concert | | 14-Step Sales Funnel | Full conversation flow from greeting β†’ product selection β†’ quoting β†’ promotion β†’ human handoff | | WhatsApp Integration | Send/receive text messages, audio, images, and video via Z-API | | REST API | 10+ authenticated endpoints for a React Native companion app | | Real-Time SSE | Push events to mobile client on new messages, bot status changes, and alerts | | Inactivity Monitoring | Automatic 1-hour follow-up messages for abandoned conversations | | System Notifications | Desktop alerts (via plyer) when human attention is required | | Thread-Safe Persistence | All session state persisted to JSON with locking for concurrent access | | Flexible Product Catalog | Supports 9 product categories with configurable options | | Portuguese (pt-BR) | Native Brazilian Portuguese conversation flow and locale settings |

Technical Highlights

  • Clean Architecture with clear separation of concerns: api/ β†’ crews/ β†’ agents/ β†’ integrations/
  • Single-process deployment β€” API server and webhook receiver run on the same Flask instance
  • Factory pattern for crew and agent creation, enabling testability and dependency injection
  • Pydantic schemas for request/response validation and API contract enforcement
  • Daemon threading for background tasks (retry agent, notifications)
  • Environment-driven configuration via .env β€” zero hardcoded secrets

πŸ— System Architecture

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚     React Native App      β”‚
                          β”‚  (Companion Dashboard)    β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚ SSE Stream + REST API
                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Flask Server (port 5000)                   β”‚
β”‚                                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   /api/v1/*     β”‚  β”‚   /webhook       β”‚  β”‚   /health       β”‚  β”‚
β”‚  β”‚  REST API       β”‚  β”‚  Z-API Callback  β”‚  β”‚  Health Check   β”‚  β”‚
β”‚  β”‚  + SSE Stream   β”‚  β”‚                  β”‚  β”‚                 β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚           β”‚                    β”‚                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                    β”‚
            β–Ό                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      CrewAI Multi-Agent System                     β”‚
β”‚                                                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                  AtendimentoCrew (Main Flow)                  β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚ β”‚
β”‚  β”‚  β”‚Orchestr. β”‚  β”‚  Quote   β”‚  β”‚  Sales   β”‚  β”‚  Media   β”‚    β”‚ β”‚
β”‚  β”‚  β”‚  Agent   │─▢│  Agent   │─▢│  Agent   │─▢│  Agent   β”‚    β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   InterfaceCrew (Status) β”‚  β”‚  NotificacaoCrew (Alerts)     β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚
β”‚  β”‚  β”‚  GUI    β”‚ β”‚ Status β”‚ β”‚  β”‚  β”‚  Alert   β”‚ β”‚  Retry   β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  Agent  β”‚ β”‚ Agent  β”‚ β”‚  β”‚  β”‚  Agent   β”‚ β”‚  Agent   β”‚   β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    ZAPI Client       β”‚    β”‚   SessionManager     β”‚
β”‚  (HTTP β†’ WhatsApp)   β”‚    β”‚  (Thread-Safe JSON)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. Z-API pushes incoming WhatsApp messages to /webhook
  2. Flask spawns a daemon thread for each message
  3. AtendimentoCrew.process_message() routes to the correct step handler via OrchestratorAgent
  4. Step handlers use QuoteAgent, SalesAgent, and MediaAgent to process data and send replies
  5. MediaAgent calls ZAPIClient to dispatch messages/media through Z-API back to WhatsApp
  6. Session state is persisted via SessionManager after every step
  7. SSE events are broadcast to connected React Native clients for real-time dashboard updates

πŸ”„ Conversation Flow

The bot follows a deterministic 14-step conversation funnel. Each step corresponds to a stage in the customer journey:

Step 0: WELCOME
  β”‚  Sends audio greeting + prompts for name
  β–Ό
Step 1: COLLECT NAME
  β”‚  Stores customer name + presents 9 product options
  β–Ό
Step 2: PRODUCT SELECTION
  β”‚  Routes to product-specific step based on customer choice
  β–Ό
Step 3-6: PRODUCT QUOTING
  β”‚  β”Œβ”€ Step 3: Fridge       β†’ Type (1-door/duplex) + Rust detection
  β”‚  β”œβ”€ Step 4: Stove        β†’ Burner count (4/5/6)
  β”‚  β”œβ”€ Step 5: Washing Mach β†’ Type (front/top loader)
  β”‚  └─ Step 6: Microwave    β†’ Size (small/medium/large)
  β–Ό
Step 6.5: PROMOTION DECISION
  β”‚  Presents promotional offer β†’ Yes/No
  β–Ό
Step 6.6: OFFER SELECTION (if accepted)
  β”‚  Two promotional bundles available
  β–Ό
Steps 7-9: YES/NO SERVICES
  β”‚  β”Œβ”€ Step 7:  Window Film β†’ Step 12 (measurement)
  β”‚  β”œβ”€ Step 8:  Door Film   β†’ Step 13 (measurement)
  β”‚  └─ Step 9:  Box Sticker β†’ Step 14 (measurement)
  β–Ό
Steps 10-11: DIRECT SERVICES
  β”‚  β”Œβ”€ Step 10: Wallpaper β†’ Media gallery + human alert
  β”‚  └─ Step 11: Furniture β†’ Media gallery + human alert
  β–Ό
Steps 12-14: MEASUREMENT
  β”‚  Collects size in meters β†’ Media gallery + human alert
  β–Ό
Step 99: COMPLETED
  β”‚  Human attendant notified; session archived
  β–Ό
RETORNO_1H: FOLLOW-UP (after 60 min inactivity)
  β”‚  Offers restart/new service/inquiry options

Product Catalog

| Code | Product | |---|---| | 01 | Plotagem Geladeira (Fridge Wrapping) | | 02 | Plotagem FogΓ£o (Stove Wrapping) | | 03 | Plotagem MΓ‘quina de Lavar (Washing Machine Wrapping) | | 04 | Plotagem Micro-ondas (Microwave Wrapping) | | 05 | PelΓ­cula Janela (Window Film) | | 06 | PelΓ­cula Porta (Door Film) | | 07 | Adesivo Box (Box Sticker) | | 08 | Papel de Parede (Wallpaper) | | 09 | Plotagem de MΓ³veis (Furniture Wrapping) |


πŸ›  Tech Stack

Backend

| Technology | Version | Purpose | |---|---|---| | Python | 3.12+ | Core language | | Flask | 3.0+ | Web framework (API + webhooks) | | Flask-CORS | 4.0+ | Cross-origin support for mobile app | | CrewAI | 0.80+ | Multi-agent AI orchestration framework | | Pydantic | 2.0+ | Data validation & API schemas | | Requests | 2.31+ | HTTP client for Z-API integration | | python-dotenv | 1.0+ | Environment variable management | | plyer | 2.1+ | System desktop notifications | | python-dateutil | 2.8+ | Date/time parsing utilities |

External Services

| Service | Purpose | |---|---| | Z-API | WhatsApp Business API gateway (message send/receive) | | React Native (companion app) | Mobile dashboard consuming REST API + SSE |


πŸ“ Project Structure

Facilit_bot/
β”‚
β”œβ”€β”€ facilit_bot/                     # Main application package
β”‚   β”‚
β”‚   β”œβ”€β”€ main.py                      # πŸš€ Entry point: Flask app factory, startup orchestration
β”‚   β”œβ”€β”€ config.py                    # βš™οΈ Centralized configuration (env vars, media paths, constants)
β”‚   β”œβ”€β”€ webhook_server.py            # πŸ“₯ Z-API webhook receiver (/webhook, /health)
β”‚   β”‚
β”‚   β”œβ”€β”€ api/                         # 🌐 REST API layer
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Module exports
β”‚   β”‚   β”œβ”€β”€ routes.py                #    All REST endpoints + SSE stream
β”‚   β”‚   β”œβ”€β”€ schemas.py               #    Pydantic request/response models
β”‚   β”‚   └── middleware.py            #    CORS setup + token authentication decorator
β”‚   β”‚
β”‚   β”œβ”€β”€ agents/                      # πŸ€– Individual AI agents (single-responsibility)
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Agent exports
β”‚   β”‚   β”œβ”€β”€ orchestrator_agent.py    #    Routes messages based on conversation step
β”‚   β”‚   β”œβ”€β”€ quote_agent.py           #    Collects product-specific data (type, size, etc.)
β”‚   β”‚   β”œβ”€β”€ sales_agent.py           #    Manages promotions and offer selection
β”‚   β”‚   β”œβ”€β”€ media_agent.py           #    Sends text/audio/image/video via Z-API
β”‚   β”‚   β”œβ”€β”€ alert_agent.py           #    System notifications + SSE alerts
β”‚   β”‚   └── retry_agent.py           #    1-hour inactivity follow-up monitor
β”‚   β”‚
β”‚   β”œβ”€β”€ crews/                       # πŸ‘₯ CrewAI crew compositions
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Crew factory exports
β”‚   β”‚   β”œβ”€β”€ atendimento_crew.py      #    Main 14-step customer service crew
β”‚   β”‚   β”œβ”€β”€ interface_crew.py        #    Bot state management + SSE broadcasting
β”‚   β”‚   └── notificacao_crew.py      #    Alert + retry notification crew
β”‚   β”‚
β”‚   β”œβ”€β”€ integrations/                # πŸ”Œ External service clients
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Client exports
β”‚   β”‚   └── zapi_client.py           #    Z-API HTTP client (send text, media)
β”‚   β”‚
β”‚   β”œβ”€β”€ state/                       # πŸ’Ύ Session persistence
β”‚   β”‚   β”œβ”€β”€ __init__.py              #    Module exports
β”‚   β”‚   β”œβ”€β”€ models.py                #    SessionState dataclass with serialization
β”‚   β”‚   └── session_manager.py       #    Thread-safe JSON file persistence
β”‚   β”‚
β”‚   β”œβ”€β”€ .env                         # πŸ” Environment variables (secrets β€” NOT committed)
β”‚   β”œβ”€β”€ .env.example                 # πŸ“‹ Environment template with documentation
β”‚   β”œβ”€β”€ requirements.txt             # πŸ“¦ pip dependency list
β”‚   └── pyproject.toml               # πŸ“¦ Poetry project configuration
β”‚
β”œβ”€β”€ midia_facilit/                   # 🎬 Media assets (local only, gitignored)
β”‚   β”œβ”€β”€ audio_boas_vindas.ogg        #    Welcome audio
β”‚   β”œβ”€β”€ ploategm_uma_porta.ogg       #    1-door fridge audio
β”‚   β”œβ”€β”€ plotagem_duplex.ogg          #    Duplex fridge audio
β”‚   β”œβ”€β”€ tratamento_ferrugem.ogg      #    Rust treatment audio
β”‚   β”œβ”€β”€ plotagem_fogΓ£o.ogg           #    Stove audio
β”‚   β”œβ”€β”€ plotagem_mΓ‘quina_lavar.ogg   #    Washing machine audio
β”‚   β”œβ”€β”€ plotagem_microondas.ogg      #    Microwave audio
β”‚   β”œβ”€β”€ promocao_*.ogg               #    Promotional audios (5 files)
β”‚   β”œβ”€β”€ imagem_*.jpeg                #    Service images (5 files)
β”‚   β”œβ”€β”€ video_facilit*.mp4           #    Demo videos (3 files)
β”‚   β”œβ”€β”€ logo_facilit.jpg             #    Brand logo
β”‚   └── fonts/                       #    Emoji font assets
β”‚
β”œβ”€β”€ venv/                            # 🐍 Python virtual environment (gitignored)
β”œβ”€β”€ node_modules/                    # πŸ“¦ Node dependencies (gitignored)
β”œβ”€β”€ package.json                     # πŸ“¦ Node.js config (expo-splash-screen)
β”œβ”€β”€ package-lock.json                # πŸ”’ Node.js lockfile
β”œβ”€β”€ .vscode/                         # πŸ–₯️ VS Code workspace settings
β”œβ”€β”€ .gitignore                       # 🚫 Git ignore rules
└── README.md                        # πŸ“– This documentation

πŸ“‹ Prerequisites

Before installing FacilitBot, ensure you have:

| Requirement | Version | Notes | |---|---|---| | Python | 3.12 - 3.13 | Using match statements and modern type hints | | pip | 23+ | For dependency installation | | Z-API Account | β€” | app.z-api.io β€” Instance ID + Token required | | Media Files | β€” | Audio, images, and videos in midia_facilit/ (gitignored) | | Git | 2.x+ | For version control |

Optional

  • Poetry (1.8+) β€” Alternative dependency manager
  • React Native App β€” Companion mobile dashboard (separate repository)
  • Ngrok β€” For exposing local webhook to Z-API during development

πŸš€ Installation

1. Clone the Repository

git clone https://github.com/your-org/facilit_bot.git
cd facilit_bot

2. Set Up Virtual Environment

# Create virtual environment inside facilit_bot/ directory
python -m venv facilit_bot/venv

# Activate (Windows PowerShell)
facilit_bot\venv\Scripts\Activate.ps1

# Activate (Linux/macOS)
source facilit_bot/venv/bin/activate

3. Install Dependencies

# Using pip
pip install -r facilit_bot/requirements.txt

# Or using Poetry
cd facilit_bot
poetry install

4. Configure Environment Variables

# Copy the example file
cp facilit_bot/.env.example facilit_bot/.env

# Edit with your actual values

Fill in the .env file:

# Z-API Credentials (REQUIRED)
ZAPI_INSTANCE_ID=inst-xxxxxxxx
ZAPI_TOKEN=your_zapi_token_here

# Server Settings
FLASK_HOST=0.0.0.0
FLASK_PORT=5000

# Security
BOT_API_TOKEN=facilit-dev-token        # Change in production!
ALLOWED_ORIGINS=*

5. Add Media Files

Place your media assets in the midia_facilit/ directory:

midia_facilit/
β”œβ”€β”€ audio_boas_vindas.ogg
β”œβ”€β”€ ploategm_uma_porta.ogg
β”œβ”€β”€ plotagem_duplex.ogg
β”œβ”€β”€ tratamento_ferrugem.ogg
β”œβ”€β”€ plotagem_fogΓ£o.ogg
β”œβ”€β”€ plotagem_mΓ‘quina_lavar.ogg
β”œβ”€β”€ plotagem_microondas.ogg
β”œβ”€β”€ promocao_uma_porta.ogg
β”œβ”€β”€ promocao_duplex.ogg
β”œβ”€β”€ promocao_fogao.ogg
β”œβ”€β”€ promocao_maquina_lavar.ogg
β”œβ”€β”€ promocao_microondas.ogg
β”œβ”€β”€ imagem_movel.jpeg
β”œβ”€β”€ imagem_facilit_geladeira.jpeg
β”œβ”€β”€ imagem_facilit_geladeira2.jpeg
β”œβ”€β”€ imagem_porta.jpeg
β”œβ”€β”€ video_facilit.mp4
β”œβ”€β”€ video_facilit2.mp4
β”œβ”€β”€ video_facilit3.mp4
β”œβ”€β”€ logo_facilit.jpg
└── fonts/NotoEmoji-VariableFont_wght.ttf

Note: Media files are gitignored. The exact filenames must match those referenced in config.py.

6. Start the Server

cd facilit_bot
python main.py

Expected output:

============================================================
  FACILITBOT - WhatsApp Automation Server
============================================================

  Local IP:   http://192.168.1.100:5000
  Webhook:    http://192.168.1.100:5000/webhook
  API:        http://192.168.1.100:5000/api/v1
  SSE Stream: http://192.168.1.100:5000/api/v1/stream

------------------------------------------------------------
  React Native .env configuration:
    EXPO_PUBLIC_API_URL=http://192.168.1.100:5000/api/v1
    EXPO_PUBLIC_BOT_TOKEN=facilit-dev-token
------------------------------------------------------------

  Press Ctrl+C to stop the server

βš™οΈ Configuration

All configuration is managed through environment variables loaded from .env.

Z-API Settings

| Variable | Default | Description | |---|---|---| | ZAPI_INSTANCE_ID | instancia_id | Your Z-API instance ID from app.z-api.io | | ZAPI_TOKEN | token_id | Your Z-API authentication token |

Server Settings

| Variable | Default | Description | |---|---|---| | FLASK_HOST | 0.0.0.0 | Bind address (0.0.0.0 = all interfaces) | | FLASK_PORT | 5000 | Server port |

Security

| Variable | Default | Description | |---|---|---| | BOT_API_TOKEN | facilit-dev-token | API authentication token for mobile app | | ALLOWED_ORIGINS | * | CORS origins (* = development only, restrict in production) |

File Paths

| Variable | Default | Description | |---|---|---| | SESSIONS_FILE | conversas.json | Path to session persistence file | | MEDIA_DIR | midia_facilit | Directory containing audio/images/videos |

Business Logic

| Variable | Default | Description | |---|---|---| | INACTIVITY_TIMEOUT_MINUTES | 60 | Minutes before 1-hour follow-up (commented out in .env.example, hardcoded in config) |

Product Options

Product options are configured in config.py as a PRODUCT_OPTIONS dictionary. Each product maps a numeric code (string) to a name and conversation step:

PRODUCT_OPTIONS = {
    "01": {"name": "Plotagem Geladeira", "step": 3},
    "02": {"name": "Plotagem FogΓ£o", "step": 4},
    # ... more options
}

Promotional Text

The promotional message (PROMOTIONAL_TEXT) and offer options (OFFER_1, OFFER_2) can be customized in config.py.


πŸ“– Usage

Running the Server

cd facilit_bot
python main.py

The server starts with:

  • Webhook listener on http://<local-ip>:5000/webhook β€” Z-API sends incoming messages here
  • REST API on http://<local-ip>:5000/api/v1/ β€” Used by the React Native companion app
  • SSE Stream on http://<local-ip>:5000/api/v1/stream β€” Real-time event push
  • Health Check on http://<local-ip>:5000/health

Connecting Z-API Webhook

  1. Log into your Z-API Dashboard
  2. Go to your instance settings
  3. Set the webhook URL to http://<your-server-ip>:5000/webhook
  4. Z-API will POST incoming messages as:
{
  "phone": "5511999999999",
  "message": "OlΓ‘, quero plotar minha geladeira"
}

React Native App Configuration

Configure your mobile app's .env:

EXPO_PUBLIC_API_URL=http://<server-ip>:5000/api/v1
EXPO_PUBLIC_BOT_TOKEN=facilit-dev-token

Bot Control

The bot starts inactive. Activate it via the API:

# Activate
curl -X POST http://localhost:5000/api/v1/bot/activate \
  -H "X-Bot-Token: facilit-dev-token"

# Deactivate
curl -X POST http://localhost:5000/api/v1/bot/deactivate \
  -H "X-Bot-Token: facilit-dev-token"

# Check status
curl http://localhost:5000/api/v1/status \
  -H "X-Bot-Token: facilit-dev-token"

Restart Command

During conversation, customers can type "reiniciar" to restart their session from Step 1.


πŸ“‘ REST API Reference

Base URL: http://<host>:5000/api/v1

Authentication: All endpoints require the X-Bot-Token header with the value of BOT_API_TOKEN.

Endpoints

| Method | Endpoint | Description | |---|---|---| | GET | /status | Bot status (active, uptime, version) | | POST | /bot/activate | Activate the bot | | POST | /bot/deactivate | Deactivate the bot | | GET | /sessions | List sessions (paginated, filterable) | | GET | /sessions/:number | Get session details | | DELETE | /sessions/:number | Delete a session | | PATCH | /sessions/:number/resolve | Mark session as resolved (step 99) | | GET | /metrics | System metrics (active/completed counts, messages today) | | GET | /stream | SSE real-time event stream |

Detailed Examples

GET /status

curl http://localhost:5000/api/v1/status \
  -H "X-Bot-Token: facilit-dev-token"

Response:

{
  "active": true,
  "uptime_seconds": 4238,
  "version": "1.0.0"
}

GET /sessions

curl "http://localhost:5000/api/v1/sessions?page=1&limit=10&status=active" \
  -H "X-Bot-Token: facilit-dev-token"

Query Parameters: | Parameter | Type | Default | Description | |---|---|---|---| | page | int | 1 | Page number | | limit | int | 20 (max 50) | Items per page | | status | string | all | Filter: active, completed, all |

Response:

{
  "sessions": [
    {
      "number": "5511999999999",
      "name": "JoΓ£o",
      "step": 3,
      "last_contact": "2026-06-30T14:30:00",
      "status": "active"
    }
  ],
  "total": 42,
  "page": 1
}

GET /sessions/:number (Session Detail)

curl http://localhost:5000/api/v1/sessions/5511999999999 \
  -H "X-Bot-Token: facilit-dev-token"

Response:

{
  "number": "5511999999999",
  "name": "JoΓ£o",
  "step": 6.5,
  "last_contact": "2026-06-30T14:30:00",
  "status": "active",
  "geladeira_ok": true,
  "fogao_ok": false,
  "maquina_ok": false,
  "micro_ok": false,
  "retorno_apos_1h": false,
  "tamanho_item": null
}

PATCH /sessions/:number/resolve

curl -X PATCH http://localhost:5000/api/v1/sessions/5511999999999/resolve \
  -H "X-Bot-Token: facilit-dev-token"

Response:

{ "success": true }

DELETE /sessions/:number

curl -X DELETE http://localhost:5000/api/v1/sessions/5511999999999 \
  -H "X-Bot-Token: facilit-dev-token"

Response:

{ "success": true }

GET /metrics

curl http://localhost:5000/api/v1/metrics \
  -H "X-Bot-Token: facilit-dev-token"

Response:

{
  "active_sessions": 15,
  "completed_sessions": 128,
  "last_message_at": "2026-06-30T14:30:00",
  "messages_today": 47
}

Error Responses

All errors follow a consistent format:

{
  "error": "Description of the error"
}

| Status Code | Meaning | |---|---| | 200 | Success | | 401 | Missing or invalid X-Bot-Token | | 404 | Session not found | | 500 | Internal server error |


πŸ“‘ SSE Real-Time Events

The SSE stream at /api/v1/stream pushes real-time events to connected clients (e.g., the React Native companion app). No authentication is required for the SSE connection itself.

Connecting

// React Native / JavaScript
const eventSource = new EventSource('http://<server>:5000/api/v1/stream');

eventSource.addEventListener('bot_status', (e) => {
  const { active } = JSON.parse(e.data);
  console.log('Bot status:', active);
});

eventSource.addEventListener('alert', (e) => {
  const { name, number } = JSON.parse(e.data);
  console.log(`Alert: ${name} (${number}) needs attention!`);
});

Event Types

| Event Name | Payload | Trigger | |---|---|---| | connected | { request_id: string } | Client first connects | | bot_status | { active: bool } | Bot activated/deactivated | | new_message | { number: string, name: string, step: int } | New message processed | | session_update | { number: string, step: int } | Session state changed or deleted | | alert | { name: string, number: string } | Customer requires human attention |

Connection Lifecycle

  • Client connects β†’ receives connected event immediately
  • Server sends keep-alive comments every 15 seconds
  • On disconnect, client queue is automatically cleaned up
  • No reconnection logic is built into the server β€” clients should implement exponential backoff

πŸ€– Multi-Agent System

FacilitBot uses CrewAI to orchestrate 6 specialized agents. Each agent has a distinct role, goal, and backstory defined using CrewAI's agent framework.

Agent Overview

| Agent | Role | Responsibility | |---|---|---| | OrchestratorAgent | Orquestrador de Atendimento | Analyzes session state + incoming message β†’ determines next step | | QuoteAgent | Agente de CotaΓ§Γ£o | Collects product-specific data (fridge type, stove burners, machine type, microwave size) | | SalesAgent | Agente de Vendas | Presents promotions, handles yes/no decisions, processes offer selection | | MediaAgent | Agente de MΓ­dia | Executes text/audio/image/video sends via Z-API | | AlertAgent | Agente de Alerta | Triggers system notifications + SSE alerts when human attention required | | RetryAgent | Agente de Retorno | Monitors inactivity; sends 1-hour follow-up messages |

Crew Compositions

AtendimentoCrew (Main Flow)

  • Process: Sequential
  • Agents: Orchestrator β†’ Quote β†’ Sales β†’ Media
  • Triggered by: Incoming webhook messages

InterfaceCrew (Status Management)

  • Process: Sequential
  • Agents: GUIAgent β†’ StatusAgent
  • Responsibility: Bot activation/deactivation + SSE broadcasting

NotificacaoCrew (Alerts & Follow-up)

  • Process: Sequential
  • Agents: AlertAgent β†’ RetryAgent
  • Responsibility: Local notifications + inactivity monitoring

Deterministic vs. LLM

While CrewAI agents are defined with roles/goals/backstories (LLM-ready), the current implementation is fully deterministic β€” all step routing logic is hardcoded in OrchestratorAgent.determine_next_step() and step handlers in AtendimentoCrew. This ensures:

  • Predictable behavior without LLM costs
  • Fast response times (no API latency)
  • Reliable conversation flow that won't hallucinate

Extending with LLM

To enable LLM-powered conversations, add an OpenAI API key and configure the agents' llm parameter:

# In agent create() methods:
Agent(
    role="...",
    goal="...",
    backstory="...",
    llm="gpt-4o-mini",  # Add this line
    verbose=True,
)

πŸ”§ Development Guide

Code Organization Principles

  1. Single Responsibility: Each agent, crew, and module has exactly one purpose
  2. Dependency Injection: SessionManager and config are passed into components rather than imported globally
  3. Factory Functions: create_*_crew() functions enable testable component creation
  4. Thread Safety: All shared state access goes through SessionManager with locking
  5. Documented Modules: Every .py file has a module-level docstring explaining its responsibility

Adding a New Product

  1. Add the product entry to PRODUCT_OPTIONS in config.py:

    PRODUCT_OPTIONS = {
        # ... existing ...
        "10": {"name": "Novo ServiΓ§o", "step": 15},
    }
    
  2. Implement the step handler in atendimento_crew.py's process_message():

    elif current_step == 15:
        self._handle_new_service(phone, message, state)
    
  3. Add the route mapping in orchestrator_agent.py's determine_next_step():

    step_map = {
        # ... existing ...
        15: "new_service",
    }
    
  4. Add any new media files to config.py and midia_facilit/

Running Tests

# Run tests (when added)
pytest

# Type checking
mypy facilit_bot/

Code Style

  • Follow PEP 8
  • Use type hints throughout
  • Keep functions under 50 lines
  • Document public methods with Google-style docstrings
  • Use descriptive variable names (avoid abbreviations like msg, prefer message)

Debug Logging

The application uses Python's logging module with DEBUG level by default:

logging.basicConfig(
    level=logging.DEBUG,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S"
)

Werkzeug's HTTP logs are suppressed to WARNING level to reduce noise.


🩺 Troubleshooting

Common Issues

"Z-API webhook not receiving messages"

  1. Verify your ZAPI_INSTANCE_ID and ZAPI_TOKEN in .env
  2. Check that Z-API webhook URL points to http://<server-ip>:5000/webhook
  3. Ensure the bot is activated (X-Bot-Token API call or via companion app)
  4. Verify the server is reachable from the internet (use ngrok for local dev)

"Bot not responding to messages"

  • Check bot activation status: GET /api/v1/status
  • Verify InterfaceCrew.get_bot_status() returns True
  • Check logs for processing errors
  • Ensure media files exist in midia_facilit/

"Module not found" errors

  • Ensure you're running from the facilit_bot/ directory
  • Verify the virtual environment is activated
  • Run pip install -r requirements.txt to ensure all deps are installed

"ImportError: cannot import name 'X'"

The code uses sys.path.insert() to add the project root. If import errors persist:

# Install the package in development mode
cd facilit_bot
pip install -e .

"PermissionError: [Errno 13]" writing conversas.json

  • Check file permissions on the working directory
  • Ensure SESSIONS_FILE path is writable

"locale.Error: unsupported locale setting"

  • The application attempts to set pt_BR.UTF-8. If unavailable, it falls back gracefully.
  • On Windows, Brazilian Portuguese locale may not be available β€” this is non-critical.

Log Files

Logs are output to stdout. For persistent logging, redirect:

python main.py > facilit.log 2>&1

πŸ“„ License

This project is proprietary software. All rights reserved by the Facilit Team.


🀝 Contributing

Contributions are welcome! Please follow the development guide and ensure:

  1. All new code includes type hints and docstrings
  2. Thread safety is maintained for any shared state
  3. New API endpoints include Pydantic schemas
  4. Configuration is environment-driven (no hardcoded secrets)
  5. The conversation flow is documented with step numbers

<p align="center"> <sub>Built with ❀️ by the Facilit_Visual Team</sub> </p>

Contract & API

Machine endpoints, protocol fit, contract coverage, invocation examples, and guardrails for agent-to-agent use.

MissingGITHUB REPOS

Contract coverage

Status

missing

Auth

None

Streaming

No

Data region

Unspecified

Protocol support

OpenClaw: self-declared

Requires: none

Forbidden: none

Guardrails

Operational confidence: low

No positive guardrails captured.
Invocation examples
curl -s "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/snapshot"
curl -s "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/contract"
curl -s "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/trust"

Reliability & Benchmarks

Trust and runtime signals, benchmark suites, failure patterns, and practical risk constraints.

Missingruntime-metrics

Trust signals

Handshake

UNKNOWN

Confidence

unknown

Attempts 30d

unknown

Fallback rate

unknown

Runtime metrics

Observed P50

unknown

Observed P95

unknown

Rate limit

unknown

Estimated cost

unknown

Do not use if

Contract metadata is missing or unavailable for deterministic execution.
No benchmark suites or observed failure patterns are available.

Media & Demo

Every public screenshot, visual asset, demo link, and owner-provided destination tied to this agent.

Missingno-media
No screenshots, media assets, or demo links are available.

Related Agents

Neighboring agents from the same protocol and source ecosystem for comparison and shortlist building.

Self-declaredprotocol-neighbors
Github ReposUpdated 5h agoRank 70

AionUi

Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!

MCPOPENCLAW
Github ReposUpdated 6mo agoRank 70

activepieces

AI Agents & MCPs & AI Workflow Automation β€’ (~400 MCP servers for AI agents) β€’ AI Automation / AI Agent with MCPs β€’ AI Workflows & AI Agents β€’ MCPs for AI Agents

OPENCLAW
Github ReposUpdated 6mo agoRank 70

cherry-studio

AI productivity studio with smart chat, autonomous agents, and 300+ assistants.

MCPOPENCLAW
Github ReposUpdated 7mo agoRank 70

CopilotKit

The Frontend for Agents & Generative UI. React + Angular

OPENCLAW
Machine Appendix

Contract JSON

{
  "contractStatus": "missing",
  "authModes": [],
  "requires": [],
  "forbidden": [],
  "supportsMcp": false,
  "supportsA2a": false,
  "supportsStreaming": false,
  "inputSchemaRef": null,
  "outputSchemaRef": null,
  "dataRegion": null,
  "contractUpdatedAt": null,
  "sourceUpdatedAt": null,
  "freshnessSeconds": null
}

Invocation Guide

{
  "preferredApi": {
    "snapshotUrl": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/snapshot",
    "contractUrl": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/contract",
    "trustUrl": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/trust"
  },
  "curlExamples": [
    "curl -s \"https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/snapshot\"",
    "curl -s \"https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/contract\"",
    "curl -s \"https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/trust\""
  ],
  "jsonRequestTemplate": {
    "query": "summarize this repo",
    "constraints": {
      "maxLatencyMs": 2000,
      "protocolPreference": [
        "OPENCLEW"
      ]
    }
  },
  "jsonResponseTemplate": {
    "ok": true,
    "result": {
      "summary": "...",
      "confidence": 0.9
    },
    "meta": {
      "source": "GITHUB_REPOS",
      "generatedAt": "2026-10-09T23:50:22.174Z"
    }
  },
  "retryPolicy": {
    "maxAttempts": 3,
    "backoffMs": [
      500,
      1500,
      3500
    ],
    "retryableConditions": [
      "HTTP_429",
      "HTTP_503",
      "NETWORK_TIMEOUT"
    ]
  }
}

Trust JSON

{
  "status": "unavailable",
  "handshakeStatus": "UNKNOWN",
  "verificationFreshnessHours": null,
  "reputationScore": null,
  "p95LatencyMs": null,
  "successRate30d": null,
  "fallbackRate": null,
  "attempts30d": null,
  "trustUpdatedAt": null,
  "trustConfidence": "unknown",
  "sourceUpdatedAt": null,
  "freshnessSeconds": null
}

Capability Matrix

{
  "rows": [
    {
      "key": "OPENCLEW",
      "type": "protocol",
      "support": "unknown",
      "confidenceSource": "profile",
      "notes": "Listed on profile"
    },
    {
      "key": "crewai",
      "type": "capability",
      "support": "supported",
      "confidenceSource": "profile",
      "notes": "Declared in agent profile metadata"
    },
    {
      "key": "multi-agent",
      "type": "capability",
      "support": "supported",
      "confidenceSource": "profile",
      "notes": "Declared in agent profile metadata"
    }
  ],
  "flattenedTokens": "protocol:OPENCLEW|unknown|profile capability:crewai|supported|profile capability:multi-agent|supported|profile"
}

Facts JSON

[
  {
    "factKey": "vendor",
    "category": "vendor",
    "label": "Vendor",
    "value": "Vichagas07",
    "href": "https://github.com/ViChagas07/Facilit_Bot",
    "sourceUrl": "https://github.com/ViChagas07/Facilit_Bot",
    "sourceType": "profile",
    "confidence": "medium",
    "observedAt": "2026-10-09T18:14:39.726Z",
    "isPublic": true
  },
  {
    "factKey": "protocols",
    "category": "compatibility",
    "label": "Protocol compatibility",
    "value": "OpenClaw",
    "href": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/contract",
    "sourceUrl": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/contract",
    "sourceType": "contract",
    "confidence": "medium",
    "observedAt": "2026-10-09T18:14:39.726Z",
    "isPublic": true
  },
  {
    "factKey": "traction",
    "category": "adoption",
    "label": "Adoption signal",
    "value": "1 GitHub stars",
    "href": "https://github.com/ViChagas07/Facilit_Bot",
    "sourceUrl": "https://github.com/ViChagas07/Facilit_Bot",
    "sourceType": "profile",
    "confidence": "medium",
    "observedAt": "2026-10-09T18:14:39.726Z",
    "isPublic": true
  },
  {
    "factKey": "docs_crawl",
    "category": "integration",
    "label": "Crawlable docs",
    "value": "6 indexed pages on the official domain",
    "href": "https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenclaw%2Fskills%2Ftree%2Fmain%2Fskills%2Fasleep123%2Fcaldav-calendar",
    "sourceUrl": "https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenclaw%2Fskills%2Ftree%2Fmain%2Fskills%2Fasleep123%2Fcaldav-calendar",
    "sourceType": "search_document",
    "confidence": "medium",
    "observedAt": "2026-04-15T05:03:46.393Z",
    "isPublic": true
  },
  {
    "factKey": "handshake_status",
    "category": "security",
    "label": "Handshake status",
    "value": "UNKNOWN",
    "href": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/trust",
    "sourceUrl": "https://www.xpersona.co/api/v1/agents/crewai-vichagas07-facilit-bot/trust",
    "sourceType": "trust",
    "confidence": "medium",
    "observedAt": null,
    "isPublic": true
  }
]

Change Events JSON

[
  {
    "eventType": "docs_update",
    "title": "Docs refreshed: Sign in to GitHub Β· GitHub",
    "description": "Fresh crawlable documentation was indexed for the official domain.",
    "href": "https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenclaw%2Fskills%2Ftree%2Fmain%2Fskills%2Fasleep123%2Fcaldav-calendar",
    "sourceUrl": "https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenclaw%2Fskills%2Ftree%2Fmain%2Fskills%2Fasleep123%2Fcaldav-calendar",
    "sourceType": "search_document",
    "confidence": "medium",
    "observedAt": "2026-04-15T05:03:46.393Z",
    "isPublic": true
  }
]

Sponsored

Ads related to Facilit_Bot and adjacent AI workflows.