Keegan Klauke and Subi Philip Join me and our guests Keegan Klauke and Subi Philip from MRE Consulting as we journey back in time to explore their early experiences with computers. Keegan shares his passion for computer hardware and programming, sparked by early video games, while Subi talks about his initial coding experience in high school. From their first encounters with the Commodore 64 to their entrance into the Salesforce ecosystem, their stories provide a unique look into the evolution of computer technology.

Listen in as we explore the integration of chatbots with Apex processes, discussing the different use cases for designing chatbots and the importance of AI in understanding customer intent. We address concerns about toxicity and hallucinations in chatbot behavior and how to prevent them. We also discuss the process of designing and testing chatbots within the Salesforce ecosystem, discussing the importance of mapping user questions to predefined intents and providing structured responses. 

Whether you’re looking to build modern chatbots within the Salesforce platform or simply interested in the evolution of technology, this episode is packed with valuable insights.

Show Highlights:

  • The design and use of chatbots within the Salesforce platform.
  • The significance of leveraging AI in chatbot design to understand customer intent and prevent potential discrepancies.
  • The importance of mapping user interactions and providing structured responses to avoid incorrect or offensive chatbot responses.
  • The challenges of automating testing for chatbots are discussed, stressing the need for human intervention.
  • Insights for those interested in building modern chatbots within the Salesforce platform.

Links:

Episode Transcripts

Keegan Klauke:
That really got my wheels turning on computers and how do you build them, and that’s where everything started from a curiosity perspective on these things that could produce video games, it’s pretty fun.

Subi Philip:
Commodore 64 is a legend of early computers and lots of different things and capabilities that people would do on that computer.

Julián Duque:
And they are Keegan Klauke, Principal Consultant and Technical Architect, and Subi Philip, Partner and Lead Architect, both working at Emory Consulting. And I’m Julian, your host for the Salesforce Developer Podcast. I’m hitting the podcast. We share stories and insights from developers for developers.
Today we are going to talk with Keegan and Subi about building chatbots with APEX. But before, we’ll start just as we left off, and we often do, with the early year. Keegan, tell me about your first experience with a computer.

Keegan Klauke:
Oh, first experience with computer. Oh, it’s a long time ago. We actually had floppy discs and my dad bought a personal computer. It was a big deal for our family, probably one of the first people to have one. He set up in his bedroom, doing the whole work remote thing, just a little bit differently back then, and he had this one game on there that he would play, which was Solitaire. I was a little bit too young to play Solitaire, but there’s this other game called Minesweeper.

Julián Duque:
Oh yes.

Keegan Klauke:
That game was one of the first experiences I had, and I think this was probably back when I was maybe six or eight years old, that really got my wheels turning on computers and how do you build them, and that’s where everything started from a curiosity perspective on these things that can produce video games. It’s pretty fun.

Julián Duque:
Beautiful. What is your first memory Subi?

Subi Philip:
Oh, my first memory is back in the eighties, we used the Commodore 64, which is similar to Keegan’s. We use floppy discs and same thing, we play lots of early video games like Spy Hunter, which was a car racing game, which was just so much fun to play and you seal the passion and the power of computers at that time, even though that was very early. Commodore 64 is a legend of early computers and lots of different things and capabilities that people would do on that computer.

Julián Duque:
I never had the opportunity to play with one of those, always wanted, but that when I grew up, that was just for rich people. I didn’t have access to those. For both of you, who was your first experience building something, like working with software, creating a program?

Keegan Klauke:
Absolutely. So for me, my first experience building software, well, I actually started building after one computer, my dad needed to use that for work. Then he bought a second computer when the first one, quote-unquote, died. Then he bought a third computer when that one, quote-unquote, died. And by this point, I was realizing that we had three junk computers that all needed one piece replaced. So that got me onto the hardware kick of, how do these things work?
But when it comes to programming, I saw this video in 1999 called The Matrix, and that clued me into a whole world of ones and zeros that I didn’t know existed before, and that drove me to ask questions about computer programming. So I told my parents, Hey, I know that we’re not a math and science family, we never have. We’re very liberal arts focused. And I told them, “Hey, I want to learn about Java. There’s this class and it seems pretty cool and I can build video games, like my first experience.” I was like, “I want to have the opportunity to do that.” So I took a Java class and the IDE we used back then was called BlueJ.

Julián Duque:
BlueJ?

Keegan Klauke:
Yeah, very, very old school IDE, that was very click and drag functionality, but I was able to build out a video game for myself that follows the same line of Dig Dug. If you’ve ever played that video game where you run around and try to blow up little ground creatures. I was able to build that for a little capstone project in high school and that started me down that path of being interested in, and aware of, computer programming and how it all worked.

Julián Duque:
Nice. It’s great how pop culture movies influence us. For me, for example, was 1995 Hackers movie.

Keegan Klauke:
Ah, yes.

Julián Duque:
That changed my whole perspective of how interacting with computers. And what about you, Subi?

Subi Philip:
[inaudible 00:04:56] … hacker. Yeah, my experience was back in high school, so I actually went to a high school that was targeted for science and engineering and in there they actually had us take a class in Pascal. That was my first entry into actually coding and building something and learning just programming concepts was fairly new at that time and it was really exciting and interesting to see that.
What ended up happening is I entered into a science competition where we had to develop something and what I ended up developing was in Pascal, I wrote a program to do an animation of a chemistry or a chemical bond. So we programmed this, and very early animation capabilities of programming the ability to put in two chemicals and animating the ability for those chemicals to come together and bond in a visual format. It was really exciting and challenging and figuring out how to actually actually do this with Pascal. How do you write loops, how do you animate the screen and how do you then display this as a demo in the science fair, which is pretty cool. I ended up winning third place in that science fair, which was pretty nice and I got a lot of feedback from my computer programming instructor and how to improve my program, but it was still great.

Julián Duque:
Nice.

Keegan Klauke:
Subi’s been overachiever ever since high school.

Julián Duque:
That’s the way to go. That’s the way to go. And fast-forward into the future, who was the first interaction or how you got into the Salesforce ecosystem?

Subi Philip:
So for me, I actually started my career in CRM using an older CRM program called Siebel. My company at the time was switching their CRM into the latest and greatest platform. So we went from Siebel and we actually evaluated several CRM products and one of them was Salesforce and so this was back in 2005, is where I first came across Salesforce. We evaluated it and selected it to be the new Salesforce platform. So that was very, very early, which it was on Salesforce classic, but it was this concept of doing something in the cloud, storing our data there, having everything run in a browser instead of an actual application sitting on your computer. It was very different at that time, but it was great. It was this new technology at that time that we wanted to try to leverage and identify how do we customize this to actually do something for our company, which was-

Julián Duque:
You have experienced quite the evolution then?

Subi Philip:
I have. I’ve seen lots of iterations and versions of Salesforce going from Classic to Aura to now Lightning, which is cool.

Julián Duque:
Nice. And what about you Keegan?

Keegan Klauke:
So for me, introduction to, I actually had a deviation when I was going through college. I took a CS, computer science class, and I hated it so much, I hated the professor so much, that I chose to choose every class to never take a computer science throughout the rest of my collegiate experience and graduate with an electrical engineering degree, and just found a way through to not have to take any computer programming classes.
Fast-forward a year, I find myself jumping into Sigil C# and C++ programming languages for a company called Quorum Business Solutions and did that for a while in the oil and gas field, transitioned over to another on-prem solution that uses the same technologies in energy trading and risk management. Then eventually, I came over to MRE Consulting and I met this guy named Subi Philip who said, “Hey Keegan, have you ever heard of this software? It’s called Salesforce.”
And the only thing that jogged my memory on what Salesforce was, was a huge IPO, NASDAQ, I can’t remember if it’s NASDAQ or S&P 500, but huge splash. And I was like, “It’s probably vaporware. I’m sure it’s not actual software,” because I was used to the on-prem stuff using database. I’m like, “How does a cloud work? That’s just ridiculous technology.”
So Subi was like, “You should go on Trailhead, check it out for me.” So I was like, “I’ll appease him and I’ll take a look.” And he was like, “Guess what? We’ve got a client who needs some help building out a enterprise solution within Salesforce for CPQ.” I was like, “Okay, first I got to figure out what Salesforce is, now I got to figure out what CPQ is.” And I started using Trailhead to learn everything I could about the platform and the technology and I got super jazzed about it and he’s like, “All right, we’re doing it. We’re going to implement this for a client.” And that was the start of this journey of about five years in Salesforce.

Julián Duque:
Five years. So here you are. You also experience quite evolution. That’s amazing. So let’s get into today’s topic. We are going to be talking about the art of building a chatbot using APEX. And this is very relevant right now, especially in this new AI world. We are seeing AI everywhere, building AI solutions, and one of the most common applications of these AI solutions is a chatbot. But how can we build one of those using our programming language, which is APEX. Tell us more about the experience you have doing so.

Subi Philip:
Yeah, I mean when we start designing a chatbot, we really start with trying to identify what’s that business goal in mind? What are we trying to achieve and serve through this chatbot? And that’s really important to understand as we’re trying to solve some type of business challenge. Once we identify that, we map that into how much information can we surface through this chatbot? What type of use case is that?
When we design that, we integrate or design that chatbot with backend processes that we use APEX for. So APEX will go and build a lot of that logic around, how do we query the data that we’re trying to surface through this chatbot? How do we build logic in processing of information? How do we make sure that the information we’re sharing is really secure and, most importantly, how do we surface that back up through a chatbot to a consumer or a user of that chatbot so that it looks very seamless to them? It looks very user-friendly, right?
And when we deal with chatbots, it’s very important to design it with that user experience in mind. It should be very simple to them. They should not be aware that there’s a whole bunch of APEX in the background. So it’s an art of, how do we design this with all this capability in the background with APEX and other tools that we have at our fingertips, and then surfacing that back up into this product.

Keegan Klauke:
You can also leverage artificial intelligence from a learning language model, or a large language model, experience of having it establish an understanding of why might the customer be calling in or chatting with this chatbot or this interface between your company and the outside world and all of the customers. And you can also establish intent in the message if you’re using an AI model to establish, “Okay, I can guess what they’re going to ask about.” I can guess, or I can start understanding what their intents are by the way that their tone is and their communications. I can also then, at the end of it, process the recording and figure out what exactly do they want. Let me serve them something that our company believes is a good solution to this person’s problem so that the experience is a much better one for that customer.
So there’s a lot of different ways, but Subi is absolutely right. The design is the most important aspect, and knowing what you’re going to build prior to starting to build out the APEX and the lightning web components that you’re going to surface within that app and know that intent of what is this chatbot designed to do, and what functions is it going to serve and how do we leverage the existing technologies with, out of the box, Einstein bots, with all these flexible capabilities like APEX and Lightning web components to build out that whole solution that really drives a lot of value for a implementation.

Subi Philip:
Yeah, and I think the early iterations of the chatbot started with this menu-based bot. It would be a bot where it would say select one, or the first option, or whatever these options were, right? As we see this new evolution of AI and engage in a customer, we’re seeing chatbots move more toward that AI bot, where it’s using things like natural language processing to have more of a natural conversation with the person using the bot where they can say, “Hey, how can I help you?” Instead of saying, “Select from our menu.” And that makes a big difference in that user experience and it makes it more friendly and we see a higher adoption of people trying to use the bot because it goes right to what they’re looking for instead of somebody having to hunt down a solution to their problem.

Julián Duque:
Yes, we just came from, I’m not sure if you have seen this meme, that compares ML or AI with just a bunch of, if else, statements. We just came from chatbots that were just pretty much a state machine, now to chatbots that can have way more natural ways of communicating and also retrieving data from multiple sources through AI. So the evolution also has been pretty powerful.

Subi Philip:
It becomes a human-like conversation, which makes it much more easier for someone to use. Like we said, in the background, it’s pulling in all this information from all these different sources, whether it’s the web or whether it’s through APEX pulling out a Salesforce or even other data sources, it becomes seamless coming back to the user of that chatbot.

Keegan Klauke:
And I’m not going to lie, I hated chatbots a couple of years ago and just recently I’ve started using them a lot more to get to agents and to get through a company’s processes quicker. I can tell you across the board, people are getting a lot smarter on the design of these things, and so much more valuable from a time perspective, because it has those AI intents, what is this person looking to do? It’s so much better at processing it and going to retrieve information, understanding that information, and then providing the right responses, that would usually take an agent or a rep who’s maybe on the other side of a chat conversation, time to review everything. How many times have you called in? What were your intents when you called in before? Do you have any open cases? Do you have a product that’s waiting on?
This really allows you to distill a whole lot of information very, very quickly and then surface it back to the client without having to go through the human element of understanding reasoning, logic, patterns. It really speeds up that whole process, so if you’re able to build that intent model and surface that customer’s information faster, you actually have a better experience than going through a live agent, which is a really cool progression of the technology.

Julián Duque:
With AI, we have a lot of freedom in terms of the interaction that the user and the chatbot is having, but how can we prevent, for example, toxicity. Let’s say the model starts acting or behaving irrational or is responding aggressively to our customers or also how to prevent hallucinations. Those are a couple of most of the common issues that we experience today with generative AI. How to properly prevent these while designing and building a chatbot?

Subi Philip:
Yeah, I think especially with Salesforce chatbots, we have intents that we would design. So when a user of the chatbot asks a question, we would try to map that question to a predefined set of intents that we built within the chatbot that says, “Hey, this intent, they’re asking about a certain piece of information like, ‘Hey, they want to pay their bill.'” We create an intent around their bill and show and surface a much more structured response.
With the chatbot, we’re very careful of just providing open-ended responses coming back from an AI model. Some of those AI responses need to be cleansed, need to be qualified, before they send back to a user, especially in an automated fashion.
So we really try to design any type of question back to an intent with a structured set of responses. And that could still come back in an NLP type of experience, so a human-like response, but it is a structured response so that we know that we’re not trying to provide back toxicity or a response that would cause insult or, I guess, offend the user or provide an incorrect response.
So it seems like it’s an open response, but it is a very structured process when we design that chatbot and those interactions going back and forth.

Keegan Klauke:
There’s also a lot of interesting thoughts around how you can utilize APEX to store some of the information about that one conversation with somebody, and you can provide it a feedback to say, “Here’s this point in the conversation.” We asked the user, “Did this solve your problem?” And with that information that you start getting back, you can start building a data model to say, “This was the progression of this chat. What was the outcome? Did it solve their problem?” And you can even use an AI model to train on that data analytics that you’ve captured through that chat experience.
So you’re now allowing a learning model or artificial intelligence model to determine, now I’ve got all this information about these chats, I have a response from the customer to say, “Did this solve what I’m looking for?” You can then utilize that as a analysis to then generate different intents and keep a pipeline of, “Hey, this is the most affected intent that’s been presented. We might want to use this and incorporate this in the next iteration of this chatbot.” I usually don’t recommend using that output and just automatically having it learn itself, because you’re always going to want a human feedback element to it to say, “Okay, yes. Let’s utilize this next functionality,” because AI can get a little squirrelly and you want to stop toxicity from it telling itself what it thinks is the best option.

Subi Philip:
And if we don’t have a structured response or a good response to one of their questions, I think that, at that point, we might transfer to a live person to help the user because we would prefer they talk to somebody at that point to get the right answer, versus the chatbot providing the wrong answer to them.

Julián Duque:
Yeah, this will prevent a lot of frustration.

Subi Philip:
Yes.

Julián Duque:
This is fascinating. I have a question. I know all of the APEX components of the chatbot can be easily tested or write automated tests for those, but how to test the whole chatbot. Is there a way I can write automation tests for the whole chatbot, or this needs to be a human or a manual test?

Subi Philip:
Especially when we talk about designing a chatbot with an NLP model, right? So natural language processing, it’s hard to build that automated test around that. So we really try to get users to go and pressure test and test different types of dialogues and responses, so it is much more of a human test of testing that chatbot to see what type of questions can it ask, is it able to map that question to one of our intents and down the menu options and coming up with that information. So right now, for the most part, we’ve seen a lot of human testing around that versus some of that automated testing capability.

Keegan Klauke:
And couple that with the ability to store analytics on those conversations as you go through your UAT testing, allows you to surface things that you might want to incorporate either in that one or the next one. So your testing is really more of a manual test. To try and automate it, you’d be trusting a natural language processing or artificial intelligence model to do your testing for your company. You want to avoid that until you are comfortable with the results that are coming through, and if you wanted to apply an AI input to a chatbot, you can definitely do that and you can get a whole lot of information coming back from it and a whole lot of test cases, and you want to make sure that you’re trending towards the right direction of what you want your company’s brand to be and the speed at which issues can be resolved so that you don’t have to have them transfer to a live agent, eventually in the future. You want to have it be a better experience going through the bot.

Julián Duque:
Nice. I want to start building a modern chatbot today. What do I need to learn? What technical components do I need to consider for building a chatbot in the Salesforce ecosystem?

Subi Philip:
So from a technology perspective, the first part is really Salesforce chatbot UI, right? So Salesforce provides a drag and drop type of capability within their builder of the bot experience to actually create these different flows within the bot and how the bot is going to respond. So you build things like dialogues and variables and entities within the Salesforce UI itself, prior to having to know any programming.
So you can build drag and drop flows within the chatbot UI, and then when you want to get to more advanced capabilities, then you can pull in the calls into APEX classes to go query some of that data. You can also do things like embed lightning web components within your bot, which is really starting to get some rich functionality and you can build and launch lightning flows within the bot as well.

Julián Duque:
Nice.

Subi Philip:
So these are all starting to get some rich capabilities, so when you get into those type of technologies, you need to know a little bit of APEX from a querying of your data in the background. For the Lightning web components, it would be your HTML and JavaScript capabilities, and then flows, lightning flows is more of your Salesforce UI experience. But right now, even without some of those programming skills, you can still build very rich chatbot experiences, just with the Salesforce UI.

Keegan Klauke:
Yeah, and setting up a Einstein bot can be a pretty quick process. It’s really where you want to drive value is where you’re going to want to focus a lot of your efforts into, how do I want to go retrieve data using APEX and invocable methods and variables in those APEX classes. And then utilizing things like the LWC chat pack, or chat LWC pack, that exists in Salesforce labs. They have a starter kit that is a beautiful conduit to transition a chatbot to utilize lightning web components flows, rich texts, displays, even integrations to outside systems. So I highly recommend looking into those from a technology perspective if you’re wanting to take it that next step deeper and build even further on the Einstein bot platform. So you’ve got a lot of really cool functionalities available to you and technologies that you can leverage to really make the chatbot do a lot of things that a lot of other companies can’t do.

Julián Duque:
Wonderful. Any last tip or recommendation to our audience that want to start building proper chatbots?

Subi Philip:
Where to start, I think there is… The best place to start is the Salesforce Cookbook. So there is a cookbook out there that walks you through, step by step, on how to create a basic chatbot and I think that is the best learning experience. Both Keegan and I have gone through that cookbook. We created our own simple chatbots and then started to extend from there, so we highly recommend searching for that Salesforce Cookbook that they published, and it walks you through all those steps.

Keegan Klauke:
It also shows you how to bring in APEX to allow you to step out of the chatbot and go into APEX and then use all the beautiful functionalities that APEX offers as well as a flow. So it walks you step by step, what you have to go into, what you have to click, what you have to drag, what you have to identify to show that initial step out of the chatbot to go utilize everything that you’re used to using as a developer. So that cookbook is very valuable.

Julián Duque:
Excellent resources.

Keegan Klauke:
And I also want to preface that, what Subi said at the beginning, I think is the most important part about building these bots out is the design element. You don’t want to start building a bot, not knowing what your goal is going to be or what you want that chatbot to represent for your company. The more focus you have at the start of the design, the better off your result’s going to be and the more value you’re going to drive for your company.

Julián Duque:
Very important. Very important. Well, Keegan, Subi, thank you very much. One last thing, while you are not building chatbots, or helping your customers succeed, what do you do for fun in your spare time? What are your hobbies?

Keegan Klauke:
Well, for me, I love to do a lot of different things, and most of it is tied to outdoor activities. So you can find me surfing, you can find me fishing, you can find me hiking and backpacking, anything that allows me to use that other side of my passion, which is outdoors activities. Usually when building lightning web components and APEX glasses and architecture designs, that usually doesn’t allow you to do it in the mountains. So that’s one of the things I have to balance.

Subi Philip:
Forced to disconnect. For myself, I mean, I love to travel. I love to see the world. I try to travel anytime I can. I love food, so trying out great new recipes and just from very early on I’ve been trying to be very creative. So I do a lot of drawing. I draw myself and recently getting into learning music, so I’m trying to teach myself piano.

Julián Duque:
Wow. Nice.

Keegan Klauke:
And I will double that comment on the food. There’s one thing about Houston, Texas that a lot of people don’t know about is the amount of food and the quality of food and the price of that food down here is unequivocal anywhere else in the world.

Julián Duque:
Now, you know, if you ever go to Houston, Texas, go and find some great food there.

Keegan Klauke:
If you come, we’re definitely taking you out.

Julián Duque:
Awesome. Keegan, Subi, thank you very much for sharing your insights with us at the Salesforce developer community and looking forward to have you two again in our podcast.

Keegan Klauke:
Sounds great.

Subi Philip:
Thank you Julian. Great talking to you.

Julián Duque:
And that’s it for now. If you want to learn more about this show, head on to developer.salesforce.com/ podcast where you can hear all the episodes and read the show notes. Thank you everybody, and talk to you the next time.

Get notified of new episodes with the new Salesforce Developers Slack app.