A chatbox for the Devoxx conference agenda, with API.AI and Cloud Functions

That's Devoxx France this week, and I've had the pleasure of delivering today another talk on the theme of chatbots, using Cloud Functions for the business logic, API.AI for the bot cleverness, with a bonus of a demo through Google Home and the Google Assistant platform.

I'll post the YouTube video recording once it's online, but in the meantime, I wanted to share my slides here:



Testing Java 8 snippets on the new App Engine Java 8 runtime

A new Java 8 runtime for Google App Engine standard is coming soon, and is currently in alpha testing. You can request to join the alpha program, if you want to try it out for yourself. But I wanted to let anyone play with it, easily, to see how well the Java 8 APIs work, but also to try some Java 8 syntax too. So here's a web console where you can do just that!


But to be precise, it's actually my good old Groovy Web Console, where people can write, execute and save Apache Groovy snippets. It is a special version, in fact, as it's built on Java 8, uses the invoke dynamic flavor, and... drum roll... it's using the upcoming "Parrot" parser which adds the Java 8 syntax constructs to the Groovy grammar. So not only can you try Java snippets, but it's a great opportunity to try the future Groovy parser that's gonna be released in Apache Groovy 2.5 or 3.0 (still to be decided).

A meetup about Java 8 on Google App Engine standard

Also, for those who live in Paris and the area, we have the chance of having Ludovic Champenois, an engineer working on App Engine, that will be in France, and will be speaking at this GDG Cloud meetup hosted by Xebia, which takes places on Tuesday, April 4th, just on the even of Devoxx France! 

So if you want to learn more about Java 8 on App Engine, please sign up!

I will also be presenting about Google Home, the Google Assistant, API.AI, and Google Cloud Functions to host the logic of your very own bots and agents. It's based on the presentation I gave at Cloud Next 2017 in San Francisco. If you want to learn more about 

Happy Pi Day! Google Home helps you learn the digits of Pi

You know what? It's Pi Day today! Well, if you follow the American date standard, it's 3.14 today, a nice approximation of Pi. Last year, in a past life, I had played with Pi already, but this year, my awesome colleagues (Ray, Sandeep, Francesc, Ian) have been working on some very cool demos around Pi, with the "Pi delivery", at https://pi.delivery/


You can transform the Pi digits in a nice melody, show a D3.js based visualisation of the transitions between digits, you can stream the Pi digits, and more. And you can learn about how it's been developed on the Google Cloud Platform.

Ray pinged me to see if we could also create an assistant you can invoke on Google Home, to ask for digits of Pi, as I recently played with Google Home, API.AI and Cloud Functions! And I played with the idea: created a new Cloud Function that invokes the Pi's Web API, designed an assistant in API.AI, and submitted this assistant to the Google Assistant.

You'll be able to ask your Google Home:
Ok Google, talk to Pi Digit Agent.
What is the 34th digit of Pi?
And it will tell you that it's 2.

How did I do that, let's first have a look at the Cloud Function, implemented in JavaScript / Node.js:
{
  "name": "pi-assistant",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node index.js",
    "deploy": "rm -rf node_modules; gcloud alpha functions deploy digit --project digit-of-pi-2017-assistant  --trigger-http --stage-bucket gs://digit-of-pi-2017-assistant/"
  },
  "description": "Ask for the n-th digit of Pi!",
  "main": "index.js",
  "repository": "",
  "author": "Guillaume Laforge",
  "dependencies": {
    "actions-on-google": "^1.0.7",
    "node-fetch": "^1.6.3"
  }
}
The key things here are the dependencies: I'm using the actions-on-google Node module to interact more easily with API.AI and the Assistant, and I'm using node-fetch to interact with the Pi Delivery's REST API. 

Let's now have a look at the code of our exported digit function in index.js:
const ApiAiAssistant = require('actions-on-google').ApiAiAssistant;
const fetch = require('node-fetch');

function nthDigit(assistant) {
    let rank = parseInt(assistant.getArgument('rank').replace(/,/g, ''));
    console.log(`${rank}nth digit`);

    // 0 -> 3, 1 -> ., 2 -> 1, 3 -> 4, 4 -> 1, ...
    // let's return 3 for 0th / 1st, and the digit otherwise, 
    // to follow natural human numbering and the fact the dot is accounted

    let start = rank < 2 ? 0 : rank;

    fetch(`https://api.pi.delivery/v1/pi?start=${start}&numberOfDigits=1`)
        .then(response => response.json())
        .then(data => {
            assistant.ask(`Digit ${rank} of Pi is ${data.content}. Do you want to know a different digit of Pi? Or say cancel to exit.`);
        }).catch(err => {
            console.log(err);
            assistant.ask('The ways of Pi are mysterious... Try again, or with another digit? Or say cancel to exit.');
        });
}

exports.digit = function (request, response) {
    let assistant = new ApiAiAssistant({request, response});
    let actionMap = new Map();
    actionMap.set('nth-digit-intent', nthDigit);
    assistant.handleRequest(actionMap);
};
It's pretty straightforward, we export a digit function, that creates an API.AI assistant, to which we feed an action map pointing at our main intent, for asking for digits. I extract the parameter (ie. the rank of the digit I'm interested in), I call the REST API with a fetch() call, and then I return the result with the assistant.ask() call.

In a nutshell, on API.AI's side, my welcome intent greets you, telling you how to use the assistant:
And then the main intent, whose webhook points at my Cloud Function, does the heavy lifting:

You can try it in the emulator:

After that, once the webhook is properly configured, I published my action, through the integrations pane, and the cloud API console. I'll skip the details here, but you can read more on how to distribution your actions.

So again, Happy Pi Day! And hopefully, if you have a Google Home device and when my assistant is officially published, you'll be able to learn more about the digits of Pi!

And let's finish with a video of the assistant running live on my Google Home!


Extending the Google Assistant with Actions on Google

Last week, in San Francisco, took place the Google Cloud Next 2017 conference, and I had the pleasure to co-present a session on "Extending the Google Assistant with Actions on Google", with Brad Abrams, product manager on the assistant technology at Google.

The Google Assistant is the conversational user interface that helps you get things done in your world. Actions on Google let you build on this assistance, while your integrations can help you engage users through Google Home on Pixel, Android and many other devices that connect with Google Assistant. In this session, we'll share the latest innovations behind the Google Assistant and how you can leverage those technologies and best practices for Voice User Interface design to build your own custom extensions to Google Assistant.

In this presentation, for our demonstration, we used API.AI and Google Cloud Functions (announced as beta during the keynote) to implement our assistant, whose job was to help attendees learn more about the conference schedule and see which talks they'd be interested in attending.

You can watch the video of the talk on YouTube already:


And you can have a closer look at the slides below:

Google Cloud Endpoints in General Availability

Today was announced the general availability of Google Cloud Endpoints

Endpoints is the Google Cloud Platform solution for Web API management, which lets you easily protect & secure your API, monitor it, without overhead, and even allows you to implement your API with any language or framework you want.

I've spoken about Endpoints a few times already, at Devoxx Belgium, Nordic APIs summit, and APIDays Paris. And you can see the recording of my Nordic APIs appearance, if you want to learn more about Cloud Endpoints:

 
© 2012 Guillaume Laforge | The views and opinions expressed here are mine and don't reflect the ones from my employer.