Skip to content
Guides
Creating your first automation

Creating your first automation

Setting up your first email automation with Plunk is as easy as counting to three. Let's do it together!

In this example we will create an automation that sends a welcome email to our new users.

Trigger an event

Before we can set up our automation, we need an event that triggers it. In our case, we want to send a welcome email to our new users. So we need to trigger an event when a new user is created. We suggest that you trigger this event when a new user is written to your database by your backend.

👋🏼

There are multiple ways to trigger events in Plunk. You can also use one of our integrations or trigger it straight in the dashboard. The latter is useful when you want to set up your automation before you have your backend ready.

await fetch('https://api.useplunk.com/v1', {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer API_KEY", // Put your API key here
    },
    body: JSON.stringify({
        "event": "user-signup",
        "email": "hello@useplunk.com",
    }),
});

Creating a template

Now that we have an event that triggers on every signup, we need to create the template for our welcome email. You do this in the Templates section of your Plunk dashboard.. Plunk templates are written in markdown for easy editing. We automatically convert that markdown to the complicated HTML and CSS that is required to send a beautiful email.

Plunk's Template Editor

In our example, we will create a marketing template but you can also create transactional templates. Transactional templates are used to send emails like password resets, order confirmations, etc. Marketing templates are used to send onboarding emails and promotions.

👋🏼

You can also use a contact's data in your template. Read more about that in the guides.

Creating the automation

Now that our event and template are ready, we can link them together in an action. You can do this in the Actions section of your Plunk dashboard. Next to our event and template, there are some other options we can configure for this action. We can configure a delay before the email is sent and also toggle whether this action should repeat if that same contact triggers the event again.

Since we want to send a welcome email to our new users, we can leave the delay at 0 seconds. We don't want to send the same email to the same user twice, so we can toggle the Run once option.

Last updated on January 18, 2023