Create a Piston to Speak your Public IP Address to an Echo Device using Echo Speaks


This piston returns the Public IP address that your ISP assigns to your router. This is a little tricky because although you can make a call to the API to find your public address, this does not work exactly right using Webcore. The reason is that it will return the address of the external Webcore server instead.

In order to get “YOUR” public external IP address you will need a simple script to issue the web request to from inside of your private network. In this example, we create this script on a Raspberry Pi.

On your Raspberry P, from a command window:

sudo apt-get update
sudo apt-get install apache2
a2enmod cgi

Add the following to the end of /etc/apach2/apache2.conf

<Directory /var/www/html>
Options +ExecCGI
AddHandler cgi-script .py
Less than-slashDirectory>

Restart Apache:

sudo service apache2 restart

Install pip to handle python package installs:

sudo apt-get install python3-pip

Satisfy the library dependencies your about to use in your script:

pip install requests

Create a script:

sudo nano /var/www/html/

from requests import get
print(“Content-Type: text/html;charset=utf-8”)
ip = get(‘’).text

Make the script executable:

chmod 755 /var/www/html/

To test the script point your Web Browser to http:///

You should get back a single line that is your IP address.

To use this in a Webcore piston, you need to make a Webcore call to the local IP address of your Pi. In my example Piston, my Pi is at You probably should statically address your Pi on your LAN.

Also notice that I am stripping off the final character at the end of the IP address in the piston. Ipify returns some non-printable character that ends up killing the “Speak Text” command in Echo Speaks.

I also create a Global variable named @PublicIP so that I can use the IP address in other pistons in my Webcore instance. So either create that Global variable or create a local one depending on your preferences.

You will also note that I use a virtual switch named ReportIP. I create an Alexa Routine that listens for “What is my Address” and then the routine turns the switch ReportIP ON. This piston makes the web call to the Raspberry Pi on the local network, which then makes a call to Ipify to get the public address. The piston then turns the virtual switch off and reports the current public IP address using Echo Speaks on which ever Echo device you select. My echo device is set to a global variable called @Echo_Location which several of my pistons use.
Here is the anonymized version if you want to import:


Keep in mind that the technique used in this code that was critical was in having the local network based Raspberry Pi from which to make the call to Ipify. Having a Global Variable in Webcore for my Public IP address lets me track when that address changes and also when my DDNS has updated my “A” record for my subdomain. This can leverage other code on down the road.


Good to see I’m not the only one ripping off @allrak’s technical expertise and insinuating it’s my own! :+1::joy::joy:


Yes, it is scary amazing that there is no intuitively simple way to do this. Generally I create LXC containers on my local network to do this stuff.