Support Center > Knowledge Base> Article: Streaming API - Eventing API (Webhooks)

Streaming API - Eventing API (Webhooks)

Article ID: 36704 Email Print
Question
Is there a way for LiveHelpNow to push customer data such as Name, Email, Chat transcript, Offline message, etc. to my contact management system automatically, in realtime?

Answer
* This article should be read by a technical web person in your organization

 

 
Introducing LiveHelpNow Eventing API (Webhooks)
No more manually calling an API, no more transfer delays, and no more frustrated developers. Eventing, which acts as a Streaming API, will allow you to receive fully customizable data and push it to any resource on the web at the exact moment a LiveHelpNow event such as a chat starting or a chat closing occurs.


 
 
How does LiveHelpNow Eventing API work?
 When an event you have subscribed to, such as "Chat Opened", "Chat assigned", "Chat Closed", "Offline Message", etc. occurs for your account, a payload is constructed per your instructions with data formatted in the way you want and is sent to the resource on the web you have setup to receive the payload and process it.


 
 
I'm excited! How do i set it up?
  1. Login to your account and go to Admin Panel->My account->Integrations and select "Events"
  2.  Click on "Add Event"
  3. Select Event, Event Type, Verb, Headers (optional), Construct your payload by clicking on available tokens for the event.
    Provide URL to submit the data to.

    * We highly recommend to enable "Test" mode for the event and test the event first. While in test mode, the Event will email you the PayLoad so you can see whether the format is what you expected and then switch Event to live mode by unchecking "Test" mode and have the data sent to your "Live" URL for processing.
    Eventing API setup

 

How do i properly receive the data?
The PayLoad is sent as InputStream
Here's PHP example on how to receive InputStream data:
<?php

// To access your headers being sent
$headers = array();
foreach($_SERVER as $headerName => $headerValue){
	if(substr($headerName, 0, 5) == "HTTP_"){ // This will eliminate no request headers
		array_push($headers, array($headerName, $headerValue));
	}
}
// The $headers variable will now contain all HTTP Request headers within a multidimensional array

// The variable below with get the payload from the LiveHelpNow Eventing API 

$payload = $HTTP_RAW_POST_DATA;

?>
Here's ASP.NET example showing reception of InputStream.
VB
Private Function RequestInputStreamToString(oStream As System.IO.Stream) As String
        Dim sb As New System.Text.StringBuilder()
        Dim streamLength As Integer
        Dim streamRead As Integer

        streamLength = Convert.ToInt32(oStream.Length)
        Dim streamArray As [Byte]() = New [Byte](streamLength - 1) {}

        streamRead = oStream.Read(streamArray, 0, streamLength)

        For i As Integer = 0 To streamLength - 1
            sb.Append(Convert.ToChar(streamArray(i)))
        Next

        Return sb.ToString()
End Function


Response.Write(RequestInputStreamToString(Request.InputStream))
C#
private string RequestInputStreamToString(System.IO.Stream oStream)
{
	System.Text.StringBuilder sb = new System.Text.StringBuilder();
	int streamLength = 0;
	int streamRead = 0;

	streamLength = Convert.ToInt32(oStream.Length);
	Byte[] streamArray = new Byte[streamLength];

	streamRead = oStream.Read(streamArray, 0, streamLength);

	for (int i = 0; i <= streamLength - 1; i++) {
		sb.Append(Convert.ToChar(streamArray[i]));
	}

	return sb.ToString();
}

Response.Write(RequestInputStreamToString(Request.InputStream))
 
Should you have any questions or concerns please do NOT hesitate to chat with us or submit a ticket for support, we are here to help!
 

Related articles

Article Details
Views: 15783 Created on: Jul 29, 2013
Date updated: Jun 07, 2016

Poor Outstanding