...
Code Block | ||||
---|---|---|---|---|
| ||||
for (var i = 0; i < data.chatTranscripts.length; i++ ) { // data.chatTranscripts[i] is an object that contains the following information: // data.chatTranscripts[i].transcript.messages: all the messages sent on a single archived chat // data.chatTranscripts[i].transcript.room: CTLive chat room ID // Get all messages: for (z = 0; z < data.chatTranscripts[i].transcript.messages.length; z++) { switch (data.chatTranscripts[i].transcript.messages[z].data.messageType) { case "TEXT": /* Text Message...call your custom function that render the message using the following properties: data.chatTranscripts[i].transcript.messages[z].data.content.text : allthe messagescontent of the chatmessage data.chatTranscripts[i].transcript.messages[z].data.content.user.isAgent: boolean to identify agent or customer data.chatTranscripts[i].transcript.messages[z].data.content.user.id : unique ID of the user data.chatTranscripts[i].transcript.messages[z].data.ts: timestamp of the message data.chatTranscripts[i].transcript.messages[z].data.deliveryErrorReason: if 'deliverySuccess' is false this propert contains the delivery error reason data.chatTranscripts[i].transcript.messages[z].data.deliverySuccess: boolean used to identify if the message war delivered successfully */ break; }; } } |
...
A two-step process can be useful for retrieving the binary content of an attachment to avoid overloading the page rendering time due to multiple requests to CTLive for large file content.
First of all you may allyou can display only a reference to the file based on represented by an icon.:
...
When the user clicks on the icon the file content can ben request requested using the 'getMultimediaMessageByMessageID
' web service and specifying the original document ID that is stored into the transcript message:
Code Block | ||||
---|---|---|---|---|
| ||||
jQuery.ajax( { type: "GET", async: true, url: "/livechat/" + <TENANT_NAME> + "/getMultimediaMessageByMessageID/" + <IMAGE_ID>, dataType: "json", headers: { "ctlivetoken": <CTLIVE_VALID_SESSION_TOKEN> } } ).done( function (data) { if (data.result == true) { // File binary content is stored in Base64 format jQuery( "#imgChatHistory").attr("src", "data:image/jpeg;base64, " + data.message.messages[0].content.img); } } ); |
...