Skip to main content

Hi,

We have a functionality where we are developing our bot and placing it in a website. we dont want to include a prechat form in there. But we need to take the data of the logged in user. How can we accomplish it? Currently i am using the prechat code in embedded settings but it is not working if i am disabling the prechat.

 

embedded_svc.settings.prepopulatedPrechatFields = {     MobilePhone: “1234567890”,     Primary_Email__c: “abc@test.com”  };  embedded_svc.settings.extraPrechatFormDetails = [{   "label":"Mobile",     "transcriptFields": ["Mobile__c"]  },{   "label":"Primary Email",    "transcriptFields": ["Primary_Email__c"]  }];

 

Thanks

 

#Chatbot  #Einstein Bot  #Einstein Bots  #BOT  #Einstein  #Einstein Analytics  #Salesforce Einstein & AI  #Apex  #Service Cloud  #Integration

4 answers
  1. Jan 31, 2023, 3:03 PM

    Hi, @gautam arya

     

    **Mark this as Best if found this Useful for other Trailblazers reference**

     

    You can try this to get information of current user : 

    // First Get the current user ID

    var userId = sforce.connection.getUserInfo().userId;

    // You can Query the database to retrieve information about the current user

    var query = "SELECT Id, MobilePhone, Primary_Email__c FROM User WHERE Id = '" + userId + "'";

    var result = sforce.connection.query(query);

    var user = result.getArray("records")[0];

    // You can pass the information to the live chat window

    embedded_svc.settings.prepopulatedPrechatFields = {

    MobilePhone: user.MobilePhone,

    Primary_Email__c: user.Primary_Email__c

    };

    embedded_svc.settings.extraPrechatFormDetails = [{

    "label": "Mobile",

    "transcriptFields": ["Mobile__c"]

    },{

    "label": "Primary Email",

    "transcriptFields": ["Primary_Email__c"]

    }];

    Feel free to Ping me again.

0/9000