Setting up sales through social networks in 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
    1212
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815
  • 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
    565
  • 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
    657
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    980

Configuring Sales Through Social Networks in 1C-Bitrix

Store accepts orders via site, but managers daily process dozens of requests from VK, Telegram and Instagram manually: copy to notepad, create order in admin, reply to customer. Not a process, it's chaos. Bitrix24 has built-in omnichannel tools, but they need proper linking with online store.

Open lines: central entry point

imopenlines module (Open Lines) — mechanism for aggregating messages from different channels into single Bitrix24 chat queue. Supported channels: VKontakte, Telegram, Viber, Facebook Messenger, Instagram Direct, WhatsApp (via WABA).

When setting up open line, each incoming request from social network creates new chat in CRM. Routing parameters: even distribution by managers, by channel owners, or by working hours. Settings stored in b_imopenlines_config.

VK integration with store

VK allows creating store directly in VKontakte via VK Shopping API. Product catalog synced via feed — same YML used for ads. But VK store sale — not order in Bitrix: user submits request via VK interface, data comes as incoming message to open line.

For automatic Bitrix order creation on incoming VK message need open lines event handler:

AddEventHandler('imopenlines', 'OnOpenLineMessageAdd', function(\Bitrix\Main\Event $event) {
    $message    = $event->getParameter('message');
    $channelType = $message['CHANNEL_TYPE'] ?? '';

    if ($channelType !== 'vk') return;

    // Extract product data from VK structured message
    $orderData = parseVkOrderMessage($message['MESSAGE']);
    if (!$orderData) return;

    // Create lead in CRM
    $crmLead = new \CCrmLead(false);
    $crmLead->Add([
        'TITLE'       => 'Order from VK: ' . $orderData['product'],
        'STATUS_ID'   => 'NEW',
        'SOURCE_ID'   => 'VK',
        'PHONE'       => [['VALUE' => $orderData['phone'], 'VALUE_TYPE' => 'WORK']],
        'UF_CRM_1_VK_ORDER_ID' => $orderData['order_id'],
    ]);
});

Telegram: integration via Bot API

Telegram bot can accept orders directly via custom scenario or via open lines. Open lines simpler to set up: all messages go to Bitrix24 without writing bot.

For more complex scenario — own Telegram bot with interactive buttons and catalog. Bot registers webhook via setWebhook, PHP endpoint handles commands and via Bitrix REST API creates orders in b_sale_order:

// /local/ajax/telegram-webhook.php
$update = json_decode(file_get_contents('php://input'), true);

if (isset($update['callback_query'])) {
    $data   = $update['callback_query']['data'];
    $chatId = $update['callback_query']['message']['chat']['id'];

    if (str_starts_with($data, 'order_product_')) {
        $productId = (int)str_replace('order_product_', '', $data);
        // Create order via Bitrix REST or directly via sale API
        $orderId = createOrderFromTelegram($chatId, $productId);
        sendTelegramMessage($chatId, "Order #{$orderId} created. Manager will contact you.");
    }
}

Catalog synchronization with social networks

Catalog relevance on VK and other platforms ensured by regular feed updates. Problem: VK updates catalog once per 24 hours in auto mode. Forced update via VK API — market.editAlbum or via VK Ads cabinet.

For Telegram catalog relevance maintained differently: bot on request query real-time requests data via Bitrix API — price and stock always current at moment of request.

Passing UTM marks for analytics

Orders from social networks must be attributed. On order creation via open lines event handler add UTM marks to custom order field:

$order->setField('USER_DESCRIPTION', 'source=vk&medium=social&campaign=openlines');

Or create custom field UF_ORDER_UTM_SOURCE for b_sale_order and fill on order creation from social network.

What we configure

  • Open lines for VK, Telegram, Instagram with routing by managers
  • OnOpenLineMessageAdd handler for automatic lead/order creation
  • Regular YML feed updates for VK catalog (every 2 hours via agent)
  • If needed — Telegram bot with inline buttons and direct order creation
  • Custom field UF_ORDER_SOURCE in b_sale_order for attribution
  • Report by channels: share of orders from VK, Telegram, Instagram in total volume