Showing posts with label Einstein Bots. Show all posts
Showing posts with label Einstein Bots. Show all posts

Sunday, 22 July 2018

Einstein Bots with Apex Class | How to Call Apex Class From Einstein Bots


In the last post we discussed how to setup Einstein Bots. In this post we will call apex class from Einstein Bots.

Step 1) Setup Live Agent . You can check this post to setup Live Agent.
Step 2) Enable Einstein Bots. Take a help from this post.
Step 3) Create one Apex Class with "@InvocableMethod" Method.


public with Sharing Class ChatBotTemperature
{
    public class ChatBotTempOutput{
        @InvocableVariable(required= true)
        public String City ;

        @InvocableVariable(required= true)
        public Integer Temp ;
    }

    public class ChatBotTempInput{
        @InvocableVariable(required= true)
        public String City ;
    }

    @InvocableMethod(Label ='Get Temperature' description='return temp')
    public static List<ChatBotTempOutput> getTemperature(List<ChatBotTempInput> input)
    {
         List<ChatBotTempOutput> lstOutput = new List<ChatBotTempOutput>();
         for( ChatBotTempInput ChatBI : input){
             ChatBotTempOutput obj = new ChatBotTempOutput();
             obj.City = ChatBI.City;
             obj.Temp = 10; // You can make some callout to get real Tem
             lstOutput.add(obj);
         }
         return  lstOutput;     
    }
}


Step 4) Add The Apex class in  "sfdc.chatbot.service.permset" permission set. This is the Important part.


Step 5) Setup Einstein Bot

Create new bot
 Create Dialog

Add Question
Add New Slot to get City Value
Add Action. 
 All Input and Output Invocable Variable will come after selecting Action (Invocable Method).
Show Response.

Step 6) Here is output 


How to setup Bot. Please check below recording


Please share your feedback and comment.

Thanks
Amit Chaudhary





Sunday, 17 June 2018

Einstein Bots | How to Setup Einstein Bot | Summer 18



Recently we did one online session on "Einstein Bots". If you are looking for recording you can check here. To use Einstein Bots you need to enable Live Agent. If you have not done it yet, read this Post for Live Agent.


Let see how to configure the same.

Step 1) Enable the Einstein Bot.
Click on Setup->Service -> Service Cloud Einstein -> Einstein Bot Then Enable it.



Step 2) Accept Term and Condition .


Step 3) Enable Live Agent Option.
Click on "Deployment Channels"


click on edit button and enable the bot for Live Agent.


Step 4) Create a new Bot.
Click on "New" button from My Bots section.



And then follow below step :-



Step 5) Lets create Dialogs.

Click on Dialog Menu from the Einstein Bots Builder.



Then Click on + button to create "New Dialogs".


All Set . Now Create a question


Click on Question icon and enter your question like below screen.


Then add new Slot.


Add some more question :)


NOTE:- Add some Choice this time. Click on "Add Choice" button.


Lets Create some rule to Response to end user. Click on Rule button from below screen.


Add Condition and action

NOTE:- I created one more Dialog "Pizza Restaurants". You can create the one more rule for Chinese as well.

Save your changes after click on save button


Step 6) Now set Dialogs in welcome bots.
Click on "Welcome" option from Einstein Bots Builder.


Step 7) Save and Activate.



Now you can test your Einstein Bot from Live Agent.





If you want to see the recording of out Apex Hour click here. Thanks Shruti for a great Demo in Salesforce Apex Hours.


Please check below post if you want to call apex class in bots

Einstein Bots with Apex Class | How to Call Apex Class From Einstein Bots




Capture.JPG  @amit_sfdc    #SalesforceApexHours    @ApexHours

Thanks
Amit Chaudhary