How to use prechatFormData from Embedded Service Deployment chat Snippet in Salesforce Experience Cloud?

How to use prechatFormData from Embedded Service Deployment chat Snippet in Salesforce Experience Cloud?

1. Create a JavaScript file using the following code.File Extension should be “.js”.

window._snapinsSnippetSettingsFile = ( function() {
    
    console.log( "Chat invitation file loaded" );
    
    embedded_svc.snippetSettingsFile.directToButtonRouting = function( prechatFormData ) {
       
        if ( prechatFormData[ 4 ].value === "Other" ) {
           
            console.log( "Inside Other Case Reason" );
            return "5735f000000192d";
           
        }
       
    }   
    
} )();

2. Upload the JS file in Static Resource.

3. Configure it in the Embedded Service Deployment in Experience Cloud builder.

Output:

Leave a Reply