How to create automations

You can create automations by using API or webhooks with MailerSend and a lot of other web applications. In other words, a trigger from one app, like MailerSend, can trigger an action for another app, such as WooCommerce, through the use of Zapier.

In this article you will learn:

  • How to integrate Zapier

    • What Zapier is 

    • How to connect Zapier with MailerSend

    • How to set up triggers and actions

  • How to add Webhooks

    • What webhooks are

    • How to set up webhooks in MailerSend

    • Types of webhook events

    • When to use webhooks

How to integrate Zapier

What Zapier is

Zapier is a web-based application that lets you connect apps with thousands of other web services, such as WooCommerce, Help Scout, and HubSpot. You don’t have to be an expert or know any coding to start building automated connections between applications called Zaps. 

All Zaps have a trigger, which is an event that occurs in another application that initiates the Zap. This Trigger sets off an action, which is the event that completes the Zap in the other application. 

If you need inspiration, see everything that’s possible with MailerSend and Zapier.

If you have any questions about Zapier, you can reach out to contact@zapier.com.

How to connect Zapier with MailerSend 

  1. Log in to your Zapier account or create a new account.

  2. Your Dashboard will be shown on the screen.

  3. To create your own workflow, select MailerSend and the other application you wish to connect. It is up to you whether MailerSend is the trigger or action of the Zap, depending on your needs.

  4. Sign in to your MailerSend account by entering your API key, which can be found in the Domains page of the domain you wish to integrate. See Managing API tokens if you haven’t yet created one.

  5. Paste the API key on your Zapier account and sign in.

  6. Follow the steps on-screen to finish setting the Zap. Zapier will test the trigger to see if it works correctly.

Now you’ll see your MailerSend account connected to Zapier. This allows you to easily send customer activity from your apps to your MailerSend account or vice versa.

Actions and triggers 

A Zap is an automated task that consists of a trigger and an action. When a specific trigger occurs, a specific action takes place. These triggers are connected to your customers. 

As soon as you create your Zap, Zapier automatically checks if there have been any new triggers every few minutes. If Zapier detects a trigger, it automatically performs its respective action.

With MailerSend, you can find 7 triggers:

  • Email is sent: your email has been sent to your recipient

  • Email is delivered: your email has been delivered to your recipient’s inbox

  • Email is opened: your email has been opened by your recipient

  • Email is clicked: your recipient has clicked on a link in your email

  • Email is soft bounced: your email was not delivered because it soft bounced. A soft bounce is a temporary rejection by a receiving recipient’s server. This may happen because the recipient's inbox is full.

  • Email is hard bounced: Your message was not delivered. The message was returned to our servers because the recipient's address is invalid. A hard bounce may occur because the domain name does not exist or because the recipient is unknown. 

  • Recipient has unsubscribed: your recipient has clicked on the “Unsubscribe” link of your email and won’t receive any more emails from your domain.

You can also find 2 actions:

  • Send an email: send a custom email that’s written in HTML or text, with attachments and variables

  • Send an email based on a template: send an email that’s based on a MailerSend template, in HTML or text, by simply adding the template’s ID number, along with attachments and variables.

How to add webhooks

What webhooks are

Contrary to API, webhooks allow you to subscribe to real-time notifications about various events that occur in MailerSend. 

Listen for events on your MailerSend account so your integration can automatically trigger reactions. You can create a webhook directly from your account.

For example, an HTTP POST callback is sent to your provided URL with a payload about the sent email. It allows you to get the most recent updates without constantly pulling the API.

How to set up a webhook in MailerSend

  1. Head to Domains and select the domain you wish to use.

  2. Under the Webhooks section, click Add new webhook.

  3. Give it a name, type the endpoint URL, and select the events to send (you can select more than 1 or all).

  4. Click Save webhook.

That’s it! Once your webhook has been successfully saved, it will send every event that you selected to the endpoint URL. 

Types of webhook events

In MailerSend, you can include more than 1 event in a single webhook. The events you can use are:

  • activity.sent

  • activity.delivered

  • activity.soft_bounced

  • activity.hard_bounced

  • activity.opened

  • activity.clicked

  • activity.unsubscribed

  • activity.spam_complaint

When to use webhooks

You can use webhooks to trigger actions or send notifications when a specific event occurs. 

Some scenarios where you might use webhooks include:

  1. You want to be notified every time an email fails to be sent because it soft or hard bounced.
    - Webhook event: activity.soft_bounced and activity.hard_bounced
    - Action: Publish on your Slack bot endpoint URL so you receive a message each time this action occurs.

  2. You want all of your customers’ MailerSend email activity transferred to their contact record in your Hubspot or Salesforce. 
    - Webhook events: all events
    - Action: A webhook containing any event is sent to your CRM app, the data is converted and logged on the recipient’s record in Hubspot or Salesforce.

  3. If you want to keep history longer than 7 days, you want to document all your email activity logs in a Google sheet for archival purposes.
    - Webhook events: activity.received
    - Action: A webhook containing the activity events you’d like to log is sent to a Google sheet script, the data is converted and logged into a Google sheet record for future reference.

As you can see, there are several scenarios where you could use webhooks. With apps like Zapier, you can connect the MailerSend webhooks with other web applications available. 

Need more info?

Feel free to talk with us via live chat or contact us at support@mailersend.com.