function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael M 

How to change code of embedded service code snippet

Hello I want to add the following code to my embedded service code snippet. However I cannot seem to edit that code. I found this webstie https://help.salesforce.com/articleView?id=snapins_chat_customize_code.htm&type=5 but don't understand all the steps. Are there simple steps you can provide so that I can add this code to my embedded service code snippet?

embedded_svc.settings.extraPrechatFormDetails = [{ "label": "URL", "value": window.location.href, "displayToAgent": true, "transcriptFields": ["URL__c"] }];
VinayVinay (Salesforce Developers) 
Hi Michael,

Check below link that can help you.

https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_lightning_components_settings.htm

Thanks,
Michael MMichael M
Hi Vinay, I appreciate your reply. I am still not getting from that link how to actually change the code of the embedded service code snippet. I just want to add my few lines of js to that code. Is it possible?
VinayVinay (Salesforce Developers) 
This is possible but haven't tried this.

Check below references
https://help.salesforce.com/articleView?id=000319423&type=1&mode=1
https://salesforce.stackexchange.com/questions/228053/is-it-possible-read-write-settings-of-embedded-svc-in-lightning-component-of-pre

Thanks,
Michael MMichael M
Hi Vinay,

Thank you for those references. I am not seeing there how to edit the embedded service code snippet.

I found a similar idea to what I want to do here:
https://salesforce.stackexchange.com/questions/277915/live-agent-users-current-location-url 

On that website, they say to add this code to the embedded service:
embedded_svc.settings.extraPrechatFormDetails = [{ "label": "URL", "value": window.location.href, "displayToAgent": true, "transcriptFields": ["URL__c"] }];

However I do not understand how to add to add this code. When I look at my embedded service code snippet, there is no edit button. How can I add that code? And if I cannot, is there any other way to use window.location.href in my einstein bot?