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:
- Trigger: This is the first node in your workflow that initiates the notification. You can trigger workflow using an event call or a direct API call to SuprSend. Events can be
- External actions performed by a user on your platform, such as
post like
ora 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. - 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. - Internal trigger from your backend code based on some data or state change like
shipment out for delivery
orjob closed
.
- External actions performed by a user on your platform, such as
- Functions: Functions are logical steps in your workflow such as delay, batch multiple notifications into a single summarized notification, or implementing conditional waits.
- 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.
- 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.
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.
We recommend creating a single workflow for tracking the journey corresponding to a trigger 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 can be triggered via event call or via a direct API call.
Triggering workflow 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 pass all data and recipient information directly in a single API. This method doesn't require user creation beforehand to trigger notification and can be used if you are migrating your existing notifications to SuprSend. Below is an example payload illustrating a dynamic workflow setup for an OTP notification.
from suprsend import Event
from suprsend import WorkflowTriggerRequest
supr_client = Suprsend("_workspace_key_", "_workspace_secret_")
# Prepare workflow payload
w1 = WorkflowTriggerRequest(
body={
"workflow": "login_otp",
"recipients": [
{
"distinct_id": "0gxxx9f14-xxxx-23c5-1902-xxxcb6912ab09",
"$sms": ["+15555555555"]
}
],
# variable data in your template
"data":{
"OTP": "1234"
}
}
)
# Trigger workflow
response = supr_client.workflows.trigger(w1)
print(response)
const {Suprsend, WorkflowTriggerRequest} = require("@suprsend/node-sdk");
const supr_client = new Suprsend("_workspace_key_", "_workspace_secret_");
// Prepare workflow payload
const body = {
"workflow": "login_otp",
"recipients": [
{
"distinct_id": "0gxxx9f14-xxxx-23c5-1902-xxxcb6912ab09",
"$sms": ["+15555555555"]
}
],
"data":{
"OTP": "1234"
}
}
const w1 = new WorkflowTriggerRequest(body)
// Trigger workflow
const response = supr_client.workflows.trigger(w1);
response.then(res => console.log("response", res));
package main
import (
"log"
suprsend "github.com/suprsend/suprsend-go"
)
// Initialize SDK
func main() {
suprClient, err := suprsend.NewClient("_workspace_key_", "_workspace_key_")
if err != nil {
log.Println(err)
}
_ = suprClient
triggerWorkflowAPI(suprClient)
}
func triggerWorkflowAPI(suprClient *suprsend.Client) {
// Create WorkflowRequest body
wfReqBody := map[string]interface{}{
"workflow": "login_otp",
"recipients": []map[string]interface{}{
{
"distinct_id": "0gxxx9f14-xxxx-23c5-1902-xxxcb6912ab09",
"$sms": []string{"+15555555555"},
},
},
// # data can be any json / serializable python-dictionary
"data": map[string]interface{}{
"OTP": "1234",
},
}
w1 := &suprsend.WorkflowTriggerRequest{
Body: wfReqBody,
}
// Call Workflows.Trigger to send request to Suprsend
resp, err := suprClient.Workflows.Trigger(w1)
if err != nil {
log.Fatalln(err)
}
log.Println(resp)
}
It is a new workflow method and is available in below SDK versions (Python >= v0.11.0, Go >= v0.5.1 and Node >= 1.10.0). Upgrade to the latest version if you are on older SDK versions.
Event based Trigger
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.
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.
Updated 5 months ago