How to store interaction data inside Salesforce using Flows

Modified on Tue, 23 Apr at 10:34 PM

How to store interaction data in Salesforce

1

Pre-requisites

Talkative passes information through to Salesforce via three custom Objects:

  1. Interaction
  2. Interaction Data (Data Collection Forms and Chatbot data)
  3. Agent Status

We will be focusing on Interaction Data in this tutorial as it contains the Key:Value pair, but the principle for storing data from other object works much in the same way.

For more information about each object please see the following link:

Salesforce data objects

Chose the object you want the data saved to and add in any custom fields. Data gets sent as a Key:Value pair. In our example we will populating the “Contact” object with new customer data collected from a data collection form. The forms are setup in your Talkative widget configs, under the Data Collection tab.

 

Key:Value pairs from Talkative Data Collection Forms

23

4

 

Below is an example of a data collection form with a mixture of standard (name, email, phone number) and custom (custom text field and picklist) fields.

5

Key:Value pairs from Dialogflow

There are two types of parameters we recommend adding to Dialogflow intents, Outcome and Journey. 

 

Outcome gives a status of what happened to that chat. Partially contained, the customer started a chat with the bot and then dropped off. Fully contained, the bot was able to answer all questions and chat ended. Handoff, the chat needed to be transferred to an agent.

 

Journey is the name of the journey they went through.

 

Please see below for the "parameter name" : "value" that needs to be added into Dialogflow and your Salesforce flows(Key:Value pairs), the parentheses in the below pairs should be excluded as they only reference which intents the pairs need to go into.

 

Outcome: PartiallyContained (in welcome intent)

Outcome: Handoff (in transfer intent)

Outcome: FullyContained (in close conversation intent) 

Journey: "journey-name" (in the start intent of each journey, only needs to be added to start of the journey, not to any of the the follow up intents)

 

Examples:

Welcome intent, Outcome : PartiallyContained

6

Login Problem Journey, Journey : Login-Problem

7

 

Salesforce Object Fields

For every field that is created in the data collection form (or that is sent via chatbot), you will need to create a corresponding field in a Salesforce object.

The fields can be added to any object, but best practice is to keep customer data in the contact object.

8

 

Optional: edit the Contact page and compact layouts to include custom fields. (see below)

9

Create the flows

Click the gear icon in at the top right of the screen and select “Setup”.

10

 

In the “Quick Find” box on the left type “Flows” and click on Flows under Process Automation.

11

 

Click “New Flow”.

12

 

Select “Record-Triggered Flow and click “create”.

13

 

In the Configure Start window add in the following settings:

14

Set Entry Conditions (optional): Use this area to set rules for triggering the flow only if a certain set of conditions are met.

In our example we only want the data to be added/updated at the end of the interaction as the interaction data object is only sent a short time after the interaction object so won’t be available at the start of the interaction.

Some data is also sent during the interaction so best practice is to poll for the data at the end of the conversation, unless you have specific triggers that need to fired along the way, such as with case creation.

 

Summary of current flow:

15

Next step is to add in variables.

For every interaction record you want to save, you will need to add in a variable to the flow.

For example, we want to extract the customer email and last name from our Key:Value pairs that get passed in our interaction data record so we will create an “email” and “last name” variable.

 

Open the Toolbox

16

 

Click on “New Resource”

17

For Resource Type select “Variable”. API Name is whatever you want to call the variable in the flow, Data Type as Text(or number if you have a phone number, etc). Leave all other values as default. Click "Done" when ready.

18

 

Add an element after Start

19

 

Add in a “Get Records” element

20

 

Add the following settings and click “Done” when ready

21

 

This will get all the records from the “Interaction Data” object (see below)

22

The next step will be to “loop” through the interaction data object, isolate the Key:Value(data) pair and add the data to the variables we created earlier.

 

Add an element after the Get Records element

19

 

Add in a “Loop” element

24

 

Add in the following settings and click “Done” when ready

25

Add an element inside the loop 

19

 

Add in a “Decision” element

27

 

This is where we tell the loop which Key to look for in the Key:Value pair. We do this by telling it to look for: {!Loop_through_records.TalkativeEngage__Key__c} in the “Resource” block condition. The “Value” being the api name you decided to use in Talkative when designing the data collection form.

Add in the following settings and click “Done” when ready

28

 

Now that we have found the Key which equals “email”, we want to assign the data that belongs to that Key to our “flow_email” variable we created earlier.

 

Add an element after the “email exists” outcome

19

 

Add in an “Assignment” element

30

 

Add in a Label, API Name and Description. Select one of the Variables you created earlier in the Variable block and use the following in the Value block:

{!Loop_through_records.TalkativeEngage__Value__c} 

Click “Done” when ready

31

 

Keep adding in decisions for every Key:Value pair you want to extract, in our example we wanted to extract two Key:Value pairs (email and last name) so we added in two decisions.

32

 

Now that you have the Key:Value data extracted and saved as variables in the flow, it's up to you what you want to do with them.

In our example we will create a new Contact record with the data and save the records to the fields we created in the Contact object at the start of this tutorial.

 

Add an element after the loop

19

 

Add in a “Create Records” element

33

Add in the Label, API Name and Description. The object we want to create a record on is the "Contact" object. Map the field values for the Contact to the corresponding variables in the flow and click “Done” when ready

 

Our final example flow looks like the following:

35

All that is left to do is "Save" and don't forget to "Activate" the flow when you are ready to have it go live.

 

Please note that although this flow functions it is still very basic and will need to be expanded on.

You will need to account for many different scenarios, such as:

  • Check if the record is present in the object, if not, then add it. If it is present, then ignore creating a new contact.
  • If a record exists but not all data matches, which piece of data is more up-to-date, the new data coming in or the record already in salesforce?

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article