0

As of Spring 23, the MIAW product does not offer image compression during upload. Our End users have low bandwidth and to preserve data storage in salesforce, I'm trying to seek a javascript solution that resizes an image before upload when the user attaches an image file and hits the send button in the MIAW conversation (Messaging Session). It will be in the head markup of the community.

My Challenge and current ask is with detecting the event as I do not see an ID associated with the send button in the embedded chat window so traditional way of dispatching onchange event isn't going to work. Trying to see what is the event for file attachment. event: 'force:attachment' or event: 'force:image' ?

Here's a very official page: https://developer.salesforce.com/docs/service/messaging-web/references/m4w-reference/event-listeners.html

Here's how a sample code looks like which clears the session on logout:

  window.addEventListener("onEmbeddedMessagingReady", () => {
        console.log("Received the onEmbeddedMessagingReady event…");
        if ($A) {
            $A.eventService.addHandler({
                event: 'force:logout',
                globalId: 'testLogout',
                handler: function (e) {
                    console.log("Received the force:logout event…");
                    // Clear previous chat session if it exists
                    embeddedservice_bootstrap.userVerificationAPI.clearSession();
                }
            });
        }
    });
3
  • Salesforce Product Support has acknowledged this as urgent and I will post an answer on 04/01 to this question.
    – Sid
    Mar 17, 2023 at 13:31
  • how did you set up the user verification, as we need to pass the JWT token to head markup, we cant do the jwt creation in head tag js it will be at server side. my approach is add dummy lwc which calls apex to generate jwt token , then lwc fires window event , which is captured by js in head tag and set embeddedservice_bootstrap.userVerificationAPI.setIdentityToken. it works , not sure this is recommended way or there are any better approach for this.
    – ansfdc
    Dec 6, 2023 at 14:37
  • Our MIAW chat is used for Community Users, and is placed in an experience cloud site - login to this site is authenticated via an IDP (PingID) that enforces SSO and MFA, so we didn't have to authenticate a MIAW session via JWT or another such custom method.
    – Sid
    Dec 7, 2023 at 16:35

1 Answer 1

0

Based on our expedited request to salesforce product team for MIAW, they were kind to include this as a feature in the platform. You must add this code to the head markup in the community.

<script type="text/javascript"> window.addEventListener("onEmbeddedMessagingReady", () => {
console.log("Received the onEmbeddedMessagingReady event.");
embeddedservice_bootstrap.settings.imageCompressionOptions = { maxWidth: 960,
maxHeight: 1280 };
});
</script>

maxWidth: The max-width of the output image. The value should be greater than 0.
maxHeight: The max height of the output image. The value should be greater than 0.
quality : The quality of the output image. It must be a number between 0 and 1. This option only available for image/jpeg and image/webp images. By default this is set to 0.8

2
  • Hi, did you set up User verification for MIAW ? Can I contact you to learn more on it ? Jul 18, 2023 at 21:45
  • Our MIAW chat is used for Community Users, and is placed in an experience cloud site - login to this site is authenticated via an IDP (PingID) that enforces SSO and MFA, so we didn't have to authenticate a MIAW session via JWT or another such custom method.
    – Sid
    Dec 7, 2023 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .