Service Cloud

Pre-Chat Context: It’s all about the flow

Use Flow to make your chats smarter and more personalized.

I’ve been writing a lot about Chat and how I’m implementing it for my service team. In my last post, I mentioned a specific flow a couple times and promised to write about it… that’s this post šŸ˜Ž. So why do we care about the pre-chat context so much? Well because once you know who someone is… pretty much anything becomes possible in terms of what dialogues you want to present to them, how their conversation is routed and even how your agents greet them. Some examples of things you could do if you know someone’s name:

  • Greet them by name

Some examples of things you could do if you know who someone is and can also use a flow to go get more data:

  • See that they have an open opportunity and talk about it or route to the opportunity owner
  • See that they have an open case and allow them to add a case comment or route to the case owner
  • Fetch Account information and do something with it
  • Start different dialogues that say different things based on their customer level
  • Route to the case, opportunity, lead, or account owner or even just someone in the same territory
  • Present different menu items to customers on subscription vs off subscription
  • and on and on and on…

Rad. So how do we do it?

Start with the pre-chat form

Using a pre-chat form, we’re able to ask the customer who they are and set the contact, lead, account and case lookups on the chat transcript. For our implementation, we’re actually only exposing this chat once the customer has logged into our support portal, so we already know who they are. We are passing these values into the form automatically but hiding it from them. It doesn’t matter if the customer sees the form or not though, we really just want Salesforce to perform this lookup for us. If it finds a person who matches, it will link that person to the transcript for you. If it doesn’t find someone, it will actually create a new lead record and attach that for you. To design your pre-chat form, all you need to do it go into your Embedded Service Deployment, click View, then Edit. Then you can choose the fields you want on your form. Try to keep it as simple as possible. This should be just the information you need to identify someone.

Getting more data with flow

My pre-chat context flow is not an original idea – I stole it from the example Einstein Bot! Which is a solid lesson to learn, especially if you’re just starting out – find inspiration everywhere. Don’t recreate the wheel. Identify out of the box solutions and then customize them to work for your needs. *Steps down off soap box* Moving on… Let’s build this thing.

Get Chat Transcript

The first thing we want to do is use a Get Records node, where we’ll get Chat Transcript records that match the Routable Id of the chat. The Routable Id is a variable we’re passing in from the chat. In my implementation specifically, I only care about the ContactId that was linked to the chat from the pre-chat form, but you might also want to store additional information like LeadId, etc.

Get Contact

Next I’m doing another Get Records, but this time to grab the actual Contact record that matches the ContactId we found in the previous node. I’m saving it to a record variable, and saving the FirstName, LastName, Name, Email, AccountId, Phone, and their Customer Level. There might be more or less you need to save to use later in a dialogue.

Get Skills

Remember in the previous post where I needed to supply a list of skills for the Einstein Bot to route to with a Transfer Action? Here’s where I’m setting that! For now, I’m actually only adding one thing to the list of skills, but you could set it to allow multiple values and turn it into a collection. The only skill I’m concerned about right now is their Customer Level, so I’m doing another Get Records to find the Skill record that matches their Customer Level. The actual name of the skill is saved under MasterLabel. My Customer Level is actually coming from the Account, but since I stored the Contact as a record, I can jump into related records and grab what I need.

Make a Decision

I actually only have one outcome in my decision so far, but this gives me room to scale. In the Einstein Bot example, it had outcomes for if it was a Contact or Lead, a Case, an Account or if it didn’t find anything. All of my chats will be with known contacts, so that’s all I need to account for here, but I’ll be expanding this in Phase 2 of my implementation to include things like On Subscription Contact vs Off Subscription Contact, etc. Based on the outcome, you could go down different paths for setting different variables and what not. So I’m just checking to see if we matched a Contact:

Assign Variables

Now I’m using an Assignment node to assign a bunch of variables that will be passed into my chat dialogues. This allows us to automate simple questions, for example:

“In case we get disconnected, is xxx-xxx-xxxx still a good phone number to call you back?”

And since I’m collecting their Customer Level, my dialogues can use this by saying things like:

“Hi, Kristi. Thanks for being a Pro customer!”

Just little touches that might mean a lot to the customer and also protect them from having to enter a lot of information that would probably be annoying to enter each time they need to chat.

Update Chat Transcript

I’m also using this opportunity to update the actual Chat Transcript with values I want preserved there. I’m logging the customer’s Customer Level at the time of the chat. That way in future reporting I can still tell how many Pro chats I had in a given period even if that Customer is no longer a Pro subscriber, etc. I also have this field mapped in my Skills-Based Routing Rules, so by filling it during the pre-chat session, its available to use one the chat needs to get routed to an agent later.

And that’s the Flow!

Super simple right? It has 6 nodes but accomplishes so much. It can be as simple or as complex as you need it to be, although I wouldn’t get too crazy with it. Remember this is running at the very start of your chat so if you are doing crazy looping and getting a lot of records it might slow things down a bit. Here’s what the whole flow looks like:

So when should you actually run this?

I’m running this first thing – even before my very first message. That way if I need to use any of the values I set in my first message I can. To call your flow from the Einstein Bot, you’ll add an Action with an Action Type of Flow. In your Action you’ll set the mapping of all of our variables between the Flow and your Bot. I recommend naming things either the same or similar so its very clear what belongs to what.

And that’s it! Now we can use these variables in our Flow to personalize our chat, set routing and skills, and more. With the power of Flow we’ve made our Bot smarter and our chat more personalized. BOOM.

8 comments on “Pre-Chat Context: It’s all about the flow

  1. Pingback: Let’s Chat About Salesforce Chat – Force For Fun

  2. Hi Kristi
    Iā€™m trying to get a custome prechat field from ChatTranscript. Can you help with a sample flow?


  3. Hi Kristi…do you have details on how you hide the prechat form but still pass in the name/email information? The only way I know how to hide the form is to deactivate it in the embedded service deployment, but then the variables do not get passed into the bot in my testing. I’m specifically referring to where you said “We are passing these values into the form automatically but hiding it from them.” My bot is only behind the login so it will always be an authenticated user.


  4. Hi Kristi…do you have details on how you hide the pre chat form but still have the name/email variables passed into the bot to work with the flow? The only way I know of to hide the form is to deactivate it from the embedded service deployment, but when I do that the values are not passed in even when logged in as an authenticated user. What am I missing?


    • My front end developer hid it on the website side of things. I have since left that company but let me see if I can ask someone who is still there what we did! I really don’t remember now without poking around šŸ˜¦


  5. Sanjeev Krishnan

    Hi Kristi. When we output entire record from flow like matched contact in above example, it sends record url back to bot and not actual field details. Because of this could not utilize the record object in dialogs in bot. Please let me know how to access field values from record object passed back to bot.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: