Pages

Thursday, December 17, 2020

How to Create a Music Streaming Service Chatbot

To begin creating your own bot for your Music Streaming Service you must first create an account at botlibre.com or botlibre.biz

Once your account has been created, click on "Bots." Here you will be presented with several options, and you will then click on "New Bot" and will be presented with the following page:

In the form, enter a "bot name" and set template to "music_stream_template" If you have a website you may enter your website URL into the "Website" field. You may leave the other fields empty and click the "Create" button at the bottom.

Your bot is now created. To give your bot set responses first click "My Bots" from the "Bots" page, and then click on your bot. Next click on "Admin Console" (the gear icon).

By clicking on "Embed" you can generate a script which can be embedded on a site like Blogger in an HTML/JavaScript gadget.

Once in "Admin Console" click on "Training and Chat Logs"

In Training and Chat Logs you can now:

       a) Add, review responses

       b) Add, review greetings

       c) Add, review default responses & more

Here is the music streaming bot's response list.

Here is an example response that uses a command to play music:

Today's Hits
playing today's hits...
command: { type: "music", cmd: "play", genre: "today's hits", url: "https://rfcmedia.streamguys1.com/MusicPulse.mp3" }
poses: dancing

The response list uses commands in the response to change radio stations. A command is a JSON string that can be attached to a response and passed to the bot client. We use some JavaScript code in the bot's embed code to play the music stream in the browser.

Here is the code that uses a Game object in the Bot Libre JavaScript SDK to receive command events from the bot:

var audio = new Audio();
function PlayMusic() {
    this.updateAvatar = function(response) {
        if (response.command != null) {
    		var command = JSON.parse(response.command);
    		console.log(command);
            if (command.cmd == "play") {
                audio.pause();
                audio.src = command.url;
                audio.play();
            } else if (command.cmd == "pause") {
                audio.pause();
            }
        }
    }
}
web.game = new PlayMusic();

Here is the music streaming JavaScript example code.

To test it out try our demo bot: Music Streaming Bot

To chat with the bot click on its subdomain link. This normal chat button does not allow adding custom JavaScript to the page, but the subdomain does.

To see this bot on a website template, check out this link: Music Streaming Service

If you have any issues with setting up your bot you may contact us at our email at support@botlibre.com or upgrade to our Platinum Service and we can create your bot for you.

Tuesday, December 15, 2020

How to Create a Chat Bot for a Pet Store

To begin creating your own bot for your Pet Store you must first create an account at botlibre.com or botlibre.biz

Once your account has been created, click on "Bots." Here you will be presented with several options, and you will then click on "New Bot" and will be presented with the following page:

 

In the form, enter a "bot name" and set template to "pet_store_template" If you have a website you may enter your website URL into the "Website" field. You may leave the other fields empty and click the "Create" button at the bottom.

Your bot is now created. To give your bot set responses first click "My Bots" from the "Bots" page, and then click on your bot. Next click on "Admin Console" (the gear icon).

 

By clicking on "Embed" you can generate a script which can be embedded on a site like Blogger in an HTML/JavaScript gadget.

 

Once in "Admin Console" click on "Training and Chat Logs"

 

In Training and Chat Logs you can now:

       a) Add, review responses

       b) Add, review greetings

       c) Add, review default responses & more

 

 

To test it out try our demo bot: Pet Store Bot

To see this bot on a website template, check out this link: Lucky's Pet Store

If you have any issues with setting up your bot you may contact us at our email at support@botlibre.com or upgrade to our Platinum Service and we can create your bot for you.

Friday, November 20, 2020

Detecting a person's gender in an image using deep learning and the Bot Libre analytics API

Bot Libre Analytic lets you easily train your own deep learning neural network without any programming. With Bot Libre you can create your own deep learning neural network for image recognition, audio and speech recognition, object detection, games, prediction, data analysis, and more. To create your own analytic see How to create your own deep learning neural network for image recognition

Bot Libre also has many pretrained analytics trained by us and our users that you can use through the Bot Libre web API from your own web or mobile application. To browse Bot Libre's analytics go here.

Here is the Gender Detector.


You can access it from the Bot Libre website, or you can access it analytic through the Bot Libre web API, or using the Bot Libre JavaScript SDK.

Here is an HTML example of using the Bot Libre JavaScript SDK:

<form method="post" name="fileinfo" enctype="multipart/form-data">
<span>Upload File. </span>
<input type="file" name="file" onchange="uploadImage(this);" accept="image/*">
</form>
<hr>
<div>
<div id="test-analytic-image">
</div>
<div id="test-object-image">
</div>
</div>

<script type="text/javascript" src="https://www.botlibre.com/scripts/sdk.js"></script>
<script>
SDK.applicationId = "12345"; // Enter your user's application id from your user page.
var sdk = new SDKConnection();
var analytic = new AnalyticConfig();
analytic.id = "35935506";

function uploadImage(input) {
var divTestAnalytic = document.getElementById("test-analytic-image");
var divTestObject = document.getElementById("test-object-image");
divTestAnalytic.innerHTML = "";
divTestObject.innerHTML = "";
var files= input.files;
var form = document.getElementById('upload-test-image');
var newDiv = document.createElement("div");
newDiv.style.padding = "5px 10px 5px 5px";
var newImage = document.createElement("img");
newImage.src = URL.createObjectURL(files[0]);
var name = files[0].name;
var type = files[0].type;
newImage.setAttribute("width", "30%");
newImage.setAttribute("height", "30%");
newDiv.appendChild(newImage);
var result = document.createElement("ul");
result.id = "list-ul";
result.style.display = "inline-block";
result.style.verticalAlign = "top";
sdk.sendAnalyticImage(analytic, function(response) {
result.innerHTML =
"<li><b>File Name: </b>" + name + "</li>"+
"<li><b>Image Type: </b>" + type + "</li><hr>";
for (var i = 0; i < response.labels.length; i++) {
if (i > 0) {
result.innerHTML = result.innerHTML +
"<li style='font-size: 14px;'><b>Label: </b>" + response.labels[i] + "</li>"+
"<li style='font-size: 14px;'><b>Confidence : </b>" + response.confidences[i] + "%"+ "</li>";
} else {
result.innerHTML = result.innerHTML +
"<li style='font-size: 16px;'><b>Label: </b>" + response.labels[i] + "</li>"+
"<li style='font-size: 16px;'><b>Confidence : </b>" + response.confidences[i] + "%"+ "</li><hr>";
}
}
newDiv.appendChild(result);
divTestAnalytic.appendChild(newDiv);
divTestAnalytic.appendChild(document.createElement("hr"));
}, files[0], form, 600);
}
</script>

 

To use the web API call the end point using a POST HTTP request,

https://www.botlibre.com/rest/api/test-analytic

Pass an XML entity for the analytic,

<analytic application='12345' id='35935506'/>

and a multipart form data for the image.

See https://www.botlibre.com/api.jsp

 

If you would like help using this analytic, or developing your own deep learning solution for your own application contact sales@botlibre.biz

 

Friday, November 6, 2020

How to create an Auto Repair chatbot

An interesting use of chatbots is to help provide quotations for car repairs and services!

1. Creating an Auto Repair Chatbot

Follow this simple tutorial to learn how to create a chatbot.

To set up an Auto Repair chatbot, select auto_repair_template as your bot template.

2. Editing the Chatbot's Responses

To view and edit the chatbot's responses, go to the Training & Chat Logs page.

Then, go to the "Review all responses" page.

Here you will be able to view and edit the bot's responses!

3. Setting up emails

The chatbot can send emails containing the user's info to make it easy for mechanics to provide a quotation for a car service/repair.

First, follow this easy tutorial to connect this chatbot with your email address.

Then, enter your email address into the "Think" command of the final response, as shown:

Now, you will receive an email when a user wants a quotation!

Example:

Here is an example of an Auto Repair chatbot on a website

Thursday, October 29, 2020

How to create your own Stock Bot for stock quotes and market information

The Stock Bot template offers financially useful functionality. Using the StockQuote script and your own API key you can have access to stock quotes. This bot is setup with IEX cloud API docs which offers many plans for API keys, even a free version. You must set your API key in the StockQuote script. If you wish for the bot to be able to access more information that is important to you, depending on your IEX cloud plan there exists a lot more information that can be accessed and easily reconfigured in the StockQuote script. You can see the bot in action here.

Consider using the bots Define functionality as well by adding your own definitions to the Define script or even integrating a dictionary API for quick financial definitions. 

If you implement this template in your own bot then navigate to the Bots menu and select New Bot

Fill out the information about your new bot as you wish but ensure to select stock_bot_template from the Template dropdown menu.


Once your bot is created you will then need to update the StockQuote with your personal IEX cloud API key which you can get from their website. To access this script after you bot has been created, select the Admin button. 

Then you want to select the Scripts link to bring you to the active scripts the bot is using. 


Make sure to select the StockQuote scripts and then you can edit it by selecting the Edit button highlighted in the top left.


Finally, navigate to the stockPrice() function and be sure to set the api_key variable to your own key.


Ensure to save the script and then you will be able to start using the bot stock quote functional

Here is the StockQuote script

Chat with the Stock Bot

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

Friday, June 26, 2020

How to create your own special event bot

Chatbots are an exceptional way to grab users attention for your next special event. They can register and inform people through the web, via email, or even with social media.

To create your own special event bot, first head to Bot Libre or Bot Libre for Business.

Here you'll want to sign up for a new account, and then click on the "Bots" icon at the top of the screen.

Select "New Bot", give your bot a name, and then set the template to special_event_bot. 

Click create and we're almost done!

At this point you've created a bot, but they still have generic special event responses. Let's change that.

 

Select the Admin box and navigate to the Training & Chat Logs page.

Here you can handle greetings, responses, all the way up to more the advanced topics like conversation flows or Facebook accounts all with a few clicks!

To get you started have a chat with our demo special event bot

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, March 13, 2020

Searching Twitter tweets by location

Bot Libre allows to you connect your bot with a Twitter account. This allows you to automate interactions with your community, or automate the posting of information. For a tutorial on creating a Twitter bot see:

https://www.botlibre.com/forum-post?id=5015

Always ensure you comply with Twitter's terms of service and automation rules,

https://help.twitter.com/en/rules-and-policies/twitter-automation

Bot Libre's Twitter integration includes support for auto replies to mentions or direct messages to your bot, auto retweeting, Tweet search, auto replies, and auto posts.  The Tweet search feature allows your bot to search for tweets on Twitter to process with its rules.

In your bot's Admin Console on its Twitter page you can configure your Twitter bot's rules. One option is the "Tweet Search", this allows you to enter multiple Twitter search queries (each on a new line).  A Twitter search can contain a list of keywords, but can also include many other commands, for a full list see,

https://twitter.com/search-advanced

One option is geo location. This lets you search tweets by location.

For example to queries all tweets on the #chatbots hashtag in the USA you can use:

#chatbots geocode:39.8,-95.583068847656,2500km

To use geocode you need to know the coordinate of the city or location you are interested in. Here is a good website to get the coordinates for a place:

https://www.latlong.net/

For more geo location examples see:

http://thoughtfaucet.com/search-twitter-by-location/examples/