Configuring embedded chat with customer-defined pre-chat form
Embedded chat is similar to legacy LiveAgent chat, but requires some additional set up of the pre-chat form.
Set up browser cookies with the visitor's selected language.
- Get the Language Weaver language code.
- Determine what language visitor intend to use.
- Store the language selected by visitor in a variable.
- Run the below query to get the LW code of visitor selected language:
SDL_LC__BeGlobal_Language_Pair__c LWcodeEntity = [select SDL_LC__FromLangCode__c,SDL_LC__FromLanguage__c from SDL_LC__BeGlobal_Language_Pair__c where SDL_LC__FromLanguage__c =:visitorLang limit 1 ]; //visitorLang fetched in steps 2. - Extract the LWLanguageCode from above query like below
LWLanguageCode = LWcodeEntity.SDL_LC__FromLangCode__c; - Once found, use the same in below steps to set the cookie.
- Use the following snippet as a guideline to set the cookies.
document.cookie = 'languageSelectedbyVisitor = '+'LWLanguageCode'; - Get the Salesforce-generated code for the embedded service and add a static resource file in the code before deployment: LanguageWeaverEmbeddedJS
- Use the below snippet to add the static resource file in the Salesforce-generated code
embedded_svc.settings.externalScripts =["LanguageWeaverEmbeddedJs"];Refer to the below screenshot. It is part of Salesforce-generated embedded code. Add the above snippet at the
//snippet placeholdercomment