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
Hands-On Guide Building a Drag-and-Drop Form Builder Using Lightning Web Components

Drag-and-drop interfaces are a user experience staple, and when paired with the power of Lightning Web Components (LWC), they unlock dynamic, highly interactive Salesforce components. In this blog post, we’ll walk you through how to build a custom drag-and-drop form builder in LWC. Users can drag form fields like text inputs and dropdowns into a […]

Read More
Please Make Blog Banner How to Create an Agentforce Enabled Scratch Org in Salesforce 100 1

Setting up an Agentforce-enabled scratch org is the most important step for developers who want to experiment with AI features such as Prompt Builder and Einstein GPT. Whether you’re developing the next generation CRM software or experimenting with how generative AI may improve user experience, a scratch org equipped with Agentforce is your playground. Follow […]

Read More
Step-by-Step Guide to Enhance Your LWC Development Workflow with the Logger API

Are you looking to streamline your LWC development workflow but confused about how to do it? Then you are in the right place. The Salesforce Logger API is a powerful tool that helps you monitor, debug, and improve code quality in real time.  This step-by-step guide walks you through how to set it up and […]

Read More
Enhancing Your Salesforce Experience with a Custom Activity Component

In today’s fast-paced business landscape, productivity hinges on streamlined workflows and intuitive interfaces. While Salesforce offers robust activity tracking capabilities, sometimes the standard components fall short of specific organizational needs.  That’s where a Custom Activity Component comes in—designed to tailor your activity management experience, boost user efficiency, and provide deeper insights into customer interactions. In […]

Read More
Step-by-Step Guide to Integrating Salesforce Doc-Gen with eSigning Tools

In today’s fast-paced digital landscape, streamlining document workflows is no longer a luxury—it’s a necessity.  Integrating a document generation app, like Docs Made Easy, with an eSigning tool, helps businesses automate the entire document lifecycle—from creation to signature—saving time, reducing errors, and boosting productivity. In this guide, we’ll walk you through the key steps, tools, […]

Read More
How to Build a Real Time Chat Application Using LWC and Models API

The Models API plays a significant role in providing access to and facilitating interaction with large language models (LLMs) from various Salesforce partners such as Anthropic, Google, and OpenAI. It enables applications to leverage these models for various tasks, including text generation and other AI-powered capabilities. As a user, you can configure any Salesforce-enabled model […]

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