Rasa-Chatbot-For-Agriculture-Value-Of-Farmers(VOF) to help the farmers via a medium to know about various crop cultivation tactics and the estimation of product usage to make the complete utilization of the available resources. The farmer can contact through a medium(an Agri expert) to know details about the land and preferred methods to do cultivate and know about new resources.
Rasa step-wise documentationCheck if your Python environment is already configured:
$ python3 --version
$ pip3 --version
If these packages are already installed, these commands should display version numbers for each step, and you can skip to the next step.
Otherwise, proceed with the instructions below to install them.
Fetch the relevant packages using apt, and install virtualenv using pip.
$ sudo apt update
$ sudo apt install python3-dev python3-pip
Install the Homebrew package manager if you haven’t already. Once you’re done, you can install Python3.
$ brew update
$ brew install python
Make sure the Microsoft VC++ Compiler is installed, so python can compile any dependencies. You can get the compiler from Visual Studio. Download the installer and select VC++ Build tools in the list. I Install Python 3 (64-bit version) for Windows.
pip3 install -U pip
Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:
$ python3 -m venv --system-site-packages ./venv
Activate the virtual environment:
$ source ./venv/bin/activate
Create a new virtual environment by choosing a Python interpreter and making a .\venv directory to hold it:
python3 -m venv --system-site-packages ./venv
Activate the virtual environment:
.\venv\Scripts\activate
You can also create an environment using anaconda navigator. For more information, refer to the documentation in the link. https://docs.anaconda.com/anaconda/navigator/getting-started/
Ubuntu / macOS / Windows: First make sure your pip version is up to date:
$ pip install -U pip
To install Rasa Open Source:
$ pip install rasa
Setting up files:
-
Make a new folder for the bot and save all the bot related files in it. Let’s name the folder “rasa” for convenience.
-
Under “rasa” folder, make a folder named “data” and add the two files namely “stories.md” and “nlu.md”. “Stories.md” file contains the story data and “nlu.md” contains the intents.
-
Under “rasa” folder, make another empty folder named “models”. This is where our trained models will be saved.
-
Under “rasa” folder, make a “config.yml” file where the pipelines and policies used will be mentioned. It is configuration of your NLU and Core models.
-
Under “rasa” folder, make a “domain.yml” file where all the intents and actions along with the templates will be mentioned.
-
Under “rasa” folder, make a “credentials.yml” file where the details for connecting to other services is mentioned.
-
Under “rasa” folder, make a “endpoints.yml” file where the details for connecting to channels like fb messenger is mentioned.
-
Under “rasa” folder, make a “init.py” file. Its an empty file that helps python find your actions.
-
Under “rasa” folder, make a “actions.py” file where code for your custom actions is mentioned.
In command prompt, activate your environment and go to the “rasa” folder location. Then run the following commands.
-
To train:
rasa train
-
To run the bot:
rasa shell
Now your bot is running and you can give input messages.
Integrating the bot to personal website:
-
add the below configuration in the credentials.yml file:
socketio: user_message_evt: user_uttered bot_message_evt: bot_uttered session_persistence: true
-
start your bot using the below command. Type this command in another cmd terminal.
rasa run -m models --enable-api --cors "*" --debug
-
After running the above command, check where the rasa server is starting on. Here it's on “5005”.
-
Now go to this link https://github.com/botfront/rasa-webchat and add the code in “body” tag of your html page or copy the
below code under “body” tag.
<div id="webchat"/>
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-latest.js"></script>
// Or you can replace latest with a specific version
<script>
WebChat.default.init({
selector: "#webchat",
customData: {"language": "en"}, // arbitrary custom data. Stay minimal as this will be added to the socket
socketUrl: "http://localhost:5005", //take note, the 5005 is because our rasa server is working on 5005
socketPath: "/socket.io/",
title: "Title",
subtitle: "Subtitle",
})
</script>
Note: In the above code, change the socket url port number to our rasa server's port number. Also make sure in the “credentials.yml” file this is added:
rasa:
url: "http://localhost:5005/api"
(5005 because rasa server port number is 5005)
Below is the format of adding a image into the bot. We cannot directly add the image Instead we add the Url of the image in the domain.yml in the template as:
utter_cheer_up:
- text: "Here is something to cheer you up:"
image: "https://i.imgur.com/nGF1K8f.jpg"
For adding link in the bot, add the following code in the template of domain.yml
utter_link:
- text: "Please click link to continue: [click here for link](https://www.google.com/)"