/
CTLive contact APIs

CTLive contact APIs

Through the API methods any CTLive integrator can send text messages, link or multimedia content, leave an active chat, terminate a chat for all participant.

Below we list all the available APIs related with a code example. The APIs are related to an istance of active chat, for example the same object returned by calling the joinContact method.

Send a Text message

ctlive_contact.sendMessage("Hello world!").then( function (msgid) { console.log("Message sent", msgid); } );

Send a Multimedia message

/* Send a multimedia type message content object can be one of the following type: { "img":"<base64_img>", "caption":"<captionToSend>", "fileName": "<file_name>", "documentType":"<document_type>" (file extension JPG, JPEG, PNG.) } { "document":"<base64_doc>", "caption":"<captionToSend>", "fileName": "<file_name>", "documentType":"<document_type>" (file extension PDF, DOC(X), PPT(X), XLS(X).) } */ ctlive_contact.SendMultimediaMessage( "DOCUMENT", content).then( function (data) { console.log("Document message sent", data); } ); // Send an IMAGE type message (png/jpg/jpeg) ctlive_contact.SendMultimediaMessage( "IMAGE", content).then( function (data) { console.log("Image message sent", data); } );

 

Get a Multimedia message

ctlive_contact.on("multimediaMessage", function (event) { // Get multiemdia message content: call contact API GetMultimediaMessageInActiveChat(<chat_id>,<message_id>) ctlive_contact.GetMultimediaMessageInActiveChat( ctlive_contact.contact.id, event.id).then( function (multimediaMessageObj) { console.log("multimedia message retrieved", multimediaMessageObj); /* Example of multimedia object retrieved: { "result": true, "data": { "chatID": "CHAT_DEFAULT_96387da2-3a5f-4d60-a30d-729e0e5706d8", "messageID": "a0458869-9747-4ab1-bd76-8727cf483685", "messageType": "IMAGE", "domain": "DEFAULT", "format": "fullsize", "content": { "img": "/9j/4AAQSkZJRgABA....", "caption": "myImage", "fileName": "45971097-illustrazione-di-happy-emoticon-dà-pollice-in-su-isolato-su-sfondo-bianco.jpg", "documentType": "jpg", "user": { "id": "USER_gverde1@acd.enghouse.com", "nickname": "Gabriele Verde", "isAgent": true, "beginTime": 1584722203945, "endTime": "", "isOnline": true, "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", "firstUri": "http://localhost:3003/AD/AD.html", "firstTitle": "AgentDesktop - Enghouse Interactive", "channel": "web", "firstIP": "::ffff:127.0.0.1" } } }, "error": null } { "result": true, "data": { "chatID": "CHAT_DEFAULT_96387da2-3a5f-4d60-a30d-729e0e5706d8", "messageID": "9c45e6ce-e48f-4d55-beb3-6141ee2b1339", "messageType": "DOCUMENT", "domain": "DEFAULT", "format": "fullsize", "content": { "document": "JVBERi0xLjMNJeL.....", "caption": "myDoc", "fileName": "WhatsApp - omnichannel API quick guide.pdf", "documentType": "pdf", "user": { "id": "USER_gverde1@acd.enghouse.com", "nickname": "Gabriele Verde", "isAgent": true, "beginTime": 1584722203945, "endTime": "", "isOnline": true, "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", "firstUri": "http://localhost:3003/AD/AD.html", "firstTitle": "AgentDesktop - Enghouse Interactive", "channel": "web", "firstIP": "::ffff:127.0.0.1" } } }, "error": null } */ } ); });

Send an Hyperlink message

Notifies “is writing” agent status

Terminate an active chat

Leave an active chat

Related content

Functionality description
Functionality description
More like this
API reference
API reference
More like this
How to use the CTLive Agent SDK
How to use the CTLive Agent SDK
Read with this
Channel API
Channel API
More like this
Widget
Widget
Read with this
Join an existing chat
Join an existing chat
More like this