This is a demo application that allows the user to search for GIFs, built with Node.js, that uses both Giphy and the SendGrid API. You can use the website to search for GIFs, or you can email firstname.lastname@example.org with a query in the subject, to get an email response back with the GIF and also have that appear in the application using the SendGrid Inbound Parse API.
Head over to https://rocky-reaches-6505.herokuapp.com/ to see the app running. You can search inside the app for a GIF, or by sending an email to email@example.com . Anyone with the web page open will see the GIF that was requested.
Create a free SendGrid account.
Clone the repository by running:
git clone https://github.com/heitortsergent/gimmegif.git
Create your local copy of the .env.example file by running:
cp .env.example .env
We're using the dotenv library to handle env variables. Edit the contents of
.env, changing the variables
SENDGRID_PASSWORD to your SendGrid credentials. The
GIPHY_API_KEY is a public key they have available over at their repository. They have instructions for getting a private key for production in there.
SENDGRID_USER=your_sendgrid_username SENDGRID_PASSWORD=your_sendgrid_password GIPHY_API_KEY="dc6zaTOxFJmzC"
After making the changes, to test the app just run:
npm install node server.js
Testing locally with azk
If you have azk installed, just run:
$ azk start
And that will also setup ngrok for you. ;)
SendGrid Inbound Parse Webhook
- Point your domain's MX record to
- Add an entry for the domain in your parse API settings
You'll have to change the
applicationReplyUrl variable inside
server.js for the user to receive back the email with the GIF.
var applicationReplyUrl = "http://yourappurl.jit.su/reply";
You can easily test the inbound webhook using ngrok by running:
Open a new terminal window and run:
ngrok should give you a url similar to this:
That's the URL you should set up inside your SendGrid parse API settings.
You can easily deploy the app by using Nodejitsu.
First of all, open
package.json and change the
subdomains to the URL you want to use.
"subdomain": "yoururl", "domains": [ "yoururl.com", "www.yoururl.com" ],
After that, create a Nodejitsu account, install the jitsu CLI and log in. For the SendGrid email to be sent back, after the user requests it through the Inbound Parse Webhook, you need to set the env variables inside nodejitsu:
jitsu env set SENDGRID_USER your_sendgrid_username jitsu env set SENDGRID_USER your_sendgrid_password jitsu env set GIPHY_API_KEY your_giphy_api_key
And finally run: