Building Chatbots the Simple Way @ Hiver: Demystifying Decision Trees

Gaurav Chaudhary
Hiver Engineering
Published in
7 min readMar 28, 2024

Chatbots are everywhere these days, popping up on websites, messaging apps, and even taking your calls. But what exactly are they, and how can they benefit you? In this blog post, we’ll dive into the world of chatbots, exploring what they are, how they work, and how Hiver brought this exciting feature to life with the help of decision trees.

Beyond the Hype: What Chatbots Can Really Do for You

  • 24/7 Availability: Chatbots never sleep! They can assist users anytime, anywhere, which is especially helpful for businesses that operate globally or have customers in different time zones.
  • Boost Efficiency: Chatbots can automate repetitive tasks, such as answering frequently asked questions or providing basic customer support. This frees up human agents to focus on more complex issues that require a personal touch.
  • Cost-Effective: Chatbots are a cost-effective way to provide customer service and support. They can handle a high volume of inquiries without the need to hire additional staff.
  • Data Powerhouse: Chatbots can collect valuable data about user interactions, which can be used to improve the chatbot’s performance and gain insights into customer behaviour.
  • Always-on Marketing: Chatbots can be used to promote products and services, and guide users through the sales funnel.

Different Types of Chatbots and Their Applications

Chatbots have become an undeniable force in the digital world. From answering your bank’s FAQs to scheduling doctor appointments, these virtual assistants are transforming how we interact with businesses and information. But with all the buzz, it’s easy to wonder: just what kind of chatbot are you talking to? The truth is, there’s not just one type of chatbot. Let’s explore the different varieties and how they’re used:

1. The Rule-Based Responder: Simple and Straightforward: Think choose-your-own-adventure for customer service. That’s a rule-based chatbot in a nutshell — pre-programmed answers based on your clicks or keywords. Great for FAQs, basic troubleshooting, or pointing you in the right direction.

2. The NLP Whiz: Understanding Your Lingo: Natural Language Processing (NLP) takes chatbots to the next level. These chatbots can analyze the user’s intent behind the words, allowing for more natural conversation. They can even identify synonyms and understand the context of a conversation.

3. The Machine Learning Master: Learning and Evolving: Machine Learning (ML) chatbots are the Einsteins of the bunch. They can learn from past interactions and user data, constantly improving their ability to understand and respond to queries.

Why Decision Trees are a Great Choice for Simple Chatbots: So you want a chatbot, but complex AI seems overwhelming? No worries! Decision trees are your secret weapon for crafting effective and easy-to-use chatbots.

What are Decision Trees?

Think choose-your-own-adventure story, but for chatbots! Decision trees map out conversations like a flowchart. Users answer questions, and their choices guide the conversation down specific paths. This ensures the chatbot delivers the most relevant response. Why Decision Trees Rule for Simple Chatbots?

  • Crystal Clear Conversations! Users can effortlessly follow along. They know what kind of answers to expect, avoiding confusion and frustration.
  • Order & Accuracy! Decision trees keep things organized, guaranteeing consistent and reliable responses each time. This builds trust with users who know they can depend on the bot for solid info.
  • Problem-Solving Pro! Simple chatbots are great at tackling repetitive tasks and answering FAQs. Decision trees let you automate these interactions, freeing up human agents for more complex stuff.
  • Always on Duty! Chatbots powered by decision trees provide support around the clock. They answer questions and offer help whenever users need it, day or night.

Decision trees are like superheroes for building helpful and user-friendly chatbots. They’re easy to create, promote clear communication, and solve common problems like a boss. With a decision tree at the heart, your simple chatbot can become a super-powered asset!

Demystifying Decision Trees: A Beginner’s Guide

  • Breaking Down the Basics: Core Components of a Decision Tree: Decision trees might seem like tangled webs of information, but they’re quite organized! Imagine a branching tree, where each split is a decision point. Here’s a breakdown of the key components that make decision trees tick:
  • Nodes (⭕️): These are the little circles or squares on the tree, representing key decision points. There are three main types:
  • Root Node (): The king of the tree, this is where the journey starts. It holds all the initial data. This can be a click on a chat button, nudge or anything that is the entry point for your chat app.
  • Decision Nodes (❓): Think of these as checkpoints. They ask questions based on features of the data (like “Is it sunny?”). The answer determines which branch to follow.
  • Leaf Nodes (): These are the final destinations. They hold the final prediction or classification based on the path taken through the tree.
  • Branches (➡️): These lines connect the nodes, showing the different directions the decision process can take based on the answers at each step.

By understanding these core components, you can unravel the mystery of decision trees! They work by asking a series of questions and splitting the data at each step until they reach a final answer at a leaf node. Pretty cool, right?

Visualizing the Flow: How Decision Trees Make Choices: Now that you know the parts, let’s see a decision tree in action! Imagine you’re using a chatbot for customer service. Here’s a possible scenario:

  • The conversation starts at the Root Node, which has information on all customer inquiries.
  • The first Decision Node might ask, “What department are you contacting us about?”
  • Depending on your answer (Sales, Billing, etc.), you’ll be directed down a specific Branch to the relevant Decision Node.
  • This new node might ask a follow-up question specific to your department.
  • With each answer, you travel down a specific branch until you reach a Leaf Node.
  • Finally, the Leaf Node displays the most relevant response or solution based on your conversation path.

Ready to Build Your First Chatbot? Here’s the Tech You Need to Know!

So you’ve decided to build a chatbot — fantastic! But before you dive in, there are some key elements you’ll need to consider. This post will explore one crucial component: the workflow builder.

  1. Workflow Builder: For businesses, a workflow builder is the magic behind creating customised conversation flows for their chatbots. Imagine a visual tool where you can drag and drop elements to design the decision-making process of your chatbot. This builder utilizes decision tree logic, allowing you to define how the chatbot responds based on user input. Building a workflow builder requires selecting the right framework. Here at Hiver, we explored several options before settling on two strong contenders: ReactFlow and JointJs. Ultimately, the decision came down to our existing technology stack. Since our app is built on React, ReactFlow emerged as the most suitable choice. We’ll provide resources for those interested in learning more about ReactFlow.

2. Chatbot Engine: This critical component takes the workflows you meticulously crafted in the builder and uses them to send targeted messages to visitors interacting with your website widgets. Imagine it as the conductor of an orchestra, translating the sheet music (your workflow) into a smooth and engaging conversation for your website visitors.

Here at Hiver, we embarked on a quest to find the perfect pre-built chatbot engine. We evaluated various tools and frameworks, including CSML-based bot builders, Rasa, and the Botpress framework. However, none of them perfectly aligned with the specific functionalities we envisioned.

Faced with this challenge, we decided to take the reins and build our own custom chatbot engine. This approach allowed us to tailor the engine to our exact needs, ensuring seamless integration with our workflow builder and flawless execution of your chatbot’s conversation flows.

3. A Webhook module that can listen to active conversations and pass on the decision tree logic-based replies to the chat widget. Since we use open source version of Chatwoot, we reused the webhooks and extended the logic to implement those webhooks.

4. A Chat widget that would display the decision trees in the form of a flow received from the above components.

Wrapping Up: Building Your User-Friendly Chatbot with Decision Trees

Now that you’ve explored the world of chatbots and the power of decision trees, you’re well on your way to crafting your user-friendly virtual assistant! Decision trees offer a clear and approachable way to build a chatbot that tackles those essential tasks and provides real value to your users.

Remember, the key to success lies in understanding your audience and their needs. By clearly defining your chatbot’s purpose and mapping out the conversation flow, you can ensure your chatbot delivers a smooth and informative experience. Don’t wait, elevate your customer service. Try Chatbots on Hiver now!

--

--