Connect this API with your frontend to capture leads, add them to your database and contact them.

Database Query

In a first step we want to check if the email we receive through the request, already exists in our database to avoid duplicates. We use the following SQL statement through the DB Query action:

SELECT COUNT(*) AS email_count
FROM leads
WHERE email = '{{}}';

We get the outcome of this query through: {{steps.check-if-user-exists.outputs}}.

IF Condition

We use an If Condition to check if the result of that query equals zero, which would mean that the email address does not exist in the database. We are using:

  • {{steps.check-if-user-exists.outputs.Result.[0].email_count}} = 0

If the query returns something other than zero, we know the email address already exists in the database and we will return a success response signaling that. The contact information will not be added to the database subsequently in that case.

Add to Database

In the case that the email address does not exist already, we will proceed to add the contact information to the database. We will do so through another DB query action with the following SQL:

INSERT INTO leads (firstname, lastname, email)
VALUES ({{inputs.body.firstname}}, {{inputs.body.lastname}}, {{}})

Ping Slack

In a next step we will notify our team on Slack of a new addition to our lead list by simply putting:

New Lead: {{}}

We can modify this message and include other contact detail variables if we want to.

Welcome Email

In a last step we are adding a SMTP action block to automatically reach out to the new lead.

As the receipient we will put {{}} and will send the following text:

Hi {{inputs.body.firstname}},

Thank you for joining our waitlist. We will be in touch shortly.

Kind regards.


You’re able to modify all steps in this template to fit your use case. You can add further contact detail variables or get rid of the first DB query if you do not care about duplicates etc. Make it your own!

Note: In the default version of the template, we interact with a table called leads which is autogenerated. If you make changes to that table name or upload your own, do not forget to change the table name in the SQL queries.