Generating memes in Slack with AWS Lambda

Posted in AWS Blog
23/02/2016 Ben Bridts

At Cloudar we use Slack for a lot of our internal communication. One of the things we love is how easy it is to extend the functionality of this messaging tool. One integration that we sometimes missed was a meme generator, because there a moments when a picture meme is worth a thousand words.

If you search for a meme generator for slack you’ll find this great ‘slash command’ by Nicole White. The only thing we liked to change was the environment that it runs in. Running the Flask application that Nicole wrote in an Elastic Beanstalk environment is fairly trivial, but porting the code to run in a Lambda function is a lot cooler. On top of this you’ll get all the benefits of Lambda, making the solution cheap and easy to scale.

If you want to jump right in, you can grab the code from GitHub and run it in your own AWS account. In the remaining part of this blogpost I’ll describe the changes we made to make it run in AWS Lambda.

What we did

  • We kept the complete, which is the real logic of the function. It is responsable for using memegen and memeifier to generate the memes. Having support for mulitple languages in AWS Lambda saves us a lot of work here.
  • We wrote a as a replacement for It contains the lambda_handler function that parses the data send by Slack, uses the models to get an image url and returns a json response. To create this file we merged an AWS Lambda Blueprint with the code that Nicole wrote, another place where the current ecosystem allows for fast integration.
  • Nicole used a webhook to post the memes, we decided to just return json directly. This looks a little bit different in Slack, but is more in line with how other slash commands work.
  • We also changed the way previews work, by returning the image directly in Slack instead of a url.

How this looks

Using a build in meme: /meme success; we have; a meme bot;

Screenshot 2016-02-23 11.55.51

Using a meme with a custom image: /meme; Hello; It’s me

Screenshot 2016-02-23 13.33.24

Previewing a meme: /meme preview awesome-awkward; makes a meme; doesn’t show anyone;

Screenshot 2016-02-23 13.39.05

Showing this to your coworkers:
Screenshot 2016-02-23 13.41.40

How to set this up

You can find complete instructions in the README. But the big steps are:

1. Set up a new slash command in Slack
2. Encrypt the Slack token with KMS
3. Update to use this token.
4. Package the code and upload it to AWS Lambda
5. Configure API gateway. to transform the form encoded data to json

Make it your own

All the source code is available on Github and we love to see how you integrate this in your own Slack team. Leave a comment here or send us a pull request on github if you find even more ways to build on the code that Nicole put online.


Leave a Reply

Your email address will not be published. Required fields are marked *


Need a hand? Or a high five?
Feel free to visit our offices and come say hi
… or just drop us a message

We are ready when you are

Cloudar NV – Operations

Veldkant 7
2550 Kontich (Antwerp)

info @

+32 3 450 67 18

Cloudar NV – HQ

Veldkant 33A
2550 Kontich (Antwerp)

VAT BE0564 763 890

    This contact form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    • SHARE