1C-Bitrix Integration with SendPulse
SendPulse is a multichannel service covering email, SMS, Viber, push notifications, and chatbots. For projects in Russia and the CIS, it is more convenient than Mailchimp: ruble-denominated plans, Russian-language support, no payment processing complications. API v2 provides a full set of methods for managing subscribers and mailings.
Authentication in the SendPulse API
SendPulse uses OAuth 2.0 Client Credentials. Obtain a token before each session:
class SendPulseClient {
private string $apiId;
private string $apiSecret;
private ?string $token = null;
public function __construct() {
$this->apiId = COption::GetOptionString('site', 'sendpulse_id');
$this->apiSecret = COption::GetOptionString('site', 'sendpulse_secret');
}
private function getToken(): string {
// Cache the token for 1 hour
$cached = \Bitrix\Main\Data\Cache::createInstance();
if ($cached->initCache(3500, 'sendpulse_token', '/sendpulse/')) {
return $cached->getVars()['token'];
}
$http = new \Bitrix\Main\Web\HttpClient();
$response = json_decode($http->post('https://api.sendpulse.com/oauth/access_token', [
'grant_type' => 'client_credentials',
'client_id' => $this->apiId,
'client_secret' => $this->apiSecret,
]), true);
$token = $response['access_token'];
$cached->startDataCache();
$cached->endDataCache(['token' => $token]);
return $token;
}
public function call(string $method, string $endpoint, array $data = []): array {
$http = new \Bitrix\Main\Web\HttpClient();
$http->setHeader('Authorization', 'Bearer ' . $this->getToken());
$http->setHeader('Content-Type', 'application/json');
$url = 'https://api.sendpulse.com/' . ltrim($endpoint, '/');
$response = $method === 'POST'
? $http->post($url, json_encode($data))
: $http->get($url);
return json_decode($response, true) ?? [];
}
}
Managing address books
An address book (mailing list) in SendPulse is a subscription list. Retrieve the book ID via GET /addressbooks and store it in COption.
Adding a subscriber:
public function addContact(string $email, array $variables = []): void {
$this->call('POST', '/addressbooks/' . $this->listId . '/emails', [
'emails' => [[
'email' => $email,
'variables' => $variables, // [['name'=>'name','value'=>'Ivan']]
]],
]);
}
Variables are analogous to Mailchimp's merge fields — name, phone, city, orders_count, and any custom fields.
Push notifications via SendPulse
A unique feature of SendPulse is browser push notifications. Subscribers who have granted permission receive pushes even without the site being open.
Integration in the Bitrix template:
<!-- SendPulse Push script -->
<script>
(function(d,w) {
var n = d.getElementsByTagName('script')[0];
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://cdn.sendpulse.com/push/scripts/push.js';
n.parentNode.insertBefore(s, n);
w.PushwooshSDK_onLoad = function() {
Pushwoosh.init({ 'applicationCode': '<?= COption::GetOptionString("site","sendpulse_push_id") ?>' });
};
})(document, window);
</script>
When an order is placed, send an order confirmation push via the API:
$sp->call('POST', '/push/tasks', [
'task' => [
'list_id' => $pushListId,
'subject' => 'Order #' . $orderId . ' received',
'body' => 'Your order totalling ' . $orderPrice . ' has been accepted for processing',
'send_date' => 'now',
'filter' => ['variable' => 'user_id', 'operator' => '=', 'value' => $userId],
],
]);
Automation via SendPulse Automation 360
SendPulse Automation 360 is a visual editor for trigger-based sequences. Trigger a sequence via an API event:
// Trigger the "welcome_series" automation for a new subscriber
$sp->call('POST', '/flows/run', [
'flow_id' => 'FLOW_ID_FROM_SENDPULSE',
'email' => $email,
'variables'=> ['order_id' => $orderId, 'product_name' => $productName],
]);
A sequence in SendPulse can include: email → 2-day delay → SMS → if email not opened → Viber message.
| Task | Effort |
|---|---|
| OAuth client + basic synchronization | 4–5 h |
| Push notifications | 3–5 h |
| Trigger events for automation | 5–7 h |
| Multichannel scenarios (email + SMS + Viber) | 6–10 h |







