Rasa Advanced Deployment: Part 4 (Custom Action Server)
Tags: Chatbots, Kubernetes, Docker, Rasa, Deployment

If you are familiar with rasa then you know that we can’t achieve everything without creating custom action.

Custom actions turn your assistants into magic. A custom action is where you put most of your assistant’s code written in Python. This can be used to make an API call or to query a database for example.

So let’s create your custom action server.

For running the custom action first we have to connect the git repo and we know how to do it the same as we talked about in the previous blog.

Do the following steps to connect the git repo.

2. Navigate to your forked copy

3. Copy the SSH URL from your GitHub repository

4. Connect Integrated Version Control in Rasa X

Specify the branch you want to use as master

Check “Require users to add changes to a new branch”

Do step 5 first, then click on “Verify connection”

5. Copy/paste the Deploy Key in your GitHub repository settings

Check “Allow write access”

Now we have connected our git and we will train our model. Let’s make active to our newly trained model.

Now training is not sufficient to talk with a bot we required to start an action server. For that, we have to create a docker image of our custom actions. So let’s see how can we achieve that.

Open a VM and issue the below-given commands

clone your forked repo to the VM

git clone https://github.com/[YOUR-GITHUB-NAME]/deployment-workshop-bot-2.git

Change directory

cd deployment-workshop-2

Build docker

docker-compose build

When the build is done at that time we will see this URL localhost:32000/deployment-workshop-bot-2-action-server:0.0.1 which we use in the following command.

Here we will do a container registry of our image into our cluster.

docker push localhost:32000/deployment-workshop-bot-2-action-server:0.0.1

While pushing you might get some error like connection refused or reset by peer then you can solve that problem by following this great article.

The steps I have done to solve the problem are as follows.

Start a registry

docker run -d -p 32000:5000 --restart always --name registry registry:latest

Edit C:/Windows/system32/drivers/etc/hosts file

#Add this line in docker edited part

127.0.0.1 localhost

::1 localhost

Now try to push the image and if it’s work then try to remove the line that we added in C:/Windows/system32/drivers/etc/hosts and then pull the image docker pull localhost:32000/deployment-workshop-bot-2-action-server:0.0.1 . if it's work then leave it as it is otherwise add that line again.

Till now our action server is pushed on the registry but not started yet. So let’s see how we can start the action server.

Step 1: Add the docker image URL into the values.yml file.

# custom action server

app:

# from microk8s build-in registry

name: "localhost:32000/deployment-workshop-bot-2-action-server"

tag: "0.0.1"

Step 2: Upgrade helm chart

On VM issue this command.

helm --namespace my-namespace upgrade --values values.yml my-release rasa-x/rasa-x

Remember when we do some changes in values.yml it will not come in actions until we will run this command.

Let’s check if our custom action is running or not by navigating the talk to bot section in rasa-x.

We can see that greet comes from our custom actions.

That’s all for today in the series of advance deployment of the Rasa chatbot. Keep an eye on the series of this blog. Till then, Happy Coding!!!

References:

If you like this post, HIT Buy me a coffee! Thanks for reading.

Your every small contribution will encourage me to create more content like this.