DEV Community

Cover image for How I built an AI Chatbot in 5 minutes 😎
Med Marrouchi
Med Marrouchi

Posted on

How I built an AI Chatbot in 5 minutes 😎

Hey chatbot enthusiasts! If you're passionate about building chatbots, today we're diving into Hexabot, an open-source AI-powered chatbot builder. In this guide, we'll walk through the process of setting up Hexabot and building a simple chatbot.

Let's get started!

What is Hexabot?

Hexabot is an open-source AI chatbot builder that allows you to create and manage chatbots across various platforms. It's designed to be highly customizable, enabling you to add your own NLU models, create complex chatbot flows, and manage everything through a visual editor. It’s available on GitHub under the AGPLv3 license, and you can check out the introductory video on our YouTube channel.


Step 1: Cloning the Hexabot Repository

The first thing you'll need to do is clone the official Hexabot GitHub repository. Here’s how:

  1. Copy the GitHub repository URL from here.
  2. Open your terminal and run the following command to clone the repo:


git clone https://github.com/hexastack/hexabot.git


Enter fullscreen mode Exit fullscreen mode

Once the cloning is complete, navigate into the project folder:



cd hexabot


Enter fullscreen mode Exit fullscreen mode

Step 2: Installing Dependencies

After cloning the repo, install the required dependencies using npm:



npm install


Enter fullscreen mode Exit fullscreen mode

This will install all the necessary npm packages for the project.


Step 3: Setting Up Environment Variables

To configure Hexabot, you’ll need to generate a .env file. Use the following command to initialize the environment variables:



npx hexabot init


Enter fullscreen mode Exit fullscreen mode

This will generate a .env file under the docker/ folder. You can customize this file if needed to adjust things like database settings and API keys.


Step 4: Starting Hexabot

Hexabot offers two modes:

  1. Production mode (npx hexabot start), which pulls Docker images from Docker Hub.
  2. Development mode (npx hexabot dev), which builds the Docker images locally for development purposes.

For this guide, let's start with production mode:



npx hexabot start


Enter fullscreen mode Exit fullscreen mode

This will pull the necessary Docker images for MongoDB, API, the widget, and the admin panel.


Step 5: Accessing the Admin Panel

Once the Docker containers are running, open your browser and go to:



http://localhost:8080


Enter fullscreen mode Exit fullscreen mode

For the initial login, use the default credentials available in the README file (admin@admin.admin / adminadmin). After signing in, you’ll be taken to the visual editor.


Step 6: Building a Chatbot

Hexabot’s visual editor is where the magic happens. It's a canvas where you can drag and drop blocks to design your chatbot's flow. Let’s walk through a simple example:

  1. Create a block: Double-click on the canvas to add a new block.
  2. Define a trigger and response: For example, you can add "hi" as a trigger, and the chatbot will respond with "hi back."
  3. Set as entry point: Don’t forget to toggle the block as the entry point if you want it to start the conversation.

Step 7: Testing Your Chatbot

You can use the Live Chat Tester to test the chatbot right in the admin panel:

  1. Open the live chat tester.
  2. Type "hi" and you should see the chatbot respond with the message you’ve set.
  3. You can chain additional blocks to create more complex interactions, like asking for a user’s name or offering quick replies.

Step 8: Adding More Complex Logic

You can continue enhancing your chatbot by adding blocks for different user inputs. For example, you can:

  • Use Quick Reply blocks to offer choices to users.
  • Chain multiple blocks together for more advanced conversations.

For instance:

  • If the user says, "How are you?" the bot could respond, "All good, how about you?"
  • Continue building logic like these to create a rich conversational flow.

What’s Next?

This post covers the basics of setting up Hexabot and building your first chatbot. We will explore advanced features in future tutorials, like handling user intents, adding custom plugins, and using the NLU engine.


Stay Connected

I encourage you to join our community:

Don’t hesitate to share your feedback in the comments below! I'd love to hear how you’re using Hexabot.

Top comments (0)