Over a million developers have joined DZone.

Cozmo, IFTTT, and Jenkins Build Notifications

DZone's Guide to

Cozmo, IFTTT, and Jenkins Build Notifications

One of the most useful features of the Anki Cozmo is its SDK, letting you use the robot in your programs. See how to create a visual trigger to a Jenkins build's results.

· IoT Zone ·
Free Resource

Download The Comparative Guide to Rules Engines for IoT to learn what are the most common automation technologies used in the IoT domain for application development


Anki Cozmo is a little tiny robot, a great companion on your desk. Cozmo comes with a great personality. He is full of fun, he plays games with you, he can do tricks, move around, and generally creates a lot of joy. Cozmo comes with a camera that can detect faces and greet people and pets. It also has an SDK that allows you to customize Cozmo and create cool apps and IoT connected programs.

In this post, I'll show how to use Cozmo with my Jenkins IFTTT Build Notification plugin to send build notifications to Cozmo. He will animate to these notifications and do some tricks — like lighting up his cubes. This will make Cozmo an eXtreme Feedback Device.

The Cozmo SDK comes with a bundle of examples and apps that you can play with and modify. There are a bunch of examples that connect Cozmo to IFTTT and use different channels like Gmail or sports news. I took the Gmail example and modified it to get Jenkins notifications. Here's how this works on a high level:


Step 1: Connecting to Cozmo From IFTTT

In order to connect to Cozmo from IFTTT, we need a computer running Cozmo exposed to the Internet. You can do this either by using a static IP or using a tool like ngrok, which sets up a secure tunnel to localhost running on your computer. To set up ngrok, follow the instructions here.

Run this command to create a secure public URL for port 8080:

./ngrok http 8080

Note the HTTP forwarding address shown in the terminal (e.g., http://4916890d.ngrok.io). This is required while creating the IFTTT applet.


WARNING: Using ngrok exposes your local web server to the Internet. See the ngrok  documentation for more information: https://ngrok.com/docs

Step 2: IFTTT Jenkins Cozmo Script

The Cozmo SDK is presently available in Python. The IFTTT examples use the aiohttp module to create a web server with an endpoint with a handler to call the Cozmo SDK:


The complete source code is available here.

Step 3: Creating the IFTTT Recipe

IFTTT is a web service that lets you create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Instagram, or Twitter. An applet may send an email message if the user tweets using a hashtag or copy a photo on Facebook to a user's archive if someone tags a user in it, or it can trigger an IoT device to a specific action.

In this example, we will create custom IFTTT Trigger and Action using the Maker Webhooks feature.

  1. Sign up and sign into https://ifttt.com
    1. Create an applet: https://ifttt.com/create
    2. Set up your trigger.
      1. Click "this".
      2. Select "Maker Webhooks" as your service.
      3. Under "Choose a Trigger", select “Receive a Web request".
      4. In "Receive a Web Request", enter "JenkinsBuild" as "Event Name"
      5. Click "Create Trigger" button
    3. Set up your action.
      1. Click “that".
      2. Select “Maker Webhooks" to set it as your action channel. Connect to the Maker channel if prompted.
      3. Click “Make a web request" and fill out the fields as follows. Remember your publicly accessible URL from above (e.g., http://55e57164.ngrok.io) and use it in the URL field, followed by "/iftttJenkins" as shown below:
URL: http: // 55e57164.ngrok.io / iftttJenkins
Method: POST
Content Type: application / json
Body: {"project": "{{Value1}}", "build": "{{Value2}}", "status": "{{Value3}}"

Click “Create Action" then “Finish".

Here is video loop for above settings:


Step 4: Configuring the Jenkins Build Job

To set up the job, you'll need the IFTTT Build Notification Plugin.

In the Jenkins job "Post-build Action" section, add a new "IFTTT Build Notifier" action with the following values:

  1. Event Name: JenkinsBuild
  2. Key: <Make Webhooks Key>

Note: You can get your unique Maker Webhooks Key from here.

Finally, run the Jenkins job to test the setup. In response to the IFTTT web request, Cozmo should roll off the charger, raise and lower his lift, announce its status, and then animate and light up the cubes.

Here is video loop for above settings:


Running It Together

Here's a video with Cozmo's reaction to a passed build vs. a failed build:

You can also connect CI tools like Travis or Circle CI using the curl command to the Maker endpoint. We can add more actions to this web server and make Cozmo even more thrilling.

See how CEP engines, stream processing engines, flow based programming engines and other popular rule-based technologies perform against seven IoT-specific criteria.

jenkins ci ,iot ,cozmo ,iot app development ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}