I wanted to take the opportunity to both learn about Alexa Conversations as well as teach others along the way. To do this best, I ran through ideas that would use as many of Alexa Conversations' features without depending on as many other features available to skill builders while still building something both functional and fun to use!

I did this by building the entire skill, from idea to publishing, all live on my twitch stream! We usually build all sorts of skills and conversational applications on stream, so trying to use only Alexa Conversations as far as we could meant that we could teach the components of it without needing any other Alexa skill building concepts as background!

Mad Libs felt like the perfect fit - a game most people know, naturally conversational, and a great test of the automation provided by Alexa Conversations.

What it does

Tweet libs has a fun, functional, yet simple set of features:

  • Start the skill
  • Ask for a mad lib by category
  • Talk to Alexa to give her the answers she requires to fill in the values
  • Have the final mad lib read out to you
  • Have your mad lib tweeted out by @alexatweetlibs for all to see!

It has dozens of output options depending on which category you go with, and a future of many many more!

Here are a couple examples!

Simple one-slot food:

food sample

Travel two-slot:

travel sample

Tweeting it out: tweeting

How I built it

I went through a few phases of building it in order to properly learn how to use Alexa Conversations. Originally, I tried building it in a way that is more similar to traditional Mad Libs where the device would prompt for parts of speech like "noun", "verb", "adjective", etc. But without the ability to use the AMAZON.SearchQuery slot type, it seemed unlikely that I'd be able to train custom SlotTypes for every possible form of a noun or verb.

Because of this, we pivoted to more subject based mad libs to help guide into different Dialog paths that made use of either pre-trained list SlotTypes, or custom trained SlotTypes.

So to make a category of Mad Lib, all I have to do is:

  • Choose the slot type(s) I want to use as variables in the output
  • Build a dialog around starting the mad lib conversation for that category and prompting for the required variables/slots
  • Build the utterances/responses for each inform request / prompt of each slot
  • Build a list of template strings in code for the category that use the slots
  • Build a generic handler that uses the template list and the input types

This means that adding new output mad lib templates to existing categories just requires adding a new string template to an array and adding an entirely new category of mad lib requires only creating template strings and training a dialog.

For example, adding a mad lib category of "hall pass mad libs" looks like this in the code:

build templates

const hallpassTemplates = ['{name} is authorized to be at {location} instead of {noun} class',
'{name} is simply too cool for {noun} class. They will be at {location} instead.',
'I heard {name} was playing hookie from {noun} class and was found sleeping at {location}!']

create abstracted handler:

const HallPassMadLibHandler = {
    canHandle(handlerInput) {
        return util.isApiRequest(handlerInput, 'HallPassMadLib');
    handle(handlerInput) {
       return handleMadlibRequest(handlerInput, "HallPassMadLib", hallpassTemplates);

And that's all there is to it!

The rest is handled by the handleMadlibRequest function that extracts the params out of the payload and replaces them in the template:

const handleMadlibRequest = (handlerInput, name, templatesArray) => {
    const args = util.getApiArguments(handlerInput);      
    const completeLib = getAndBuildMadlib(templatesArray, args)
    let response = {
        apiResponse: {
            response : completeLib
        shouldEndSession: true
    return response;

const getAndBuildMadlib = (templatesArray, args) => {
    // get random template from the provided array
    var output = templatesArray[Math.floor(Math.random() * templatesArray.length)];
    // iterate over each property in args and replace that property from the templates
    const keys = Object.getOwnPropertyNames(args); // ex: ['noun', 'location', 'name']
    keys.forEach(key => {
        output = output.replace(`{${key}}`, args[key])

    // return the full completed output
    return output;

Pair that together with a dialog, and you're done! sample dialog

Challenges I ran into

The biggest challenges came with the time it took to build the model. In order to build the entire model, I saw times of 5-20 minutes, and during those build times I wasn't able to make any other changes like build new dialogs, utterance patterns, etc. This meant that to start testing, I'd need to queue a build and wait for everything to finish, validate my changes, then continue to add more.

Accomplishments that I'm proud of

The biggest accomplishment for me was being able to teach and inspire others to build conversational experiences on Alexa and come up with their own ideas to build while exploring my own! I was able to quickly understand the different take/mindset on AC building versus traditional skill building and had the opportunity to share that, break it down, and teach others how to get started themselves!

What I learned

I learned an insane amount about Alexa Conversations and the new ways to build and manage multi-turn conversations without having to manage it all myself using my own tools and way more code. The ability to design and configure natural conversations using only labeling and minimal code left me with an entirely different mindset to my traditional app dev take on building skills.

I also learned a bit more about Alexa hosted code. I've released dozens of skills using managed/hosted lambdas, HTTP servers on AWS, Azure, and GCP, as well as cloud functions with HTTP Gateways. Learning how easy it is to build skills that require minimal code using all the resources available in the Alexa Developer Console was awesome!

What's next for Tweet Libs

First off - more mad libs! Now that we can SUPER easily add more mad lib templates to existing categories, I'll be adding more and more! I'm planning on sourcing them from my discord, twitch chat, my own brain, and also the @alexatweetlibs twitter too! I also plan on adding more categories and accompanied templates to add a more expansive set of features and fun. I may also add more social channels to share the mad libs other than twitter, but that is up in the air at the moment.

I can't wait to see all your funny mad libs on twitter in the future!

Built With

Share this project: