Connect Viber Business Bot REST API and AI Chat to Perfex CRM with PolyUtilities v3.7.0
Connecting a Viber Business Bot directly to Perfex CRM via the official Viber REST Bot API lets regional support and sales teams across Eastern Europe, Southeast Asia, and APAC manage customer chats inside Unified Inbox with zero third-party SaaS middleware fees. Built into PolyUtilities for Perfex CRM v3.7.0 by HeadRandom, the native Viber adapter (Poly_omnichat_viber_adapter) enforces strict HMAC-SHA256 X-Viber-Content-Signature validation, 2 MB payload limits, and 120 req/min/IP rate caps while pairing real-time Viber replies with AI Chat Copilot and 1-click CRM Lead, Ticket, and Estimate creation.
Why Official Viber REST Bot API Integration Matters for Perfex CRM
Viber remains a primary messaging channel for millions of B2B buyers and service clients across Vietnam, the Philippines, Greece, Ukraine, and Central Europe. Managing Viber inquiries on personal mobile devices causes lost leads, slow handoffs, and zero audit history inside Perfex CRM.
With the PolyUtilities v3.7.0 OmniChat & AI Hub release, your Viber Business Bot connects straight to your self-hosted Perfex instance. Inbound customer messages arrive in the Perfex CRM Unified Inbox, deduplicate automatically via Viber's message_token (vb_<token>), preserve media links for local downloading and AI analysis, and dispatch replies through https://chatapi.viber.com/pa/send_message with a 15s TLS-verified cURL call.

| Specification | PolyUtilities v3.7.0 Viber Bot Adapter | Manual Mobile App / SaaS Relay |
|---|---|---|
| API Protocol | Official Viber REST Bot API (set_webhook + send_message) |
Unofficial desktop sync or paid connector |
| Inbound Signature Check | HMAC-SHA256 X-Viber-Content-Signature using Bot Auth Token |
Often omitted in custom scripts |
| Webhook Protection | 2 MB max body (HTTP 413), 120 req/min/IP (HTTP 429) | Unprotected PHP endpoints |
| Credential Encryption | AES-256-CBC encrypted vault (enc:v1:...) in Perfex DB |
Plaintext tokens or cloud relay storage |
| AI Copilot & Auto-Reply | Multi-provider LLMs + 10s loop guard + daily USD budget cap | Paid add-on subscriptions ($49+ / month) |
| CRM Actions | 1-click Lead, Support Ticket, Estimate, Proposal, Task | Manual CRM data entry |
Prerequisites Before Registering Your Viber Bot Webhook
Verify these four items before calling set_webhook so Viber approves your endpoint on the first request:
- PolyUtilities v3.7.0 Installed and Enabled: Complete module setup with the PolyUtilities installation and setup guide and turn ON External Channels under PolyUtilities > OmniChat Settings > General.
- Trusted Full SSL Certificate Chain: Viber enforces strict TLS validation during
set_webhook. Self-signed certificates, expired certs, or servers missing an intermediate CA chain fail immediately. Confirm your domain scores clean SSL chain validation before calling Viber. - Active Viber Account for Bot Creation: You need a standard Viber mobile account to authenticate at
https://partners.viber.com/. - Automatic CSRF Exemption Active: PolyUtilities automatically excludes
poly_utilities/omnichat/webhook/*from Perfex cookie CSRF validation while enforcing cryptographic HMAC-SHA256 verification on every inbound POST request.
Step 1: Create a Viber Business Bot and Copy Your Auth Token
- Navigate to the Viber Admin Panel and sign in using your registered Viber phone number (confirm the 6-digit verification code sent inside the Viber app).
- Click Create Bot Account in the left menu.
- Complete the bot profile: upload a 400x400px brand avatar, set your Account Name, choose a unique URI (for example
mycompany_support), select category/subcategory, language, and enter your website and email. - Accept the Viber Bot terms and click Create.
- Copy the generated Auth Token displayed on the confirmation screen (also available anytime under Edit Info in the Viber Admin Panel).
Step 2: Save the Viber Channel in Perfex CRM FIRST
Just like Slack and Meta channels, you must save your Viber channel in Perfex CRM before executing set_webhook. As soon as you invoke Viber's set_webhook API, Viber sends a signed test webhook callback to your Perfex endpoint to confirm availability; Perfex validates X-Viber-Content-Signature against your saved auth_token immediately.
Go to PolyUtilities > OmniChat Settings > Channels and fill in the fields using this exact mapping:
| Perfex Settings Field | Required Value for Viber Bot | Critical Configuration Note |
|---|---|---|
| Channel Type | Viber Bot (viber) |
Routes webhook traffic to Poly_omnichat_viber_adapter |
| Channel Name | Display label (e.g. Viber Support Bot) |
Visible to agents in Unified Inbox |
| Account ID | Bot URI / Name (e.g. mycompany_support) |
Identifies your bot in multi-bot installations |
| Token / API Key / Password | Viber Bot Auth Token | Stored encrypted as auth_token for outbound send_message |
| App Secret / Webhook Secret | Paste the exact same Viber Bot Auth Token | Viber signs every webhook payload with the Auth Token itself |
| Verify Token / IMAP Host | Leave blank | Not required by Viber REST Bot API |
Why paste the Auth Token in both Token / API Key / Password and App Secret / Webhook Secret? Unlike Meta (which separates Access Token and App Secret), the Viber REST Bot API computes X-Viber-Content-Signature as HMAC-SHA256(raw_json_body, auth_token). Entering your Auth Token in both fields keeps your configuration consistent and ensures both outbound dispatch and inbound signature checks use the exact same encrypted secret.
Click Save Channel and verify the row is marked Active.
Step 3: Register Your Perfex Webhook via POST /pa/set_webhook
Copy the Viber Webhook URL shown in the Perfex Channels table:
https://your-crm-domain.com/poly_utilities/omnichat/webhook/viber
If you connect multiple Viber bots to one Perfex CRM installation, append ?account_id=mycompany_support matching your saved Account ID so Poly_omnichat_viber_adapter::parse_inbound() maps every inbound thread to the exact bot record.
Run the following curl command from your terminal (or Postman/Insomnia), replacing YOUR_VIBER_AUTH_TOKEN and your domain:
curl -X POST https://chatapi.viber.com/pa/set_webhook \
-H "Content-Type: application/json" \
-H "X-Viber-Auth-Token: YOUR_VIBER_AUTH_TOKEN" \
-d '{
"url": "https://your-crm-domain.com/poly_utilities/omnichat/webhook/viber",
"event_types": ["message", "conversation_started"]
}'
A successful registration returns JSON with "status": 0 and "status_message": "ok":
{
"status": 0,
"status_message": "ok",
"event_types": ["message", "conversation_started"]
}
How PolyUtilities Verifies Every Inbound Viber Event
When a customer messages your Viber Bot, Poly_omnichat_webhook.php runs a strict 4-step pipeline before storing anything:
- Abuse & Size Guards: Rejects payloads over 2 MB with HTTP
413and IP floods above 120 req/min with HTTP429. - Cryptographic Verification:
Poly_omnichat_viber_adapter::verify_signature()extractsX-Viber-Content-Signature, computeshash_hmac('sha256', $raw_body, $auth_token), and validates with constant-timehash_equals(). Any tampered request receives HTTP403. - Deduplication & Media Parsing: Extracts
sender.id,sender.name,message.text, andmessage.media, deduplicating retries withvb_<message_token>. When Auto-Download Inbound Media is active in AI Hub, images and audio attachments pass through OmniChat's SSRF allowlist and Image CDR / Anti-Malware pipeline before local storage. - Outbound Delivery Verification: When an agent or AI replies,
send_outbound()posts{"receiver":"<user_id>","type":"text","text":"..."}tohttps://chatapi.viber.com/pa/send_messagewithX-Viber-Auth-Tokenand confirms HTTP200plus"status": 0.

Automating Viber Conversations with AI Copilot and 1-Click CRM Actions
Once live messages flow into Perfex CRM, connect your Viber channel to the Multi-Provider AI Chat Hub & Key Rotation Pool to accelerate support and capture sales opportunities 24/7:
- AI Copilot Composer Tools: Generate full contextual replies with Draft, pick from 3 Smart Suggestions, fix grammar, translate between Vietnamese, English, Greek, or Russian in 1 click, and summarize long buyer inquiries directly inside Unified Inbox.
- 24/7 Automation Rules & After-Hours AI Auto-Reply: Open OmniChat Settings > Automation Rules and create rules such as Trigger
Outside Business Hours+ ConditionChannel Type equals viber-> ActionTrigger AI Auto-Reply, or TriggerInbound Message+Message Body contains quote-> ActionAdd Tag: viber-salesandAssign Staff. Every AI auto-reply respects the configurable 10s per-conversation cooldown and daily USD budget cap ($0.15/$0.60 per 1M tokens ongpt-4o-minior free-tier Gemini 2.5 Flash rotation). - 1-Click Conversion to Perfex Leads, Tickets, and Estimates: From the right-hand CRM Context Panel, convert any Viber buyer chat into a Perfex Lead (automatically linking the Viber contact identity), open a Support Ticket pre-populated with the last 10 messages (ready for the Perfex CRM Ticket AI Copilot & Slash Macros), or launch pre-filled Estimate and Proposal editors in 1 click.

Troubleshooting Viber set_webhook and Delivery Failures
status: 1(Invalid URL) or SSL Handshake Error onset_webhook: Your server is missing an intermediate SSL certificate or uses a self-signed cert. Verify the complete certificate chain with an online SSL checker and ensure Cloudflare proxy rules do not block Viber's bot user agent.- HTTP 403 Invalid Signature on Inbound Messages: Confirm you saved the Viber channel in Perfex FIRST and pasted the exact Auth Token from
partners.viber.comwith zero leading or trailing spaces. - Bot Receives Messages but Outbound Replies Fail (
status != 0): Verify the Auth Token was not regenerated in the Viber Admin Panel; Viber invalidates old tokens immediately when rotated, and note that Viber requires the user to initiate or subscribe to the bot before outbound replies are accepted.
Ready to bring Viber, WhatsApp, Messenger, Instagram, Telegram, SMS, Slack, Zalo OA, and Email into one self-hosted Perfex workspace? Check out PolyUtilities for Perfex CRM on HeadRandom.
Frequently Asked Questions (FAQ)
Why do I paste the Viber Auth Token into both Token and App Secret in Perfex CRM?
Viber does not issue a separate App Secret for webhooks. Instead, the Viber REST Bot API uses the Bot Auth Token both as the X-Viber-Auth-Token header for outbound send_message requests and as the HMAC-SHA256 signing key for inbound X-Viber-Content-Signature validation.
Why did Viber reject my set_webhook call even though my Perfex site loads in Chrome?
Desktop browsers sometimes cache intermediate CA certificates that server-to-server clients like Viber do not. Viber requires a complete, trusted SSL certificate chain served directly by Nginx or Apache, plus an immediate HTTP 200 response from poly_utilities/omnichat/webhook/viber.
Can I run multiple Viber Business Bots on a single Perfex CRM instance?
Yes. Save each Viber Bot with a distinct Account ID (its Bot URI) in OmniChat Settings > Channels, then register each bot's webhook URL with ?account_id=YOUR_BOT_URI appended so OmniChat routes inbound payloads to the matching channel and Auth Token.
Does PolyUtilities charge per-message fees for Viber Business Bot replies?
No. PolyUtilities for Perfex CRM connects directly to https://chatapi.viber.com/pa/send_message with $0 third-party middleware fees; you only follow Viber's official bot commercial terms if applicable to your region.
Can AI Auto-Reply respond to Viber customers automatically outside working hours?
Yes. Configure your business hours under OmniChat Settings > Business Hours & AIO 2.0, enable AI Hub, and create an Automation Rule matching Trigger Outside Business Hours + Channel Type equals viber -> Action Trigger AI Auto-Reply.
PolyUtilities boosts Perfex CRM with powerful customization and workflow enhancements. Create multi-level menus, group menus by purpose, embed iframe links, open content in popups, and reorganize system navigation with drag-and-drop. Add dynamic widgets across dozens of display positions, use right-click navigation, manage custom JS/CSS, support multi-company and multi-address structures, and convert selected text into tasks instantly. Combined with banners, announcements, quick-access shortcuts, and many smart utilities, PolyUtilities turns Perfex CRM into a faster, cleaner, and highly personalized workspace for every team member.
Need a Custom Perfex CRM Module, Bug Fix, or CodeIgniter 4 Upgrade?
Avoid broken updates, PHP 8.2-8.4 errors, and risky core edits. HeadRandom provides custom Perfex CRM module development, upgrade, and bug-fixing services for any third-party or custom module on your Perfex CRM installation, plus upgrading Perfex CRM from CodeIgniter 3 to CodeIgniter 4 via IgniteCore for Perfex CRM.
Develop new custom modules from scratch, patch bugs or hook conflicts on existing client modules, and update legacy code for clean PHP 8.2-8.4 compatibility with zero core file hacks. View Perfex CRM module development scope.
Migrate your Perfex CRM runtime to CodeIgniter 4 (4.7.6) using IgniteCore for Perfex CRM (independent module by HeadRandom) with Dual-Mode CI3 fallback, 32% to 75% lower latency, 50% less RAM, and custom CI4 porting for third-party modules. See CI3 to CI4 upgrade options.
Combine 2+ HeadRandom services (Custom Module, IgniteCore CI4 Upgrade, or Website Care) to save 30% automatically.