How to build a simple meme bot in 30 minutes using Meteor

Febin John James
HackerNoon.com
5 min readMar 14, 2017

--

We are going to build a simple meme bot. It responds with memes according to the sentiment of the topic. Get the source code here. If you are interested in making cloud apps. Do checkout my book Cloud Is a Piece of Cake . Get the free chapters here.

Install Meteor

If you are using OSX/Linux

If your are using Windows

Download the installer here

Now in your terminal

Now visit http://localhost:3000/

We need six gifs, three for positive and the other for negative sentiment. One of the three gifs is randomly picked and shown.

The six memes must be in gif format with filenames 1.gif,2.gif,….,6.gif and one more with the filename “angry.gif”. We will use the first three for negative and the other three for positive sentiment. (You can use the gifs I used , get them here)

Create a folder named public. Inside that create a folder called gifs. Place the gifs inside it.

For styling let’s add twitter bootstrap. Go to terminal and type the following (Stop meteor using CTRL + C, then execute the following command)

Add this package for sentiment analysis

Let us start meteor by typing

The following code will give us the sentiment of the text written.

This will calculate the sentiment for the words “I am so Happy “. Since it’s a positive sentence we get a score above zero. Otherwise we get a score below zero.

Now here’s the code to select random gifs based on positive and negative sentiment . (Read through the code , don’t use it in your files yet.)

In case users don’t input anything or types less words we will show him the angry gif. Here’s the code for that. (Read through the code , don’t use it in your files yet.)

Now, let’s integrate the above code inside a html file . Replace your main.html with the following lines of code

Now visit http://localhost:3000

Congrats, you have made a meme bot :D

Interested in making cloud apps ? Do checkout my book Cloud Is a Piece of Cake . Get the free chapters here.

If you want help with any topic on programming, please fill up this form. I will get back to you soon.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

--

--