Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Send a Multimedia message

Code Block
breakoutModewide
languagejs
//*
Send a DOCUMENTmultimedia 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), (doc/docx/xls/xlsx/ppt/pptx/pdf)XLS(X).)
}
*/
ctlive_contact.SendMultimediaMessage( "CHAT_eaa2e7c0-9c26-40db-b720-d777ab68078d", "DOCUMENT", Base64Contentcontent).then(
  function (msgiddata) {
    console.log("Document message sent", msgiddata);
  }
);

// Send an IMAGE type message (png/jpg/jpeg)
ctlive_contact.SendMultimediaMessage( "CHAT_eaa2e7c0-9c26-40db-b720-d777ab68078d", "IMAGE", Base64Content).then("IMAGE", content).then(
  function (data) {
    console.log("Image message sent", data);
  }
);

Get a Multimedia message

Code Block
languagejs
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 (msgidmultimediaMessageObj) {
        console.log("Image message sent", msgid);
  }
);
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

...

Code Block
languagejs
// End a chat and disconnect all participant.
// The first parameter is the instance of a CTLive active chat.
// The second parameter is reservedspecified andas assignedinput to falseparameter
LIVECHATSDK.LIVECHAT.endContact(ctlive_contact, false);

Leave an active chat

Code Block
languagejs
LIVECHATSDK.LIVECHAT.leave("CHAT_eaa2e7c0-9c26-40db-b720-d777ab68078d");