Using Zapier for notification...

Last Update: 15.06.2018. By Jens in Developers Life | Learning | Newsletter

So, today we are going to use Zapier for sending the email notification. To follow along, you obviously need a Zapier account. The free is enough.

An automation process is called a zap in the world of Zapier. It consists of a trigger and multiple steps of actions. The onboarding for creating a new Zap is great, haven’t seen that in a long time. so I’ll only cover the important steps to follow along.

First, we use a webhook as the trigger and set it to run every time we hit (POST,PUT,GET) the endpoint for our Zap. I’ll also send JSON. For the hook, you can basically skip forward in the wizard to the point, where it gives you the URL for your trigger and waits for the first request.

I coded a small sample sender for it as followed:

public class ZapierTest { 

@Data 
@AllArgsConstructor 
public static class ZapData { 
  private String appName; 
  private String jobTitle; 
}

public static void main(String[] args) { 
    RestTemplate restTemplate = new RestTemplate(); 
    restTemplate.put("<your endpoint>", new ZapData("FRADevJobs", "Magic Undead-Unicron")); 
}

}

You only need to replace with your endpoint. Run the sample app and it will get registered in the wizard. You can save the hook now and move on to the action you want to perform.

I used to send an email. Therefore the wizard lets me fill in all the wonderful fields of an email and offers via the Insert a field button on each input field to access the values from our trigger.

Once you are done, activate the Zap and run the app a few times and should get your emails.

Straightforward and simple, indeed. Loved the onboarding, I couldn’t even do anything wrong :-)

Compared to the email version from yesterday, it is definitely fewer lines of code. Essentially, one line using the RestTemplate. Plus it is pretty flexible with the action to perform. It could email, twitter and SMS me all at once. Haven’t checked it, maybe one can even decide by the time of the day what to use.