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
-
OnOpenLineMessageAddhandler 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_SOURCEinb_sale_orderfor attribution - Report by channels: share of orders from VK, Telegram, Instagram in total volume







