Thursday, October 22, 2020

How to Train a Deep Learning TensorFlow Analytic to Play Checkers

Bot Libre now allows you to create generic deep learning analytics and train them through our web API. Deep learning analytics can be used for a wide array of purposes to analyze and make predications on data. This example shows how to train a deep learning analytic to play checkers.

You can use either the Bot Libre deep learning library, or the TensorFlow deep learning library. You can choose the inputs, outputs, and layers.

The web API endpoint to train the network is:
https://www.botlibre.com/rest/api/train-data-analytic

The web API endpoint to test the network is:
https://www.botlibre.com/rest/api/test-data-analytic

Create the Analytic

1. Go to the Deep Learning page and create a new analytic.

2. Configure the network with the following settings:

3. Click on "Save", and then "Reset Network".

Train the Analytic

You can use our Java checkers program to train your Checkers analytic.

You can find it here: https://github.com/BotLibre/BotLibre/blob/master/ai-engine/source/org/botlibre/game/Checkers.java.

1. Clone our BotLibre GitHub repository, and open the Checkers.java file in your preferred Java IDE.

2. Edit apiDetails with your API details:

  • URL to the Bot Libre REST API (this should be https://www.botlibre.com/rest/api
  • Your username
  • Your password
  • Your application ID
  • Your analytic's ID

3. Use the learnGames method to train your analytic. We provide several playing strategies to train with in the Strategy class. Some examples have been provided for you to use.

4. You can use the playGames method to test your analytic against several playing strategies.

Create a Checkers Chatbot

Now that you have an analytic trained to play Checkers, you can create your own Checkers chatbot with your own analytic!

Follow this tutorial to create your Checkers chatbot.

Then, modify line 283 of the Checkers Self script with your application ID and analytic ID to connect it to your analytic.

Here is an example Checkers chatbot for you to try: https://www.botlibre.com/browse?id=18546151.

Tuesday, October 20, 2020

How to Connect a Bot to WhatsApp

Through Bot Libre and Bot Libre for Business, you can now send and receive WhatsApp messages with your own bot. Currently, WhatsApp requires users to have a formally approved account to send messages, but this can be avoided by working in a sandbox on Twilio. 

Step 1 - Create a Bot 

First you must create a bot that you want to connect to WhatsApp via Twilio, or you can use one of your existing bots. To create a bot, follow the instructions here: How to create your own chat bot in 10 clicks

Step 2 - Create a Twilio account

Click here to go the Twilio website. To create a trial account, click on the "Sign up and start building" button in the middle of the website.

Enter your information on the following form, then click the "Start your free trial" button.

You will then need to verify your email address. Check your email and click on the link.

You will also need to verify your cell phone number. Enter your cell number and click "Verify".

Once you have received your verification code, enter it on the website and press "Submit" to complete your account creation.

Answer the questions from Twilio or click "Skip to dashboard".

Step 3 - Get a phone number from Twilio

From the menu on the left side of the Twilio website, select the circle and three dots icon, shown in red below, and then select "Phone Numbers"

 

Click the "Get Started" button to begin. Next, click the "Get your first Twilio phone number".

A screen will pop up with a phone number that has been chosen for you. You can accept this phone number by clicking the "Choose this Number" button. If you want to try again for a different phone number, you can click the underlined "Search for a different number" link. Ensure the number you select has voice capabilities.

Step 4 - Connect webhook

Navigate to your bot's page on the Bot Libre website. Go to its admin console by clicking on the gear icon.

Click the "WhatsApp" link to view your bot's Twilio settings. Copy the "Twilio WhatsApp Webhook URL" to your clipboard.

Now return to the Console on the Twilio website and select "Programmable SMS", then "Settings", and finally "WhatsApp Sandbox Settings". 

Next, paste the Twilio WhatsApp Webhook URL into the "When a message comes in" textbox. Scroll to the bottom and press save.

Step 5 - Connecting to your bot on WhatsApp

To join the sandbox, send your join code, found under "Sandbox Participants", to your Twilio number. This will add you to the sandbox where you can begin messaging your bot!

In summary, your bot should now be able to send and receive WhatsApp messages through the sandbox on Twilio. If you encountered any issues, or would like help setting up your bot please email us at support@botlibre.com or upgrade to our Platinum service and we can build your bot for you.

Friday, August 21, 2020

Running Bot Libre Community Edition using Kubernetes on Amazon AWS

This forum post will go over how to run the Bot Libre Community Edition containers from AWS using kubectl on a Kubernetes setup.

What is Kubernetes?

According to kubernetes.io, "Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available."

For an overview of Kubernetes, visit https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/.

You can also visit their home page at https://kubernetes.io/.

Required Software:

  • Kubernetes
  • kubectl

Ensure that kubectl and Kubernetes are configured properly before proceeding

Firewall:

Before starting up the server, make sure to set up your firewall correctly for Bot Libre.

Bot Libre Community Edition requires the following ports to be open:

22 – SSH
80 – HTTP
443 – HTTPS
25 – SMTP
465 – SMTPS
110 – POP3
995 – POP3S
143 – IMAP
993 – IMAPS
6665 – IRC

The procedure for how to set up the firewall depends on the firewall you are using. For example, an Amazon EC2 instance would use security groups. For a typical Linux server, iptables can be used.

For the bare minimums, only the HTTP port needs to be accessible.

AWS Marketplace Product Subscription

You will gain access to the Bot Libre Community Edition container registry by subscribing on the AWS Marketplace.

  1. Go to https://aws.amazon.com/marketplace.
  2. Search for Bot Libre Community Edition, and filter for container products.
    https://aws.amazon.com/marketplace/pp/B08FXT93P9
  3. Click on "Continue to Subscribe".
  4. Read the Terms and Conditions, and click on "Accept Terms".
  5. After your request has been processed, click on "Continue to Configuration".
  6. Select the latest version, and click on "Continue to Launch".

Deploying the Containers

  1. Log in to the Bot Libre Community Edition container registry using the following command:
    • $ aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 117940112483.dkr.ecr.us-east-1.amazonaws.com
  2. Download our Kubernetes manifest file from our GitHub. This can be done with the following command:
  3. Apply the manifest using kubectl:
    • $ kubectl apply -f kubemanifests.yaml
  4. Wait until the app-web and app-db pods are ready.
    • You can use the following command to watch the status of the pods:
      • $ watch kubectl get pods
  5. (Optional) Set up HTTP port forwarding to the app-web pod with the following command:
    • $ kubectl port-forward --address 0.0.0.0 app-web 80:80
    • This can be repeated for other ports to enable Bot Libre to connect to other services.
  6. Open the home page on a web browser. This will take up to 3 minutes to load. If you are starting the container for the first time, a random admin password will be generated.

Retrieving the Admin Password

  1. Once the page has been loaded on a web browser, use the following command with the container name to retrieve the admin password:
    • $ kubectl logs app-web | grep "ADMIN PASSWORD"
  2. Log in to Bot Libre on your web browser by using the username "admin" and the password you have just retrieved.
    • We recommend that you update your admin password after logging in. This is because if the logs have been erased, then you will no longer be able to access the default admin password.

Running the Bot Libre Community Edition docker containers on Amazon AWS

This forum post will go over how to run the Bot Libre Community Edition containers from AWS using Docker Compose on any machine.

Required Software:

Firewall:

Before starting up the server, make sure to set up your firewall correctly for Bot Libre.

Bot Libre Community Edition requires the following ports to be open:

22 – SSH
80 – HTTP
443 – HTTPS
25 – SMTP
465 – SMTPS
110 – POP3
995 – POP3S
143 – IMAP
993 – IMAPS
6665 – IRC

The procedure for how to set up the firewall depends on the firewall you are using. For example, an Amazon EC2 instance would use security groups. For a typical Linux server, iptables can be used.

AWS Marketplace Product Subscription

You will gain access to the Bot Libre Community Edition container registry by subscribing on the AWS Marketplace.

  1. Go to https://aws.amazon.com/marketplace.
  2. Search for Bot Libre Community Edition, and filter for container products.
    https://aws.amazon.com/marketplace/pp/B08FXT93P9
  3. Click on "Continue to Subscribe".
  4. Read the Terms and Conditions, and click on "Accept Terms".
  5. After your request has been processed, click on "Continue to Configuration".
  6. Select the latest version, and click on "Continue to Launch".

Deploying the Containers

  1. Log in to the Bot Libre Community Edition container registry using the following command:
    • $ aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 117940112483.dkr.ecr.us-east-1.amazonaws.com
  2. Download our docker-compose.yml configuration file from our GitHub. This can be done with the following command:
  3. Build and create the containers with the following command:
    • $ sudo docker-compose up --no-start
  4. To start the containers, run the following command:
    • $ sudo docker-compose start
  5. Open the home page on a web browser (this is the same IP address as the server where the Docker commands are run). This will take up to 3 minutes to load. If you are starting the container for the first time, a random admin password will be generated.
    • If you are unsure about your server's public IP address, you can use the following command:
      • $ curl ifconfig.me

Retrieving the Admin Password

  1. Once the page has been loaded on a web browser, use the following command to retrieve the default admin password:
    • $ sudo docker-compose logs | grep "ADMIN PASSWORD"
  2. Log in to Bot Libre on your web browser by using the username "admin" and the password you have just retrieved.
    • We recommend that you update your admin password after logging in. This is because if the logs have been erased, then you will no longer be able to access the default admin password.

Tuesday, July 28, 2020

Running Bot Libre on Amazon EC2 using the Bot Libre Community Edition AMI

You can host your own server running the Bot Libre platform using Amazon EC2. Bot Libre provides a free AMI (Amazon Machine Image) that makes it easy to install and configure the open source Bot Libre Community Edition platform.

The EC2 instance can be launched from either the AWS Marketplace page or the EC2 page.

Launching from the AWS Marketplace:

  1. Search the AWS Marketplace for the Bot Libre Community Edition AMI, and open the page.
    https://aws.amazon.com/marketplace/pp/B08DG88ZSV?qid=1595956177307
  2. Click on "Continue to Subscribe".
  3. Read the Terms and Conditions, and click on "Continue to Configuration".
  4. Select the latest software version, and any region of your choosing. Then, click on "Continue to Launch".
  5. Under "Choose Action", select "Launch through EC2", and click on "Launch". This will take you to the EC2 configuration page.

Launching from the EC2 home page:

  1. Click on "Launch Instance".
  2. Select the "AWS Marketplace".
  3. Search for the Bot Libre Community Edition AMI.
    https://aws.amazon.com/marketplace/pp/B08DG88ZSV?qid=1595956177307
  4. Select it, and click on "Continue". This will take you to the EC2 configuration page.

EC2 configuration:

  1. Select an instance type of your choosing. We recommend having 8 GB of RAM at minimum (e.g. t3a.large). Click on "Next: Configure Instance Details".
  2. Configure your instance details, and click on "Next: Add Storage".
  3. The amount of storage required depends on the amount of content your users will generate. The size of the storage volume can be modified later, if required. Once you have the storage configured, click on "Review and Launch".
  4. Review the instance details, and click on "Lanch".
  5. Select an existing key pair or create a new key pair. This will be used to connect to the instance via SSH.

Retrieving the admin password:

  1. Go to the EC2 Instances page, and find the Public DNS or Public IP of the Bot Libre instance. Note that the DNS and IP will not persist if the instance is stopped.
  2. Copy the DNS or IP into a web browser to load the Bot Libre home page. It can take up to 3 mins for the page to load when launching for the first time.
  3. Once the webpage has loaded for the first time, connect to the instance with SSH using either the DNS or the IP. To log in, use "centos" as the username and use the key you selected during the EC2 configuration. For more information on connecting to an EC2 instance, see this page: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html.
    • To get the admin password, use the following command:
    • $ sudo cat /usr/local/tomcat8/logs/catalina.out | grep "ADMIN PASSWORD" 
    • This password will only be available the first time the instance is run.
  4. Log in to Bot Libre on your web browser by using the username "admin" and the password you have just retrieved.

For more information on the Bot Libre Community Edition see Bot Libre Community Edition

Tuesday, July 21, 2020

Running the Bot Libre platform on-premise using Docker

The Bot Libre Community Edition web platform is now available as a Docker container. This means that getting Bot Libre up and running on your server has never been easier!

What is Docker?

Docker is a platform that allows you to run “containers” using OS level virtualization. A container is a software package that is bundled with its required libraries and configuration, so you do not have to perform any additional configuration/installation yourself.

Software You Will Need:

Firewall:

Before starting up the server, make sure to set up your firewall correctly for Bot Libre.

Bot Libre Community Edition requires the following ports to be open:

  • 80 – HTTP
  • 443 – HTTPS
  • 25 – SMTP
  • 465 – SMTPS
  • 110 – POP3
  • 995 – POP3S
  • 143 – IMAP
  • 993 – IMAPS
  • 6665 – IRC

The procedure for how to set up the firewall depends on the firewall you are using. For example, an Amazon EC2 instance would use security groups. For a typical Linux server, iptables can be used.

Deploying Bot Libre using Docker Compose:

First, you will need to download the docker-compose.yml file from our GitHub.

This can be done with the following command:

To build and create the containers for Bot Libre, run the following command:

  • $ sudo docker-compose up --no-start

Running Bot Libre using Docker Compose:

To start the containers, run the following command:

  • $ sudo docker-compose start

To gracefully stop the containers, run the following command:

  • $ sudo docker-compose stop

To view the logs, run the following command:

  • $ sudo docker-compose logs

If you need to run bash on the Tomcat web server container (app-web), first get the name of the container with this command:

  • $ sudo docker ps

Then, use the following command with the container name:

  • $ sudo docker exec -it container_name bash