We know Chatbots are used on websites, Facebook, and Whatsapp to assist customers even if the agents are unavailable in the office at that time.

The Salesforce CRM platform also provides the Chatbot Functionality to help customers manage clients in an effective way. You will find it in the quick find box just by entering “bot”.
It is very easy to use. We can call flows, Apex classes and also directly access the objects available in Salesforce.

But for some purpose what will happen if we have to show our custom messages or any image with some custom change?

So, here in this blog, we are going to show you how to call your Lightning Web Component in your chatbot. And believe us it is very easy. Let’s go step by step on this journey.

So first we are going to set up a chatbot on our public site. So let’s create one.

Step 1. Go to the Quick find box and type Einstein Bots

1 1320538b2d

Step 2. Then click the New button to create a new chatbot or you can proceed with your created one.

2 132060cfa9

Step 3. Select the standard bot then click next

3 13207626c3

Step 4.  After creating the chatbot our dialog page looks like this

4 13208e60bb

After creating the bot now is the time to integrate our bot with the community site.

Step 5.  Go to the Quick find box and type all sites.

5 13209fd363

Step 6.  Go to the builder page of the community site

6 1321038b07

Step 7.  Go to the builder page and click on the gear icon. Go to security and privacy add a trusted URL and enable the security level.

7 1321182cb0

Step 8.  To Add a trusted URL go to the quick find box and type chat settings and copy the Chat API endpoint URL.

8 13212886ba

Step 9. Set the bot to the community page.

After adding the chat API endpoint URL it’s time to set our bot to the community page.

Go to component and scroll down and go to the support section and drag the embedded service chat to the community page

9 13213ad5b3

Step 10. Create an LWC component

After integrating our Einstein Bot into the community site. Let’s create an LWC component just to show an image on page

Step 11. Create an LWC component to make changes in the chat

Now we have finished setting up the chatbot. Let’s Create an LWC component to make changes in the chat as per our choice. For reference have a look at this URL Link: Base Chat Message.

i) Here, We will create an LWC component to show the image whenever a client asks for the product image.
ii) For this we have created some dialogues and at a certain point, we have called the LWC component.
iii) To use the LWC component we have used “lightningSnapin__ChatMessage” in target and imported “lightningsnapin/baseChatMessage” module in the javascript class.
iv) We have created some custom CSS to modify our message and chat theme.
v) Here is the code for the LWC component that we have used in our chatbot after creating this lwc we have deployed it into org.

HTML File

JavaScript File

XML File

CSS File

Step 12.  After deploying your LWC to your org go to quick find box and type Embedded Service Deployment

12 13214155f7

Step 13. Click on dropdown and select View

13 132155c5e3

Step 14.  Select Chat setting and click on edit

14 1321784bda

Step 15.  Add your lightning web component in Chat Messages and save it.

15 1321827d39

Here are some sample snaps of our working bot:

  • When we select Order Details the bot show this message.
16
  • When we select Product Image the bot shows the image
17

Please Test our chatbot! Click Here

Conclusion:

Now our Einstein Bot is ready to go. Try to create your own Bot by performing the above steps and share your experience with us. Stay tuned to our blogs for more interesting Salesforce development solutions. Until the next, Keep Learning!

Share This Blog
Table of contents
Related Articles
How to Use Transform Element in Salesforce Flow

Salesforce introduced the transform element in their winter ‘24 release. This feature simplifies data processing in flows by eliminating the need for loops and assignment elements. With the Transform Element, you can seamlessly map source data to target data, making your flows more efficient and easier to maintain. Transform element is available for screen flows, […]

Read More
How to Use TypeScript in Salesforce Lightning Web Components (LWC)

TypeScript is a programming language developed by Microsoft; used for enhancing JavaScript by adding different static types. With the help of TypeScript, developers can easily find errors during the development process before the execution. It also makes the code more readable and maintainable. With the successful integration of Salesforce Lightning Web Components (LWC), TypeScript improves […]

Read More
Expert Guide on Seamless Integration of Salesforce and QuickBooks Online

Integrating Salesforce with QuickBooks Online can significantly streamline your business operations, improving data accuracy and efficiency. QB Sync Made Easy offers a seamless solution to synchronize customer and financial data between the two platforms. This expert QuickBooks Online, on the other hand, is a leading accounting tool specifically developed for small and medium-sized businesses that […]

Read More
A Complete Guide to Salesforce CPQ Contract Amendment and Renewal

Salesforce CPQ software offers robust features for managing pricing, product configurations, and quotations. The capacity to effectively modify and renew contracts is essential for businesses managing intricate agreements and long-term partnerships. In this guide, we’ll walk you through the details of contract amendment and renewal processes in Salesforce CPQ. About Salesforce CPQ Contract Amendments Modifications […]

Read More
Step by Step Guide to Configure Email to Salesforce 1 1

In this detailed guide, we will walk you through the significant yet easy steps to configure Email to Salesforce. Without any further ado, let’s get started! About Email to Salesforce As the term refers, Email to Salesforce is valuable for any organization that businesses use as their Customer Relationship Management (CRM) platform. It helps streamline […]

Read More
Guide on CRUD Operations in Node.js with jsForce

CRM developers typically need to integrate Salesforce with Node.js apps. One well-known library for this purpose is jsForce, which provides a comprehensive set of tools for interacting with Salesforce data and performing CRUD tasks effectively. Let’s dive into the blog, where you will understand the use of jsForce to execute key CRUD tasks within Salesforce, […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818