Send email when a charge is paid on Stripe

A workflow that create a charge on Stripe and trigger an email via Sendgrid sent to the user

Workflow Code

View the Github Project. View all of the files, fork the project and deploy to Heroku in a few clicks.


let stripe = null;
let sendgrid = null;

module.exports.handle = function* ({ email, amount, currency, template_id }) {
  stripe = this.connector("stripe", stripeConnectorId);
  sendgrid = this.connector("sendgrid", sendgridConnectorId);

  // Create a charge on Stripe
  yield"/charges", {
    body: `currency=${currency}&amount=${amount}&source=tok_visa&receipt_email=${email}`

  // Send email with Sendgrid
  yield"/mail/send", {
    body: {
      personalizations: [
          to: [{ email: email }],
          dynamic_template_data: { email, amount, currency, subject }
      template_id: template_id,
      from: { email: "" }

Workflow input

A workflow instance is launched with the following input.\ A workflow can be launched using the quick launch button on the sandbox or via http.

  "email": "",
  "amount": "4000",
  "currency": "usd",
  "template_id": "34"

Get your API keys from Stripe

If you don't already have a stripe account, you can create a test account at You will need your Stripe test API keys, and secret key to create the API connector on Zenaton.

Stripe dashboard

Ideas to improve the workflow:

This is a simple workflow to get you started with Zenaton but can be modified for more complicated logic.

  • Send emails with customized messages based on the customer's information or behaviour. This data could be sent in the workflow input or you could add a step to the workflow to grab it from your database.
  • If it is the first time the customer has been charged for a subscription, send a different email.
  • If the amount paid by the user is more than X, then trigger a slack notification to a team member to follow up.
  • Add A/B testing in the workflow and send a notification on slack only if there is a big gap in the metrics for opening / click rate

View the Github Project. __View all of the files, fork the project and deploy to Heroku in a few clicks. Or run it in the online sandbox without needing to install Zenaton.

Play on Zenaton