Where do I start?
Much has been made of the coming takeover of digital assistants. There’s still a lot of work to be done before they’re truly useful though.
In these early stages of the technology, it can be fun to identify low hanging fruit for digital assistants like Amazon Alexa or Google Assistant. One assistant feature that could be compelling to digital marketers is sending email campaigns so I decided to build a MailChimp app for the Google Assistant.
The first step was to understand the Actions on Google platform and get a sample app running with Google’s intro guide. This exposed me to their system of intent matching with a simple fact retrieval app.
It also gave me a taste for API.AI agents which take raw user input and maps it to specific intents that you’ve configured. For example, after initiating a conversation with the sample Google app, I might say “gimme a fact about cats” and the agent will know to map that to the choose_cats intent based on sample inputs that I’ve set up in the API.AI console.
Next I need to pull MailChimp into the mix with their REST API. After going through their getting started guide, I was running curl commands for every interaction I needed (pulling down the user’s email lists, sending a campaign, etc). To make this accessible to my Node script, I wrote a small class with the MailChimp Node wrapper (thanks @thorning!) to make these queries for me. Here’s a function to send a campaign that’s already been queued up with an email body and a target distribution list:
Once, I had the API calls working, it was just a matter of tweaking the flow of the conversation and configuring the intents in API.AI correctly. It took a ton of iteration to get this working smoothly. For some reason the intent setup process wasn’t intuitive to me at first. It helped to look at the intents for other apps. Here’s a function that responds to the user’s request to create and send a new email campaign:
One of the cool things that Actions on Google allows you to do is build lists of potential answers and prompt the user visually with options through the .buildList()
function.
The final script to manage all this ended up being pretty small. The Actions on Google client library makes the code very efficient.
Me demoing the end result
Please comment below 😄