Workflow

Understand what is workflow and how to design a workflow to send multi-channel notification.

Workflow is the notification powerhouse where you define the logic and stitch individual pieces together, like user, template, vendor, and preferences, to deliver notifications to the end user.

A workflow comprises a series of steps that, when executed in sequence, form the notification journey. There are primarily four types of workflow steps, referred to as workflow nodes in SuprSend:

  1. Trigger: This is the first node in your workflow that initiates the notification. You can trigger workflow using an event call to SuprSend. Events can be
    1. External actions performed by a user on your platform, such as post like or a new comment. You can track these actions by integrating one of our frontend SDKs directly into your product or pass them via backend SDKs or HTTP API.
    2. User entering or leaving a list: these events are generated when you maintain a user list and you want to notify users who leave or enter the list, for instance, when users unsubscribe from a topic. These events are auto tracked if you maintain lists within SuprSend.
    3. Internal trigger from your backend code based on some data or state change like shipment out for delivery or job closed.
  2. Functions: Functions are logical steps in your workflow such as delay, batch multiple notifications into a single summarized notification, or implementing conditional waits.
  3. Branches split the workflow execution into parallel flows where user passes through one of the branch based on a condition. An example of branch is wait until where user waits on this branch until a condition is met.
  4. Delivery: Delivery nodes are the final send nodes that deliver the final notification to the users. The content of the notification is designed with templates. You can send notification on a single channel, multi-channel, or use channel routing for sequential delivery across multiple channels.

Notification Categories

Each workflow is associated with a notification category. Notification category is used to group related workflows together and are also used for users to set their preferences across a group of workflows. For example, all shipment related notifications can be grouped under a category Delivery updates and user can then chose to turn off these notifications on email and just receive these updates on push channel. This preference setting will automatically apply to all workflows with category Delivery updates. You can know more about notification categories here.


Designing a workflow

In SuprSend, you can group multi-channel and multi-stakeholder notifications in a single workflow. We consider workflow as a sequence of notifications triggered by an event.

One example of a multi-channel and multi-stakeholder workflow can be a payment reminder, where you have to send a series of reminders to the company's users.

  • The first reminder is sent to the admins of the accounts via email.
  • 2nd reminder is sent to the admins as well as the finance team of the company on Inbox first, and then via email if the notification is not seen on Inbox.
Payment Reminder with 2 send nodes

Payment Reminder workflow

We recommend creating a single workflow for tracking the journey corresponding to an event so that it's easier for you to track the entire flow, like how many users saw the first notification, how many dropped off after the second notification, which is the best performing channel, and more. It is also easier to maintain and iterate over if you have fewer workflows corresponding to an event.


πŸ“˜

Test your workflows in staging workspace before deploying to production

It is best to first design your workflows in staging workspace and trigger a test workflow before making it live for your production users. Once, your workflow is well tested and working, clone it to the production workspace.


Version control for workflows

All the workflow changes are first saved in the draft version and are only made live once you commit the changes. This allows you to confidently make changes to workflows, without affecting any running workflow in production.


Triggering a workflow

Workflows created on SuprSend dashboard are triggered via event call. Below is a sample event call to trigger payment reminder workflow. These events can either be triggered by integrating one of our frontend or backend SDKs or you can also integrate with your CDP platforms like Segment and map the events passed through these platforms as your workflow trigger.

from suprsend import Event

# Track Event Example
distinct_id = "0fxxx8f74-xxxx-41c5-8752-xxxcb6911fb08"
event_name = "Payment Pending"   
properties = {													
  "first_name": "User",
  "invoice_amount": "$5000",
  "invoice_id":"Invoice-1234"
} 
event = Event(distinct_id=distinct_id, event_name=event_name, properties=properties)

# Track event
response = supr_client.track_event(event)
print(response)
const { Event } = require("@suprsend/node-sdk");

// Track Event Example
const distinct_id = "0fxxx8f74-xxxx-41c5-8752-xxxcb6911fb08" 
const event_name = "Payment Pending"  

const properties = {													
  "first_name": "User",
  "invoice_amount": "$5000",
  "invoice_id":"Invoice-1234"
}

const event = new Event(distinct_id, event_name, properties)

// Track event
const response = supr_client.track_event(event)
response.then((res) => console.log("response", res));
import org.json.JSONObject;

import suprsend.Suprsend;
import suprsend.Event;

public class Event {
  public static void main(String[] args) throws Exception {
    trackEvent();
  }

  private static Subscriber trackEvent() throws SuprsendException {
    Suprsend suprsendClient = new Suprsend("_workspace_key_", "_workspace_secret_");

    String distinctId = "0fxxx8f74-xxxx-41c5-8752-xxxcb6911fb08"; 
    String eventName = "Payment Pending"; 

    JSONObject eventProps = new JSONObject()
      .put("first_name", "User")
      .put("invoice_amount", "$5000");
   	  .put("invoice_id", "Invoice-1234");


    Event e = new Event(distinctId, eventName, eventProps);

    // Track event
    JSONObject response = suprClient.trackEvent(e);
    System.out.println(response);
  }
ev := &suprsend.Event{
  EventName:  "Payment Pending", 
  DistinctId: "0fxxx8f74-xxxx-41c5-8752-xxxcb6911fb08", 
  Properties: map[string]interface{}{													
    "first_name": "User",
    "invoice_amount": "$5000",
    "invoice_id":"Invoice-1234"
  }
}

// Send event to Suprsend by calling .TrackEvent
_, err = suprClient.TrackEvent(ev)
if err != nil {
  log.Fatalln(err)
}

πŸ“˜

User profile should be created in SuprSend for passing in event call

Please Note that the user profile should be created beforehand for distinct_id passed in your event call. If user is not present, it will discard the event call.


Creating dynamic workflows via API

For transactional usecases such as OTP, authentication, and verification notifications, where dynamic user channel information or sensitive data needs to be passed at the time of sending, you can configure the entire workflow setup within your codebase. This enables you to trigger the workflow directly via API without relying on an event call to SuprSend. Dynamic workflows can be created using our backend SDK or API. Below is an example payload illustrating a dynamic workflow setup for an OTP notification.

from suprsend import Workflow

# Prepare Workflow body
workflow_body = {
  "name": "Login OTP",
  "template": "otp",
  "notification_category": "system",

  "users": [
    {
      "distinct_id": "0f988f74-6982-41c5-8752-facb6911fb08",
      "$sms": ["+15555555555"]
    }
  ],
  # variable data in your template
  "data": {
    "OTP": "1234"
  }
}

wf = Workflow(body=workflow_body)
# Trigger workflow
response = supr_client.trigger_workflow(wf)
print(response)
const { Workflow } = require("@suprsend/node-sdk")

// Prepare Workflow body
const workflow_body = {
  "name": "Login OTP",
  "template": "otp",
  "notification_category": "system",

  "users": [
    {
      "distinct_id": "0f988f74-6982-41c5-8752-facb6911fb08",
      "$sms": ["+15555555555"]
    }
  ],

  // data can be any json
  "data": {
    "OTP": "1234"
  }
}

const wf = new Workflow(workflow_body)
// Trigger workflow
const response =  supr_client.trigger_workflow(wf) // returns promise
response.then((res) => console.log("response", res));
import org.json.JSONObject;
import org.json.JSONTokener;

import suprsend.Suprsend;

public class TestSuprsendSDK {

    private JSONObject loadBody(String fileName) throws FileNotFoundException {
        JSONObject jsonObject;
        String relativePath = String.format("%s/src/%s/resources/%s.json", System.getProperty("user.dir"),
                this.getClass().getPackage().getName(), fileName);
        InputStream schemaStream = new FileInputStream(new File(relativePath));
        jsonObject = new JSONObject(new JSONTokener(schemaStream));
        return jsonObject;
    }

    public static void main(String[] args) throws Exception {
        TestSuprsendSDK sdk = new TestSuprsendSDK();
        // Load workflow body json
        JSONObject body = sdk.loadBody("input");
        // SDK instance
        Suprsend suprsend = new Suprsend("WORKSPACE KEY", "WORKSPACE KEY");
        // Create workflow instance
        Workflow wf = new Workflow(body)
      
        // trigger workflow
        JSONObject resp = suprClient.triggerWorkflow(wf);
        System.out.println(resp);
    }
}}

// Workflow Body Input file
{
    "name": "Login OTP",
    "template": "otp",
    "notification_category": "system",
  
    "users": [
        {
            "distinct_id": "0f988f74-6982-41c5-8752-facb6911fb08",
         	  "$sms": ["+15555555555"]
        }
    ],
    // data can be any json / serializable python-dictionary
    "data": {
        "OTP": "1234"
    }
}
// Create workflow body
wfBody := map[string]interface{}{
  "name":                  "Login OTP",
  "template":              "otp",
  "notification_category": "system",
  
  "users": []map[string]interface{}{
    {
      "distinct_id": "0f988f74-6982-41c5-8752-facb6911fb08",
      "$sms": []string{"+15555555555"},
    },
  },
  
  // # data can be any any json string
  "data": map[string]interface{}{
    "OTP":   "1234"
  },
}

wf := &suprsend.Workflow{
  Body:           wfBody,
}

// Call TriggerWorkflow to send request to Suprsend
_, err = suprClient.TriggerWorkflow(wf)
if err != nil {
  log.Fatalln(err)
}

Send notification using Google Sheets

You can also configure your one-time notifications using google sheets. Refer step-by-step guide to configure workflows using google sheets here.


Per-Tenant workflow

Tenants represents a segment that user belongs to. It can be organizations, teams within an organization, subsidiary companies or different product lines in the same business. While there is no association of workflows and tenants directly within SuprSend, you can dynamically pass tenant_id in your trigger to send notification for a tenant. This will pick the properties corresponding to that tenant for sending custom notification content for the tenant and also pick per-tenant preferences while executing the workflow. Read more about tenant workflows here.


Tracking / Debugging Workflow run

For each workflow run, you'll see a detailed log capturing the state and response of each workflow step as they are being sent. You can refer to error guides to comprehend the errors and see how to solve them.


Analyzing notification performance

SuprSend provides comprehensive analytics for you to track the performance of your notifications. You can track delivery, seen, click across all channels in a single graph, track which channel is performing best, and how users are interacting with the notification. You can also get the notification data back in your data warehouse for internal analysis and reporting using S3 connector.

πŸ‘

Configure SuprSend webhook in vendor dashboard to track delivery data

Ensure to include the SuprSend webhook callback URL in your vendor dashboards for WhatsApp, SMS, and email. This enables us to track delivery, seen, and click statuses to show in logs and analytics. For real-time updates to your system, you can also add your webhook endpoint as an outbound webhook in SuprSend. SuprSend processes data received from your end-vendors in a standard format, eliminating the need to adapt your system for different vendor data structures.