Introduction

The usage of webhook will solve the task of receiving the data about the leads from:

The received data can be sent to your own CRM. 

Description

During the different events, the data is sent as GET-parameters to the addresses specified in the Deals handler address field and Address to receive additional information on the deal field in the integration settings. You can use this option while configuring your own CRM. 

Event type – Deal

EventDescription
Lead from the Lead hunterThe data will be sent if the Send to CRM option is activated in the Lead hunter. 
Call from the Calltracking

The data will be sent during the phone call via Calltracking.

(warning) The data will be sent only for the first cost of the phone number. The data from the repeated calls won't be sent.

Lead from CRMThe data will be sent if you configured the integration with CRM.

Parameters of the request 

ParameterExampleDescription
id90The ID of the lead
visit12852Visit number with the source of the lead
title

Incoming call from 11230001122
Caught lead: 11230001122
CRM Lead

For the call from Calltracking
For the lead from Lead Hunter 
For the lead from CRM 
text

Data of the form: 11230001122
Promo-code: 1674
Landing page: http://site.com
Date of dispatch: 17:22 15.04.2015

Additional information about the deal that is usually sent as a comment to the deal. 
For calltracking, the information about the dialed number is also sent in this field.
nameRobertThis parameter is used for the Name field in the Lead hunter. 
phone+11230001122The dialed number or the Phone field in the Lead hunter. 
emailemail@mail.comThis parameter is used for the email address field in the CRM form
data

This parameter is used for Lead Hunter
data is a JSON parameter that contains the page key with the landing page value.

Additional fields and the values of additional fields are also transmitted to the data parameter.

created_date2015-06-28 09:12:54Date and time of receiving the lead by Roistat (UTC+0)
token6512bd43d9caa6e02c990b0a82652dca

The token is generated from login and password that are specified in the integration settings in the following format:

 md5('username' + 'password')

actionleadEvent type

Example of a request:

http://{webhook_url}/?user=&token={id_token}&action=lead&visit=9&id=6&title={title}&text={text}&name={name}&phone={phone}&email={email}&data={"page":"http:\/\/site.com\/"}&created_date={yyyy-mm-dd+hh%3Amin%3Asec}

Event type – additional information

NotificationDescription
Duplicated leadInformation about the call from the client that already has a deal in CRM
Conversation history from CRMThe full history of conversation between the client and manager

Parameters of the request 

ParameterExampleDescription
leadId155Lead ID
titleDuplicated leadTitle of the lead
textDuplicated lead from {Client name} {Email address} {Phone number} with a {Message in the lead}Notification message 
actionmessageEvent type
userdemouserUser name (specified in the integration settings) 
token6512bd43d9caa6e02c990b0a82652dcaThe token is generated from login and password that are specified in the integration settings in the following format: md5('username' + 'password')

Configuration

1) Open the Roistat API: own CRM integration settings and specify the webpage addresses (webhook) in the Deals handler address field and Address to receive additional information on the deal field. For example, we will use the http://site.com/webhook.php address for both types of events. 

2) On the http://site.com/webhook.php address, place the script that will receive the GET-parameters and operate with them.

(информация) Roistat should receive the following response: 

{
"status" : "ok",
"order_id" : "deal_ID_"
}

If Roistat does not receive this response, the data will be sent repeatedly once per several minutes until Roistat receives it. 

The example of lead for receiving the information about the lead from the Lead hunter: 

<?php
 
if (array_key_exists('id', $_GET)) {
    $leadId = $_GET['id']; // Lead ID, for example "123"
    $leadTitle = $_GET['title']; // Title of the lead, for example: "Caught lead: 11231234567"
    $leadText = $_GET['text']; // The containment of the Lead hunter form, for example: "11231234567"
    $roistatVisit = $_GET['visit']; // Visit number, the value of the roistat_visit cookie, for example: "1234"
    $data = json_decode($_GET['data'], true); // data - is a JSON parameter, that contains page key and its value - Landing page
    $page = $data['page']; // Landing page of the lead, for example: "http://site.com"
    
	// The information about the deal is sent CRM
    
	// Roistat resumes the ok response and the ID of a deal if everything is OK. If this response won't be transmitted, the information about the lead will be sent to this page once per several minutes:
    exit(json_encode(array("status" => "ok", "order_id" => $orderId))); 
}