In this session, you will learn,
- How to build a chatbot with docker container
- How to Build an environment free chatbot with no dependencies
Before starting I am assuming that you have docker already installed on your system. If you don’t have docker installed on your system then check this blog.
Now, when you have a docker installed on your system, we can start further. Let’s first understand what exactly we are doing here. In this blog, I’ll show you how to create an initial chatbot with rasa so that a user can talk to the bot. If you are already familiar with Rasa chatbot then you will surely say that for that you need to set up an environment and then install all the packages into it and then initialize your project. Yes, you are absolutely correct. But this time we will use the docker container for this and with docker, you don’t have to create a virtual environment to setup and install the dependencies.
Here, your docker container will it self work as a virtual system where you can set up and add all the dependencies as per the application you are working with.
So, the benefit of using a docker container is that you don’t require a virtual environment when you have a container with you. Also, there are negligible chances of conflicting of one docker application with other as different containers are independent of each other.
How to create a Chatbot inside a docker container
For creating a chatbot yo have to pull a docker image for rasa from the docker hub which will have all the dependencies and packages installed in that docker image. For installing that execute the following commands on the terminal or command prompt:
docker run --user 1000 -it -v $(pwd):/app rasa/rasa:1.10.8-full init --no-prompt
In the above commands, first two commands are to create and new directory with name RasaDockerTest and to change to that directory. And the last command is user to mention which docker image I’m using which will create the initial project for rasa. Here, I’m using the repository name as rasa/rasa and tag is 1.10.8-full. For rasa repository you can pull different tags with different versions. Tags can be in these formats:
For the first time when you will run this command, it will try to search the image on your system. If it exists then it will use the existing image otherwise the mentioned image (means rasa/rasa:1.10.8-full) will be pulled from the docker hub. It may take time to pull the image depending upon your internet speed.
The last command is directly linked to the docker container which means whatever changes that you will make here will be updated inside the docker container as well. Once the last command is executed successfully. You will see all the files and directories will be created automatically inside your current directory. The files and directories inside the current directory is the initial rasa chatbot which you may have seen while creating the rasa project like in here:
When you have successfully executed the last command, now we cal run our next command to talk to the bot.
docker run --user 1000 -it -v $(pwd):/app rasa/rasa:1.10.8-full shell
The above command is equivalent to rasa shell the only difference is that this command doesn’t require any environment to be activated before executing this command, this will open the chat window for you to talk to the bot. This is how the output will be when you will talk to the bot using a docker container.
You can also check this session for more clarification:
Learn more on Rasa chatbot here.
This is all about the Setting up of your rasa chatbot inside a docker container, I hope you have gained some good quality of knowledge from here. If you have any query then feel free to leave your query below in the comment section.
For more understanding and clarification on rasa chatbot, you can check out the official website of rasa and docker hub. Also, you can check these video contents for the deployment of rasa Chabot on the live server with Google Cloud Platform and link it to the domain name.
Stay tuned and Happy Learning.