Setting up order status notifications in WhatsApp 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Setting Up Order Status Notifications in WhatsApp for 1C-Bitrix

WhatsApp does not provide a public Bot API like Telegram. Sending notifications to customers in WhatsApp requires using the WhatsApp Business API (the official route through Meta) or unofficial gateways. The choice of method determines the cost, reliability, and compliance with platform rules — the latter matters because accounts that violate the TOS are blocked without warning.

Integration Options

1. WhatsApp Business API (official)

Access via Meta Cloud API or through a BSP (Business Solution Provider): Twilio, MessageBird, WABA360, i2crm. Requires business verification with Meta and approval of message templates. Templates go through moderation — not all formats are permitted. Pricing is per outgoing message.

2. WhatsApp Web-based gateways (unofficial)

Chat-api.com, green-api.com, and similar services. They work by emulating WhatsApp Web with a phone number connected to an account. The risk of being blocked is higher, but integration is simpler and cheaper. For order notifications at low volume (<500 messages/day) — a viable option.

Integration via Green API (gateway)

Green API provides a REST API with a minimal entry threshold. A free instance is available for testing.

class WhatsAppService
{
    private string $apiUrl;
    private string $idInstance;
    private string $apiToken;

    public function __construct()
    {
        $settings = \Bitrix\Main\Config\Configuration::getValue('custom');
        $this->idInstance = $settings['whatsapp_instance_id'];
        $this->apiToken   = $settings['whatsapp_api_token'];
        $this->apiUrl     = "https://api.green-api.com/waInstance{$this->idInstance}";
    }

    public function sendMessage(string $phone, string $message): bool
    {
        // Normalize phone to format [email protected]
        $phone = preg_replace('/[^0-9]/', '', $phone);
        if (str_starts_with($phone, '8')) {
            $phone = '7' . substr($phone, 1);
        }
        $chatId = $phone . '@c.us';

        $url = "{$this->apiUrl}/sendMessage/{$this->apiToken}";
        $payload = json_encode([
            'chatId'  => $chatId,
            'message' => $message,
        ]);

        $ch = curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_POST           => true,
            CURLOPT_POSTFIELDS     => $payload,
            CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT        => 10,
        ]);
        $response = json_decode(curl_exec($ch), true);
        curl_close($ch);

        return isset($response['idMessage']);
    }
}

Order Event Handler

// /local/php_interface/init.php
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
    'sale',
    'OnSaleOrderStatusChange',
    function (\Bitrix\Main\Event $event) {
        $order = $event->getParameter('ENTITY');
        $statusId = $order->getField('STATUS_ID');

        // Get the customer's phone number from order properties
        $propCollection = $order->getPropertyCollection();
        $phoneProp = $propCollection->getItemByOrderPropertyCode('PHONE');
        $phone = $phoneProp ? $phoneProp->getValue() : null;

        if (!$phone) {
            return;
        }

        $statusTexts = [
            'N' => 'Your order #%d has been received. Please await confirmation.',
            'P' => 'Order #%d has been handed to the courier.',
            'D' => 'Order #%d is waiting for you at the pickup point.',
            'F' => 'Order #%d is complete. Thank you!',
            'X' => 'Order #%d has been cancelled.',
        ];

        if (!isset($statusTexts[$statusId])) {
            return;
        }

        $message = sprintf($statusTexts[$statusId], $order->getId());

        $wa = new WhatsAppService();
        $wa->sendMessage($phone, $message);
    }
);

Key Restrictions of the WhatsApp Business API

When using the official Meta API (Cloud API), messages sent without prior opt-in from the user are prohibited. Message templates must be approved by Meta before sending. Example template structure:

{
  "name": "order_status_update",
  "language": { "code": "en" },
  "components": [
    {
      "type": "body",
      "text": "Your order #{{1}} status has been updated: {{2}}."
    }
  ]
}

Request to the Meta Cloud API:

$response = Http::post(
    "https://graph.facebook.com/v18.0/{$phoneNumberId}/messages",
    [
        'messaging_product' => 'whatsapp',
        'to'                => $recipientPhone,
        'type'              => 'template',
        'template'          => [
            'name'       => 'order_status_update',
            'language'   => ['code' => 'en'],
            'components' => [[
                'type'       => 'body',
                'parameters' => [
                    ['type' => 'text', 'text' => $orderId],
                    ['type' => 'text', 'text' => $statusText],
                ],
            ]],
        ],
    ]
);

Setup Timeline

Integration via Green API or a similar gateway, event handler, status-based message formatting — 4–8 hours. Official WhatsApp Business API with Meta verification, templates, and testing — 3–5 business days.