Feedback form in Einstein Bot to Set Rating of Lead.

Posted on January 15, 2021 Post Thumbnail

Hi Trailblazer, In this Blog Post We are going to create a feedback form in Einstein Bot to set the Rating of Lead.

Before start, Let's have a look at the demo :)

For a quick demo click on the right bottom button "Chat with an Expert"

In the chat window after quick inputs, Enter "rating".

Rating

On the basis of an input value, We'll set up the Lead's rating.

That's all about the quick demo.

If you're new to Einstein Bot :)

Check out the following blog posts.

How To Put Einstein Bot On Any Website Using Salesforce.

How To Setup Web Chat On A Website Using Salesforce And Chat With Viewers In Real Time

What you'll Learn from Blog Post :)

You'll learn how to create a simple form in Einstein Bot.

About Einstein bot Permission Set.

How to call Apex method from Einstein Bot.

Walkthrough :)

1. First, We'll add a form in Einstein Bot.

2. We'll create a class for Setting the lead's rating.

3. Provide access to Apex class to Einstein Bot.

4. We'll call the Apex method from Einstein Bot.

Let's Start :)

Create basic Feedback Form.

Go to Setup and Open Einstein Bot Builder.

Einstein Bot

In Einstein Bot, Create a Dialogs.

Name it Rating.

Now Add a Question in the Rating Dialog and Create a Variable (Number).

Rating form.

Now Let's create a class.

I'm assuming you enabled form in your embedded chat for creating form.

And We'll update the rating of the same lead.

Create a class with name Leadsrating

public class Leadsrating {
    @InvocableMethod
public static void updateRating(list<integer> rat)
{
   lead ld = [SELECT CreatedDate, LeadSource, Rating, Name FROM lead ORDER BY CreatedDate DESC LIMIT 1];
    ld.LeadSource = 'EinsteinBot';
   if(rat.get(0) == 1)
       ld.Rating = 'Cold';
    if(rat.get(0) == 2)
       ld.Rating = 'Cold';
    if(rat.get(0) == 3)
       ld.Rating = 'Cold';
   if(rat.get(0) == 4)
       ld.Rating = 'Warm';
   if(rat.get(0) == 5)
       ld.Rating = 'Hot';
    update ld;
}
}

Explanation of above Class.

Quarrying the latest Lead and Setting the rating.

If input 1, 2, 3: Rating = COLD ;

If input 4: Rating = WARM ;

If input 5: Rating = HOT ;

Now, Let's Give access to the Einstein bot to the Class.

Navigate to Permission Sets.

And click on 

sfdc.chatbot.service.permset

Chatbot

Give Access to the Class.

Access

Last Step, Call Apex method from Einstein Bot.

Go to Rating dialog and add Action.

Check the following image for reference.

Apex.

After completing all the steps.

Activate your Einstein Bot.

Now test it out.

Click on the right bottom button "Chat with an Expert"

In the chat window after quick inputs, Enter "rating".

and click on any number, I clicked 4.

Bot.

Before chat.

chat

After Chat

rating

Bot updated Lead Source and Rating.

As you can see, It's working now.

This is how we can create a feedback form in Einstein Bot to set the Rating of Lead.

I hope It'll help you somehow.

If you have any question Ask Me

Thanks for reading :)

Write a comment for suggestions and hit the heart icon.


2205
0

Tags: #EinsteinBot

Comments

There are no comments yet.
Your message is required.

Get notified of new posts