Pass Pre Chat to Salesforce Messaging for In App and Web REST API
1K views
Jan 16, 2025
When we invoke the Salesforce Messaging for In-App and Web REST API, routingAttributes can be used to pass the Pre-Chat field values. Blog Post: https://www.infallibletechie.com/2025/01/pass-pre-chat-to-salesforce-messaging-for-in-app-and-web-rest-api.html
View Video Transcript
0:08
hello everyone in this video we are
0:11
going to see how to pass pre-art field
0:15
values if we are using Salesforce
0:18
messaging for inapp and web rest
0:22
apaa for setting up Salesforce messaging
0:25
for inapp and web rest
0:28
API you can make use of this blog post
0:33
in this blog post I have given step
0:37
bystep instruction using which you
0:40
should be able to set up Salesforce
0:42
messaging for inap and web for rest
0:46
API the next step
0:49
is whenever we use pre-art field values
0:53
we have to make use of omni Channel flow
0:56
if we use the routing type as Q we won't
1:00
be able to pass the pre- chat field
1:02
values uh for messaging for inapp and
1:05
web so in order to pass the values of
1:08
the pre-chat field values and do some
1:11
operations we have to make use of omni
1:13
Channel flow so I have created an omni
1:16
Channel
1:17
flow here I have
1:20
created multiple variables but I'm going
1:22
to talk about email which is an input
1:25
variable
1:31
next I have created first name it is
1:35
also available for
1:38
input last name this is also available
1:41
for
1:42
input in my messaging for inapp and web
1:46
I'm going to show first name last name
1:48
and email pre-chat field
1:51
values those uh values that are entered
1:55
by the visitors will be passed to the
1:58
flow using
2:00
these three input
2:04
variables so this is uh uh done in order
2:08
to pass the messaging session record ID
2:11
to the Omni Channel flow I have created
2:14
one more input field uh sorry one more
2:17
input
2:19
variable called record ID uh it should
2:22
be K sensitive so make sure when you uh
2:27
type record ID the I should be Capital
2:30
all other U um characters should be in
2:34
lower case and make sure available for
2:36
input is
2:38
enabled okay so now when this Omni
2:41
Channel flow is
2:43
invoked uh it will pass first name last
2:47
name and email to these
2:49
variables and the messaging session
2:52
record ID will be passed to this record
2:55
ID
2:56
variable here I'm making use of get
2:59
records flow element and then I'm
3:02
checking whether an existing contact is
3:05
found using the email that was entered
3:08
by the
3:12
visitor next using a decision element
3:16
I'm checking whether the contact is not
3:20
null if it is not
3:22
null the contact is
3:25
found I'm using a
3:27
variable it is not uh input
3:34
variable it is contact ID so this is a
3:37
text variable I'm I'm getting the
3:39
existing contact ID and assigning it to
3:42
the contact ID
3:44
field let's say the contact is not found
3:47
using the email that was uh shared by
3:50
the visitor it will create a contact for
3:54
me I'm making use of create records flow
3:57
element to create a contact record
4:00
using the email first name and last name
4:03
that was entered by the
4:07
visitor using an assignment operator I'm
4:10
assigning the contact ID with the newly
4:12
created contact ID if an existing
4:14
contact is found the contact ID variable
4:17
will be assigned with the existing
4:20
contact ID if the contact is not found
4:23
it will create a contact record using
4:25
Create records and then it will assign
4:27
contact ID variable with the newly
4:30
created contact
4:32
record next I'm fetching messaging
4:34
session
4:39
record using update records I'm updating
4:42
the messaging
4:44
user I'm I'm finding the messaging user
4:48
using
4:49
the messaging uh sessions messaging user
4:54
ID and I'm updating the contact with the
4:58
newly created contact record so this is
5:01
my Omni Channel flow the key thing to
5:04
note here is these
5:08
variables okay next create a messaging
5:15
channel in the messaging channel for the
5:18
Omni Channel routing select Omni flow
5:21
and select the flow which was created so
5:24
this is the Omni channel uh flow which I
5:27
created so I have selected it
5:30
uh if there are any issues running this
5:31
flow it will go to this fall back que
5:34
and then it will assign so have some
5:36
users in the messaging session que you
5:38
can name you can create a queue with any
5:40
name and add some users so that you will
5:43
have a
5:48
backup here okay the next step
5:53
is parameter
5:56
mappings these three fields are standard
6:00
custom uh pre-at field so using new
6:03
button you should be able to map it when
6:07
you create this mapping this is also
6:09
case instiute so here I have first name
6:13
last name and email so those are the
6:15
flow variable names Salesforce
6:17
automatically populates this parameter
6:19
API name and channel variable
6:21
name once this mapping is done we have
6:25
to make use of Channel variable name
6:28
last name and email so we have we should
6:32
not use the API name make sure you are
6:34
using the channel variable name and this
6:36
is also case
6:38
sensitive okay so now I know these are
6:41
all the channel variable names my Omni
6:44
Channel flow is ready messaging channel
6:46
is also ready it is active now create
6:49
embeded service deployment I'm using
6:52
custom client deployment because I'm
6:54
making use of Salesforce messaging for
6:56
in happen with rest AP here make sure
7:00
you have created sorry you have added
7:03
the preat field
7:06
values once this is done make sure you
7:09
click the publish button once it is
7:11
published we will be able to make all
7:14
the rest AP codes as an agent let me go
7:18
available for
7:22
messaging so the first step is we have
7:24
to get
7:26
the
7:28
token so I'm going
7:31
to do a post request I have the access
7:36
token I have a script which stores that
7:39
in the variable called uh ma aw access
7:45
token next we have to uh do a post
7:49
request to create a conversation when
7:52
you do this here only we have to make
7:55
use of routing attributes to pass the
7:59
pre- field values so here underscore
8:01
first name underscore last name
8:03
underscore email name
8:08
are Channel variable
8:12
names so these values will be passed to
8:16
this flow and the Omni Channel flow will
8:18
take care of all the uh logic whatever
8:21
you have done to make use of the pre-art
8:24
field values so let's see this an action
8:26
in order to create um
8:30
a conversation ID I'm making use of this
8:33
sample piece of code so once I execute
8:36
it it will create a uh conversation ID
8:38
for me so that I can make use of
8:44
it so this is the conversation ID I'm
8:47
going to make use of
8:49
it so now it will create a messaging
8:53
session
8:54
record it will invoke the Omni Channel
8:56
flow it will pass these values if the
9:00
existing contact is found it will create
9:03
it will use the existing contact if
9:05
there are no existing contacts with the
9:08
email test test.com it will go and
9:11
create a new contact I already have an
9:14
have a contact with the test
9:16
test.com so it will Fitch that contact
9:20
and then it will link it to the
9:21
messaging user let's see that so now I'm
9:24
going to make a call to create a
9:25
conversation
9:33
it it got
9:34
created as an agent I received
9:39
it see it linked the contact using the
9:43
existing contact so the Omni Channel
9:46
flow was executed it
9:51
uh it um it fed the contact it checked
9:56
whether the contact is not not null it
9:59
is done it is not null because there is
10:01
an existing contact with that
10:03
email uh it fed the messaging session it
10:06
updated the messaging end user with the
10:07
existing contact ID and using route to
10:10
work it assigned it to the
10:14
que okay now you
10:18
can
10:20
subscribe to the server side events if
10:23
you want so that if I send a message as
10:27
an agent you should be able to see see
10:29
that in the S
10:36
events so you can go and check whether
10:39
that message is
10:42
received
10:55
okay okay this one is typing indicator
11:02
okay this is the
11:06
conversation the message that was
11:09
sent is
11:16
here okay the
11:20
message okay so this is the message that
11:22
was sent testing from agent so using
11:25
this SSA subscription you should be able
11:27
to do it if you want to send a message
11:29
you can make use of
11:31
this and you should be able to send a
11:34
message if you want to close the
11:36
conversation you can make use of this um
11:39
delete request and then you should be
11:40
able to um close the
11:46
conversation so in order to send the
11:49
pre-art field values kindly make use of
11:52
routing
11:54
attributes in the routing attributes
11:57
make use of the channel variable AP and
11:59
channel variable names and these are K
12:02
sensitive so kindly make sure um it is
12:07
also mapped with the flow
12:10
variables in the messaging
12:16
Channel please check the video
12:18
description in the video description I
12:20
have shared my blog post in the blog
12:22
post you should be able to get the steps
12:24
whatever we discussed uh in this video
12:27
for your reference
12:36
I hope it do
12:44
helpful thank you for watching
#Internet Software
#Text & Instant Messaging