Hi there is a site in pure HTML with a popup form. How to make the data from the form fall into cRM Bitrix. I looked in Google but it shows how to place the form that the bitrix offers (She has her own stylization). Interests me as an existing form (made in my dis) to integrate with this cRM

  • And what is not suitable for using the standard Bitrix24 form, but using your own styles? - Kyper

1 answer 1

This can be done by creating an incoming web hook on the portal.

This article describes in detail how this can be done.

Here's an example of how to transfer to Bitrix24 lead from the order form of goods in the store:

// массив статических значений передаваемых полей лида для примера, заменить на значения из полей формы оформаления заказа $defaults['TITLE'] = 'НАЗВАНИЕ ЛИДА'; $defaults['NAME'] = 'ТЕСТОВОЕ ИМЯ'; $defaults['LAST_NAME'] = 'ФАМИЛИЯ ТЕСТ'; $defaults['ASSIGNED_BY_ID'] = 1; //ОТВЕТСВЕННЫЙ $defaults['PHONE'] = array(array("VALUE" => '434873248932', "VALUE_TYPE" => "WORK")); $defaults['EMAIL'] = array(array("VALUE" => '43487@bk.ru', "VALUE_TYPE" => "WORK")); $defaults['COMMENTS'] = 'тЕСТОВЫЙ КОММЕНТАРИЙ'; //статисеский массив передаваемых товаров, заменить на массив содеражащий по каждому из товаров выбранных пользователем информацию о названии товара, цене за 1 единицу и количеству $products_example = [ [ 'PRODUCT_NAME' => 'Товар 1', 'PRICE' => 100.00, 'QUANTITY' => 3, ], [ 'PRODUCT_NAME' => 'Товар 2', 'PRICE' => 200.00, 'QUANTITY' => 13, ], ]; //строка обработчик которая будет выполнять добавление лида в Битрикс24 $queryUrl = 'https://portalname.bitrix24.region_domain/rest/user_id/webhook_token/crm.lead.add.json'; $queryData = http_build_query(array( 'fields' => array( "TITLE" => $defaults['TITLE'], //поле "Название лида" "NAME" => $defaults['NAME'], //поле "Имя" "LAST_NAME" => $defaults['LAST_NAME'], //поле "Фамилия" "STATUS_ID" => "NEW", //не менять. все лиды должны попдать в этом статусе "OPENED" => "N", //этот параметр менять не нужно "ASSIGNED_BY_ID" => $defaults['ASSIGNED_BY_ID'], //Числовой идентификатор пользователя который будет назначен ответственным за лид. Можно узнать в Битрикс24 "PHONE" => $defaults['PHONE'], //поле "Телефон" "EMAIL" => $defaults['EMAIL'], //поле "Email" "COMMENTS" => $defaults['COMMENTS'], //поле "Комментарий", "SOURCE_ID" => "WEB", ), 'params' => array("REGISTER_SONET_EVENT" => "Y") )); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $queryUrl, CURLOPT_POSTFIELDS => $queryData, )); $result = curl_exec($curl); curl_close($curl); $result = json_decode($result, 1); writeToLog($result, 'Лид'); //строка обработчик для привязки заказанных товаров к лиду $queryUrl = 'https://portalname.bitrix24.region_domain/rest/user_id/webhook_token/crm.lead.productrows.set.json'; $queryData = http_build_query(array( 'id' => $result['result'], 'rows' => $products_example, )); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $queryUrl, CURLOPT_POSTFIELDS => $queryData, )); $result = curl_exec($curl); curl_close($curl); $result = json_decode($result, 1); writeToLog($result, 'товары лида'); if (array_key_exists('error', $result)) { writeToLog($result['error_description'], "Ошибка при сохранении лида: "); }