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 DOCUMENT type message (doc/docx/xls/xlsx/ppt/pptx/pdf) ctlive_contact.SendMultimediaMessage( "DOCUMENT", Base64Content).then( function (msgid) { console.log("Document message sent", msgid); } ); // Send an IMAGE type message (png/jpg/jpeg) ctlive_contact.SendMultimediaMessage( "IMAGE", Base64Content).then( function (msgid) { console.log("Image message sent", msgid); } );
Send an Hyperlink message
ctlive_contact.SendLink("https://www.enghouseinteractive.it/").then ( function (msgid) { console.log("Hyperlink message sent", msgid); } );
Notifies “is writing” agent status
// The agent has started writing ctlive_contact.isWriting(true); // The agent has stopped writing ctlive_contact.isWriting(false);
Terminate an active chat
// End a chat and disconnect all participant. // The instance of a CTLive active chat is specified as input parameter LIVECHATSDK.LIVECHAT.endContact(ctlive_contact);
Leave an active chat
LIVECHATSDK.LIVECHAT.leave("CHAT_eaa2e7c0-9c26-40db-b720-d777ab68078d");