All docs This doc
Skip to end of metadata
Go to start of metadata


Overview

The following operations allow you to work with chats. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with chats, see Sample configuration

OperationDescription
getChatByIdRetrieves a single chat item for the given Chat ID.
listChatsRetrieves finished chats and left messages.

sendChatTranscriptByEmail

Sends a chat transcript to an e-mail address.

Operation details

This section provides further details on the operations related to chats.

Retrieving a single chat item 

The getChatById operation retrieves a single chat item for the given Chat ID. 

getChatById
<livechat.getChatById>
	<chatId>{$ctx:chatId}</chatId>
</livechat.getChatById>
Properties
  • chatId: The chat ID to return a single chat.
Sample Request

Following is a sample REST/JSON request that can be handled by the getChatById operation.

Sample request for getChatById
{
	"apiUrl":"https://api.livechatinc.com",
	"login":"anu.thushi@gmail.com",
	"apiKey":"81df74bda524d8027f0717cffaf318b2",
	"chatId":"NJHV7BG1C5"
}
Related LiveChat Documentation  

Retrieving finished chats and left messages

The listChats operation retrieves finished chats and left messages. 

listChats
<livechat.listChats>
    <queued>{$ctx:queued}</queued>
    <tag>{$ctx:tag}</tag>
    <dateTo>{$ctx:dateTo}</dateTo>
    <query>{$ctx:query}</query>
    <includePending>{$ctx:includePending}</includePending>
    <agent>{$ctx:agent}</agent>
    <goal>{$ctx:goal}</goal>
    <timezone>{$ctx:timezone}</timezone>
    <rate>{$ctx:rate}</rate>
    <page>{$ctx:page}</page>
    <visitorId>{$ctx:visitorId}</visitorId>
    <hasGoal>{$ctx:hasGoal}</hasGoal>
    <tagged>{$ctx:tagged}</tagged>
    <dateFrom>{$ctx:dateFrom}</dateFrom>
	<group>{$ctx:group}</group>
</livechat.listChats>
Properties
  • queued: 1 or 0. If 1 is passed, returns chats started from the queue.
  • tag: Filters chats by a specified tag.
  • dateTo: Returns chats with any of their activities matching the date. Defaults to "today".
  • query: Returns chats containing the query.
  • includePending: 1 or 0. Indicates whether to include chats that have not yet ended. Pending chats can be recognized by the "pending : true" attribute. They may appear with some delay due to caching reasons. 
  • agent: Returns chats for a given agent login.
  • goal: Returns chats for a given goal ID.
  • timezone: The timezone in the TZ format (e.g. America/Phoenix).
  • rate: Filters chats considering their rating status. Available values: "rated", "not_rated", "rated_good", "rated_bad".
  • page: The page number, defaults to 1.
  • visitorId: Returns chats with a specified visitor ID.
  • hasGoal: 1 or 0. If 1 is passed, returns chats having any goal.
  • tagged: 1 or 0. If 1 is passed, returns chats having any tag. If 0 is passed, returns chats without any tag.
  • dateFrom: Returns chats with any of their activities matching the date. Defaults to the beginning of time.
  • group: Returns chats for the given group ID.
Sample Request

Following is a sample REST/JSON request that can be handled by the listChats operation.

Sample request for listChats
{
	"apiUrl":"https://api.livechatinc.com",
	"login":"anu.thushi@gmail.com",
	"apiKey":"81df74bda524d8027f0717cffaf318b2",
	"includePending":"1"
}

Note

There are more optional parameters available. For more information on the usage of these parameters please check the API document. 

Related LiveChat Documentation

http://developers.livechatinc.com/rest-api/#get-chats

Sending a chat transcript to an e-mail address

The sendChatTranscriptByEmail operation sends a chat transcript to an e-mail address.

sendChatTranscriptByEmail
<livechat.sendChatTranscriptByEmail>
    <to>{$ctx:to}</to>
	<chatId>{$ctx:chatId}</chatId>
</livechat.sendChatTranscriptByEmail>
Properties
  • to: The receiver's email address.
  • chatId: The chat ID to send the transcript.
Sample Request

Following is a sample REST/JSON request that can be handled by the sendChatTranscriptByEmail operation.

Sample request for sendChatTranscriptByEmail
{
	"apiUrl":"https://api.livechatinc.com",
	"login":"anu.thushi@gmail.com",
	"apiKey":"81df74bda524d8027f0717cffaf318b2",
	"chatId":"NJHV7BG1C5",
	"to":"janaka.n.ranathunga@gmail.com"
}
Related LiveChat Documentation

http://developers.livechatinc.com/rest-api/#send-chat-transcript

Sample Configuration

Following is a sample proxy service that illustrates how to connect to LiveChat with the init operation and use the getChatById operation. The sample request for this proxy can be found in the getChatById sample request. You can use this sample as a template for using other operations in this category.

Sample proxy
<?xml version="1.0" encoding="UTF-8"?>
	<proxy xmlns="http://ws.apache.org/ns/synapse" name="livechat_getChatById" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
	 <target>
	 <inSequence>
      <property name="apiUrl" expression="json-eval($.apiUrl)"/>
      <property name="login" expression="json-eval($.login)"/>
      <property name="apiKey" expression="json-eval($.apiKey)"/>
      <property name="chatId" expression="json-eval($.chatId)"/>
      <livechat.init>
         <apiUrl>{$ctx:apiUrl}</apiUrl>
         <login>{$ctx:login}</login>
         <apiKey>{$ctx:apiKey}</apiKey>
      </livechat.init>
      <livechat.getChatById>
         <chatId>{$ctx:chatId}</chatId>
      </livechat.getChatById>
	   <respond/>
	 </inSequence>
	  <outSequence>
	   <send/>
	  </outSequence>
	 </target>
   <description/>
  </proxy>  
  • No labels