rauldpm / ChatbotTFG

This project houses a chatbot built with the Open Source Rasa software.
GNU General Public License v3.0
0 stars 0 forks source link

Deploy bot and allow the use via Telegram #9

Closed rauldpm closed 1 year ago

rauldpm commented 2 years ago

This issue aims to manually deploy the bot on a platform of your choice and enable the use of the bot on Telegram.

rauldpm commented 1 year ago

Update report - Option 1 Ngrok

A first approximation has been made using ngrok, which allows obtaining a public address and linking the rasa server with telegram, for this, I have followed the following steps:

At the same time, it is necessary to start the rasa and actions server:

In this way rasa receives and sends messages in JSON format, locally, the following can be executed:

curl -XPOST http://localhost:5005/webhooks/rest/webhook -H "Content-type: application/json" -d '{"sender": "test", "message": "Horario"}'

Having the answer:

[{"recipient_id":"test","text":"Nuestro horario es:"},{"recipient_id":"test","text":"Lunes: 08:00 - 22:00.\nMartes: Cerrado.\nMiercoles: 08:00 - 22:00.\nJueves: 08:00 - 22:00.\nViernes: 08:00 - 22:00.\nSabado: 08:00 - 22:00.\nDomingo: 08:00 - 22:00."}]%

When runing ngrok you get an output like the following:

ngrok                                                                                   (Ctrl+C to quit)

Phishing is against the TOS. Don't do it.                                                               

Session Status                online                                                                    
Account                       (My name) (Plan: Free)                                         
Version                       3.0.6                                                                     
Region                        Europe (eu)                                                               
Latency                       -                                                                         
Web Interface                 http://127.0.0.1:4040                                                     
Forwarding                    https://8bd6-188-78-170-15.eu.ngrok.io -> http://localhost:5005           

Connections                   ttl     opn     rt1     rt5     p50     p90                               
                              0       0       0.00    0.00    0.00    0.00

Where https://8bd6-188-78-170-15.eu.ngrok.io is the public address to set in the credentials file

When creating the bot using BotFather in Telegram, you need to set a name for the bot and an identifier:

Then we are provided with a TOKEN that must be entered in the credentials.yml file as follows

telegram:
  access_token: "{BOT_TOKEN}"
  verify: "restaurante_rauldpm_bot"
  webhook_url: "https://{NGROK_URL}/webhooks/telegram/webhook"

Once everything is configured, you can access an ngrok interface where the requests made are reported:

image

Conversations on Telegram

telegram1


telegram2


telegram3


This option is used to test on Telegram, since it does not cost money and has a limited number of requests, but it does not serve to carry out a definitive deployment in production due to the limitation of requests and availability

rauldpm commented 1 year ago

Update report - Option 2 Heroku

Heroku provides up to 5 deployments for free but with limited hardware https://www.heroku.com/pricing

The free plan provides:

The standard plan provides from 512MB to 14GB with a fixed price range from $25 to $500.

Due to the little flexibility that this platform has (the bot will increase its requirements as more stories are learned with the users), the deployment in Google Cloud and AWS ECS will be studied.

rauldpm commented 1 year ago

Update report - Option 3 AWS

aws configure
aws ecr get-login-password | docker login --username AWS --password-stdin {created repo_url}
docker build -t rasa-server .
docker build -t rasa-actions .
docker tag rasa-actions:latest {repo_url}/tfg:rasa-server 
docker tag rasa-actions:latest {repo_url}/tfg:rasa-actions 
docker push {repo_url}/tfg:rasa-server 
docker push {repo_url}/tfg:rasa-actions 

image

This option allows for extensive customization of the environment through the use of EC2, ECS, CloudFormation, IAM, and others.

An infrastructure can be made consisting of:

rauldpm commented 1 year ago

Update report - Option 4 Google Cloud

rauldpm commented 1 year ago

Update report

rauldpm commented 1 year ago

Update report