Today, on Valentine’s Day ❤️, I found myself in that all-too-familiar situation—scrambling at the last minute, stressed about creating the perfect plan.
I started thinking about how I could leverage APIs to send thoughtful gifts 🎁, but options are pretty limited. Then it hit me: while I might have failed today, we may have found a solution for future dinner outings.
That’s when Bruno—my trusty API sidekick—came into play. 🐶
I decided to harness the power of the Yelp Fusion API and Nylas to solve my dinner dilemmas. With Bruno handling the heavy lifting, I built an automated workflow that fetches top-rated restaurants, stores their details as environment variables, and then drives a beautifully(?) formatted email with clickable reservation options. And here’s the best part: even on a hectic day like Valentine’s, I can now effortlessly send out an email with my top dinner suggestions.
Here's a public Github repo with the collection and feel free to submit a PR to improve anything.
Before any automation can occur, you need to secure your API keys🔒. Here’s how I got started:
Clone the Github repo for this collection. You can do so using the CLI, or directly through Bruno's import options if you have a commercial license.
The collection contains an Environment Restaurant Res
, but you will need to enter values for the following variables:
Email
: the email address you want the list to be sent toyelpAPIkey
: your Yelp Fusion API keynylasAPIkey
: your Nylas API keygrantid
: Your Nylas Grant value which will be used as a parameterThe Yelp Fusion API allows you to pass a huge selection of Query Params
. Below are the ones that I used:
This example fetches the top 5 restaurants where I live that have reservations next week at 9PM, sorted by distance because I am lazy and don't want to drive 🚗.
Send the request and verify you're getting 5 restaurants:
We will use the restaurants received in the response to pass into our email. In order to do this, we have to write a small script to extract the URL for each restaurant and store them as individual environment variables. Here’s the code I used:
// Parse the JSON response from Yelp
const responseData = bru.response.json();
const businesses = responseData.businesses;
// For the first 5 restaurants, store each URL in a separate environment variable.
for (let i = 0; i < 5; i++) {
const url = (businesses[i] && businesses[i].url) ? businesses[i].url : "";
bru.setEnvVar("restaurantUrl" + (i + 1), url);
}
This script ensures that I have five distinct variables—restaurantUrl1
through restaurantUrl5
—each containing a link to a restaurant option.
Run the request again, and inspect your variables. You should see there was one created for each restaurant:
Next, I wanted to deliver these options in a sleek, clickable format. Leveraging Nylas, I built an HTML email that pulls in the environment variables.
{
"subject": "Options for our date",
"body": "<html><body>Hi Love,<br><br>Here are five options for next Saturday:<br><br><a href=''>Option 1</a><br><a href=''>Option 2</a><br><a href=''>Option 3</a><br><a href=''>Option 4</a><br><a href=''>Option 5</a><br><br>Let me know which one you prefer!<br><br>Yours,<br>Deadpool</body></html>",
"to": [
{
"name": "myfriend",
"email": ""
}
]
}
Each hyperlinked “Option” pulls its URL from the corresponding environment variable. This neat format allows you to easily explore dinner choices with just a click.
Here's what the email itself looks like:
You can run both of these requests using Bruno's Collection Runner - either in the GUI or through the CLI.
This could very easily be automated to run every week, month, or even annually the week before Valentine's Day :).
By combining the Yelp Fusion API with Nylas—and orchestrating it all through Bruno—I transformed what used to be a frantic, last-minute scramble into a smooth, automated process. Every week, without any manual effort, I receive a beautifully formatted email with top dinner picks, letting me finally relax and enjoy the anticipation of a great meal.
If you’re tired of planning under pressure or simply want to explore how API automation can simplify your life, I highly recommend giving this approach a try. With the right tools—and a trusty sidekick like Bruno—you can turn everyday challenges into elegantly solved problems.
Here’s to a day filled with love, stress-free planning, and delicious dinners ahead!