0

We are using a lightning app with embedded service. we used the instructions given here. The chat button appears on the page but we keep getting this error:

{
    component: "markup://embeddedService:sidebar", 
    componentStack: "[ltng:outAppUnstyled] > [embeddedService:sidebar] > [embeddedService:sidebar]", 
    action: null, 
    name: "SyntaxError", message: "Error in $A.getCallback() [Unexpected end of JSON …debarController/ACTION$getDeploymentConfiguration", …
}
action: null
component: "markup://embeddedService:sidebar"
componentStack: "[ltng:outAppUnstyled] > [embeddedService:sidebar] > [embeddedService:sidebar]"
data: null
handled: false
id: 1174708058
message: "Error in $A.getCallback() [Unexpected end of JSON input]↵Callback 
failed: serviceComponent://ui.embeddedservice.aura.components.controller.SidebarController/ACTION$getDeploymentConfiguration"
name: "SyntaxError"reported: falseseverity: undefinedsf: (9) [d, d, d, d, d, d, d, d, d]stackFrames: (9) [d, d, d, d, d, d, d, d, d]
stackTrace: "Object.eval()@https://xxx.cs123.force.com/components/embeddedService/sidebar.js:30:393"
stacktraceIdGen: "markup://embeddedService:sidebar$Object.eval$Error in $A.getCallback()"stacktraceIdGen
Modifier: nulltf: "serviceComponent://ui.embeddedservice.aura.components.controller.SidebarController/ACTION$getDeploymentConfiguration@markup://embeddedService:sidebar↵Object.eval()@https://guitar-deltak-community.cs123.force.com/components/embeddedService/sidebar.js:30:393"__proto__: 
Error
    at new Aura.externalLibraries (https://static.lightning.force.com/cs123/auraFW/javascript/BcWxSGldKzy83CHM8lFYMg/aura_prod.js:300:363)
    at https://static.lightning.force.com/cs123/auraFW/javascript/BcWxSGldKzy83CHM8lFYMg/aura_prod.js:65:1

Our code looks something like this:

$Lightning.use(
    "embeddedService:sidebarApp",
    function () {
        $Lightning.createComponent(
            "c:HelloWorld",
            document.body,
            function (cmp) {
                console.log("callback");
            }
        );
    },
    “https://xxx.cs123.force.com/application”
);

UPDATE-1:

Here is my lightning web component code:


import { LightningElement, api } from 'lwc';

export default class HellowWorld extends LightningElement {
    @api msg = 'Test!';

    clicked() {
        alert("Hi");
    }
}

and my lightning out code is:

$Lightning.use(
    "embeddedService:sidebarApp",
    function () {
        $Lightning.createComponent(
            "c:HelloWorld",
            { msg : "Hi!" },
            document.body,
            function (cmp) {
                console.log("callback");
            }
        );
    },
    “https://xxx.cs123.force.com/application”
);

But still it gives same error on click on the chat button. Just to clarify, the page comes up and we see the snap-in chat as well. The error that I have shared is on click of the chat button.

0

Looks like you dont provide param in your input as indicated in the documentation you give and this could explain the error =>

message: "Error in $A.getCallback() [Unexpected end of JSON input]

enter image description here

For a more explicite exemple, you can see Andres Perez exemple

<body>
    <div id="lwcLightning"></div>
</body>
    <script>
    $Lightning.use(
        "<%- appName %>",
        () => {         
            $Lightning.createComponent(
                "<%- lwcCmpName %>",
                { msg: "It works (LWC)!" },
                "lwcLightning",
                (cmp) => {
                    console.log("LWC component was created");
                }
            );
        },
        "<%- lightningServerUrl %>",
        "<%- accessToken %>"
    );
</script>
5
  • we tried the code from the link you provided. we are able to embed 2 components. The problem is when we use embeddedService:sidebarApp as appName, it shows the chat but on clicking we get the above error. It seems an issue with embedded service and was hoping if someone tried doing something similar. – raj Jul 16 '20 at 14:57
  • Can you add your c:HelloWorld code ? It really looks like you need to provide some parameters in the red box I drow in my answer – Badbaxx Jul 16 '20 at 15:09
  • I have updated the original post with the details. Also wanted to clarify that the page does come up. The issue is that snap-in chat doesn't expand. – raj Jul 17 '20 at 11:53
  • Does it change anything if you replace document.body by the div id where you call the component (like the exemple I provide)? – Badbaxx Jul 17 '20 at 12:19
  • We just tried with div id but that did not work even with div id. The error seems to be coming from this script service.force.com/embeddedservice/5.0/esw.min.js – raj Jul 17 '20 at 15:22
0

We had raised a case with Salesforce on this. It turns out the issue was that we were using $Lightning.use in a VF page that was in different org than where we had enabled the live agent. Apparently both the $Lightning.use and live agent should be in same org for it to work. We tested it and want to confirm this works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.