Context Variables in Salesforce Agentforce
1K views
Dec 3, 2024
Show More Show Less
View Video Transcript
0:05
hello everyone in this video we are
0:07
going to see context variables in
0:10
Salesforce agent
0:13
force once you are in the agent force
0:16
agent
0:17
Builder we have to go to
0:20
context we have to select the record
0:23
variable on the messaging session
0:26
object we have to click update included
0:28
fields and then then we will be able to
0:31
select additional
0:33
fields in the context variable once the
0:37
selection is made you have to click save
0:40
included
0:42
Fields here messaging session ID
0:45
messaging user ID and messaging user
0:47
language were pre-selected I selected
0:51
contact
0:52
ID in order to make use of this context
0:54
variable I have created a simple flow it
0:58
is an autol launched flow
1:00
I'm making use of get records flow
1:03
element and then I'm getting the
1:05
opportunity record using booking number
1:08
equal to input variable booking number
1:11
contact ID equal to input variable
1:14
contact record do the ID of the
1:17
contact here contact record is an input
1:20
variable data type is record object is
1:24
contact booking number is another input
1:27
variable data type is text
1:30
and available for
1:32
input once this uh get records is
1:36
executed successfully it will assign the
1:39
values to the opportunity record
1:43
variable this is an output variable data
1:47
type is record and object is
1:52
opportunity here for this contact record
1:55
I'm going to
1:57
pass this end user contact typ
2:01
in order to do
2:05
that I'm making use of this
2:10
topic in the action I'm invoking the
2:16
flow in the agent
2:19
action for the agent instruction I
2:21
saying get the opportunity stage
2:24
value booking number is the booking
2:26
number of the opportunity to check the
2:28
stage value contact record here I have
2:32
clearly mentioned that always use
2:34
messaging session. enduser contact ID
2:37
found in the context
2:39
variables never use user provided
2:42
information for this input since I have
2:45
instructed uh the agent action like this
2:49
it will go and get the context variable
2:51
value messaging session. end user
2:54
contact ID and then it will pass it to
2:57
the flow
2:58
here it won't send any other uh detail
3:02
that was sent by the uh users in the
3:05
chat it always makes use of messaging
3:09
session. end user contact ID which is
3:11
found in the context
3:16
variable so this is the context variable
3:20
value that will be
3:21
passed here I have a test contact record
3:26
I have an opportunity related to that
3:30
amount is 583 stage is
3:33
prospecting Let's uh test
3:35
our agent force
3:41
agent so I'm going to give the name as
3:46
test
3:48
contact and then uh test contact at
3:52
test.com is the
3:55
email
3:57
here it will invoke the this Omni
4:00
Channel
4:04
flow it will check whether the
4:07
email is entered or not if it is entered
4:11
it will try to find the matching uh
4:13
contact if the contact is found it will
4:16
assign that value to this contact ID
4:18
variable if the contact is not found it
4:21
will try to create a contact record it
4:24
will fetch the messaging session record
4:27
and then it will update the messaging
4:29
user of the the messaging session with
4:31
the contact
4:35
ID so here I'm assigning the contact ID
4:38
as uh the existing contact ID here I'm
4:42
assigning the newly created contact ID
4:45
I'm getting the messaging session record
4:48
and then here I'm updating the messaging
4:49
session user
4:52
record from the messaging session I'm
4:54
getting the messaging user ID and then
4:57
I'm updating the contact ID field
5:01
so whenever I invoke uh um my uh
5:05
messaging for inapp and web it will call
5:08
this uh Omni Channel flow it will try to
5:12
find the matching contact if the
5:13
matching contact is not found it will
5:15
create it and then finally it will route
5:18
the messaging
5:20
session to
5:22
the agent for service
5:25
agent I am doing all this checks and
5:27
populating the contact ID since my uh
5:31
agent force agent is dependent on this
5:34
end user contact
5:38
ID okay so now once I click Start
5:43
conversation already there is an
5:45
existing uh contact record with this
5:49
email so it won't create a new contact
5:53
record
6:00
it invoked the flow it found the
6:02
matching contact it would have updated
6:05
the messaging session with the
6:09
flow oh I didn't activate it so let me
6:12
activate it
6:27
again let's look at the messaging
6:29
session
6:30
so that we will have an
6:34
idea so this is the active messaging
6:38
session
6:39
record it already updated the
6:44
contact so I'm going to
6:47
say booking status
6:54
check it will ask
6:57
the booking number
7:00
let's take this particular booking
7:10
number let's set up a debug log so that
7:13
we will have a better understanding of
7:15
it
7:30
so now if I send it it will invoke the
7:34
flow where it checks the opportunity
7:39
uh uh State stage by passing the contact
7:45
record and as well as the booking
7:48
number if we check
7:53
the debug log we will have a better
7:56
understanding so here the contract
7:58
record
8:00
is the context variable and the booking
8:03
number is 1 2 3 4 5 whatever the
8:06
whatever we typed it on the
8:15
chat so we can make use of context
8:17
variables we can invoke agent action by
8:20
passing the context variables by by
8:23
clearly mentioning it on the
8:25
instruction so that uh uh the action
8:29
whatever we have set it up we'll fire
8:31
accordingly with the context variable
8:33
and then it will
8:40
process I hope it was
8:45
helpful thank you for watching
#Intelligent Personal Assistants
#Internet Software