
To greet Salesforce Experience Cloud Site Users from the Einstein BOT in Messaging for In-App and Web, Hidden Pre-Chat field can be used.
1. . Create a Custom Field in the Messaging Session Object/Entity to store the Experience Cloud Site User Id.

2. Create a Omni-Channel Flow.

Update Messaging Session:

Route to BOT:

3. Create a Autolaunched Flow where we have to get Messaging Session and User records. The Flow should return the User’s Name.

Fetch Messaging Session:


Fetch User Name:


User Name Assignment:

4. In BOT, call the Flow and store the User’s Name in a variable. Using Message component, greet the User.

5. Create a Messaging Channel where Routing Type is Omni-Flow.

6. Create a Custom Parameter and do the mapping in the Messaging Channel.

The User Id custom parameter is used to capture the Salesforce Experience Cloud User Id.
7. In the Embedded Service Deployment, add the Custom Parameter to the Hidden Pre-Chat Fields.

8. In the Experience Cloud Site, use the following code to pass the Experience Cloud Site User Id.
<script>
window.addEventListener(
"onEmbeddedMessagingReady", () => {
console.log(
'Inside Messaging Ready Block'
);
let userId = $A.get(
'$SObjectType.CurrentUser.Id'
);
console.log(
'User Id is',
userId
);
embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields( {
'User_Id' : userId
} );
}
);
</script>

Output:

So, using this approach we can easily greet Customers (Salesforce Experience Cloud Site Users) from the Einstein BOT in Messaging for In-App and Web.