Back to blog

How To Build A Scalable Chatbot Architecture From Scratch 

In this publication series, we’re going to cover our best practices used during developing IT projects. If you’ve ever had thoughts about developing chatbot and conversational platform for your business  —  you’re in the right place, because today we’re going to start from the very beginning of any project  — architecture.  We hope that everyone will learn something useful and valuable in this publication. 

Moving right along, we strongly recommend you to separate chatbot module and conversation logic from the rest of your back-end system. Later we will find out why it’s important, prudent and how this can be beneficial for your project.

Let’s imagine that our imaginary chatbot project’s main goal is to deliver visualization of trading stocks data. In this case, we will need a module for fetching, storing and visualizing information. 

The microservice architecture will be more beneficial, as it ensures decentralization and the ability to easily connect separate entities. Moreover, scalability and speed are the other two key factors that will definitely impact chatbot performance. Therefore, it’s obvious that separating each module as a microservice in our architecture makes sense. Moreover, it’s profound and important to have each module scalable and resistant to high loads.

In fact, a conversational interface as a mobile app, messenger or even custom web chat – is potentially one of the future possible solutions for this issue that will ensure handy user interaction. Imagine the situation when you have defined everything in one module? So, how would you scale and encapsulate the business logic, when it’s mixed with conversation flow? In this case, it’s profound to separate REST API and NLU/NLP modules to provide the chatbot architecture with higher flexibility, as in the example below:

As you can see, it’s pretty easy to add new interfaces if you have seen anything about dividing the project into 3 or more major modules: Rest API, entire conversational flow and NLP/NLU usage. Now let’s talk about each architecture module in detail.

Chatbot Interfaces (front-end)

Surely the frontend of the bot plays an indispensable part in our project. Webchat on the website serves as the interface through which users can interact and talk with the bot. We really prefer using own web-widget, that has lots of advantages, amongst which there are:


Certainly, Facebook, WhatsApp, Slack or many other platforms are widely used, but they all have lots of restrictions of controllers you may use. So, the user will see only predefined, limited and equally designed for concrete platform calendars, buttons, notifications, file uploaders, and viewers.
In contrast, we may create as many as needed of our own custom elements, designed in colors, forms, and sizes, as our imagination allows.

Dynamic interaction

It’s a matter of fact. Users want to get the most when it comes to using bots. Sending not a static picture, but rather a rendered HTML chart, that looks like a picture with clickable inner elements — is the feature that attracts and makes our bot stand out among the rest.

AWS Lambda + AWS API Gateway

In our system, these notions stand for the core API of our system.
It’s not a secret that one of the biggest strengths of AWS Lambda functions is the reduced cost of execution. In a traditional web application, with code hosted on  and accessible through  an EC2 machine instance in AWS, you need to pay for the server usage regardless of the fact whether your API is actually in-use or not. The cost of the idle-time can be very high, depending on the instance particulars you’re working with.
As our project is not hosted on a specific server, we also considerably reduce the risk that our machine might break down. It can be easily substantiated: we aren’t obligated to rely upon a single machine to perform all the tasks of serving the app and executing the code . If one machine goes down, the process of replacing it is handled automatically by AWS. In other words, AWS “cares” for a problem instantly and our code doesn’t miss a beat.

AWS ElasticCache Redis

In our project, it’s users for the highly scalable caching system storing temporary data(cache, tokens, API calls counter, etc.). So, it’s not so “expensive” to make the same API calls or access databases with repetitive queries dozens or hundreds of times a day. However, it can be challenging to get it working with AWS Lambda. We’ll prepare an entire publication on this topic on the next series. Stay tuned 🙂

AWS DynamoDB

It offers built-in security, backup, and restores, as well as in-memory caching. Furthermore, it was extremely easy to implement it into our current system.

Main reasons why we use it:

  • Fast and owing single-millisecond latency
  • Integrated with most of AWS Services such as IAM, CloudWatch, etc.
  • Autoscale and elastic in nature
  • Virtually infinite storage 


Being in the process of cutting usage down as much as possible, AWS EC2 is still used for the static images generation due to AWS Lambda limitations. The main usage of it is based on the FusionCharts and uploading pictures, as well as infographics generation. But this point is highlighted in the next chapter.

In the first version of the chart, targeted for static image generation, we used Export and Upload service developed by FusionExport team. The rendered HTML is literally screenshotted, uploaded to the AWS S3 service that prevails over others due to the security, low cost, and scalability. For the same reasons, AWS S3 was used to store widget plugins and admin-pages for our project.

Let’s draw an interference from all above-mentioned:
To a certain extent, using AWS services makes the mind of the developer free of redundant anxiety regarding the machine “life.”
Mulling over correct architecture in advance plays a pivotal role in the project development.
Using Lambda + API Gateway definitely prevails over EC2 machines, as AWS automatically defines select new instances when it’s needed, so the application is an endless-liver.

In the next series, we’ll talk about using different charts services, caching process, experience, and comparison of a couple of other platforms we used. Stay frosty!

Back to blog

WhatsApp Business API: Common Questions for Chatbot Implementation

WhatsApp is on everybody’s A-list. It’s nothing new that WhatsApp is on the hype and most companies want to implement the bot into for business. Statistic says, that today messenger has 1.6 Billion monthly active users across 170+ Countries and 80% of messages sent to WhatsApp are seen within 5 minutes compared to the traditional SMS. Looks impressive but there are still a lot of uncovered questions that go on and on.

So, I gathered the most important for development and implementation questions that cover WhatsApp Business API. In the course of creating the article, I also checked Quora questions I’ve previously answered related to the topic. Please check the following list and write the questions you want to know.

WhatsApp bot


What is a WhatsApp bot?

For now, the WhatsApp bot seems like a simple AI solution. The bot for this messenger communicates only through text chat and images. Buttons and additional tools are not possible like on other messengers.

How safe are WhatsApp bots?

WhatsApp bots are very safe. Compared with other platforms, WhatsApp bots really encrypt messages. Messages to the WhatsApp server come via encrypted format. Check WhatsApp Availability and Scaling to understand how the service architecture provides this.

How do I build a simple Whatsapp bot?

To create a simple bot for WhatsApp without any additional help you can use the Twilio API that allows one start building and prototyping in a sandbox. Visit Twilio API for WhatsApp to understand how it works.

Is it possible to integrate a chatbot in Whatsapp which replies to my messages?

As mentioned previously, you can already build a bot for WhatsApp. First of all, install and set up the WhatsApp server. Then you will get access to the API that gives the opportunity for a bot to start working.

Warning: the bot will start working if it is created with programming languages but not with cloud platforms.

You can probably integrate a chatbot with WhatsApp but you’ll need to create an integration by yourself.

Launch the following services:

Getting Started — Quick outline of how to get started and next steps

Network Requirements — Network requirements necessary for the WhatsApp Business API client to connect to WhatsApp servers

Phone Number — Verify and register your business’s phone number

Verified Name — Display your business’s name when talking to your customers

Volumes — Securely store WhatsApp data while using Docker

Installation and Upgrading — Installation scripts and guide to get the WhatsApp Business API client running

HTTPS Setup — Set up and use HTTPS endpoints

Users endpoint — Create, manage, and use access tokens and user accounts for additional security

Backup and Restore Settings — How to backup and restore your WhatsApp Business API client

Deploying WhatsApp on AWS — Create an Amazon Web Services cloud to run the WhatsApp Business API client

Rate Limits — WhatsApp Business API endpoint rate limits scenarios

Understanding How to Get Opt-in for WhatsApp — How to present your users with an opt-in for messaging

Postman Collection — Import our WAE Developer Collection into Postman to quickly test the WhatsApp Business API

Then create an integration code with AI WA. Check out API Reference to understand how to build that. Here you find information regarding WhatsApp Business API Root Nodes and example of WhatsApp Business API format uses the contacts node.

How do I create a computer bot that can automatically reply to all our Facebook and Whatsapp messages?

As far as I know, one of the solutions is to use the Twillio API for WhatsApp using a simple REST API. The Twilio API for WhatsApp allows developers to start building and prototyping in a sandbox. In order to launch apps in production, you can request access to enable WhatsApp on your Twilio number. WhatsApp is currently opening up access in a Limited Availability program, where WhatsApp approval is required for all customers who wish to create their own profiles. Check out this link to start work with Twiliio API.

Other platforms, for example, Clare.AI and Hubtype, are still in beta testing. You can use these ones if you have the time when it will be launched.
For now, start learning how to make your bot for WhatsApp using WhatsApp Business API. So, the solution is to learn guidelines and tutorial and develop bot by yourself or pass the work to agencies.

How can I connect a WhatsApp group with a Telegram Group using a bot?

As of now, there isn’t any opportunity to work with groups in WhatsApp, unfortunately. As far as I know, only p2p communication is possible.

How accessible is the WhatsApp API?

WhatsApp API is accessible after branching on servers. Check this Installation and Upgrading to understand how it works in coding.

How can I get Whatsapp API?

First of all, install and update the WhatsApp Business API Client using Docker Compose. Follow all the steps and then you will get the WhatsApp API as you need it.

Make sure you have gotten approval for your business’s phone number and have a Verified Name certificate before attempting installation.

Initial Setup

Before continuing, please read through the other WhatsApp Business API guides.

This guide requires Docker, a container platform that lets you run the WhatsApp Business API Client. Docker Compose is also required. Docker Compose is bundled with Docker for macOS and Windows but requires a separate installation on Linux.

1. Install Docker on your system.
2. If Docker Compose is not bundled with your Docker installation, install it.
3. Download the docker-compose.yml and db.env configuration files: (find it here)
4. Open a console and navigate to the directory where you saved the downloaded files.
5. If you have a MySQL installation running, change the values in the db.env file to reflect your MySQL configuration. If you do not have MySQL installed, the docker-compose.yml and db.env files have a default configuration to bring up an instance in a local container.
6. Run the following command in the console:

docker-compose up

You will get some output, while the script downloads the Docker images and sets everything up. To run the containers in the background, use the -d parameter:

docker-compose up -d

Once you have completed these steps, ensure that the containers are running with the following command:

docker-compose ps

By default, the Web app container will be running on port 9090.

You can download and configure our Postman Collection to easily interact with the WhatsApp Business API.

Refer to the Registration documentation for next steps.


Please note that the list could be supplemented by other related questions. If you have anything to add, please share it with us and we’ll include it in the existing list. So, follow me and stay on top of WhatsApp chatbots novelties.

Get a Quote