Skip to navigation

Creating a Workflow with webhook trigger

A Webhook trigger starts your workflow whenever another system, such as a payment gateway or your backend, calls the Workflow URL. The data it sends becomes available to every step of the workflow.

Prerequisites

  • Ensure relevant notification events which will be configured as part of Workflow are created.
  • Make sure you have the sample payload which will be triggered via webhook.
  • Ensure at least 1 allowlist API is configured if you want to receive delivery reports.

How to configure a Webhook

Here is the setup at a glance.

1

Create the workflow

Navigate to Workflows from the left navigation panel. If you have already created a few workflows, you can see them in card view.

Click CREATE, enter a name and click SUBMIT. The workflow canvas opens with the list of triggers.

2

Select the Webhook trigger

Select WEBHOOK from the triggers. The Webhook panel opens on the right. To pick a different trigger, click CHANGE TRIGGER.

3

Choose the HTTP Method

Under HTTP Method, select the method which will call the workflow.

  • GET: trigger this workflow with a GET request and optional query parameters.
  • POST: trigger this workflow with a POST request and a payload with the appropriate content type.

4

Choose the Content Type

If you select POST, then you need to select the content type of the payload under Content Type.

Content TypeWhat it means
NoneNo payload will be sent when triggering the workflow.
JSONContent type will be set to application/json.
Form DataContent type will be set to multipart/form-data.
URL Encoded FormContent type will be set to application/x-www-form-urlencoded.
XMLContent type will be set to application/xml.
TextContent type will be set to text/plain.

5

Add a Sample Payload

If you selected JSON, Form Data or URL Encoded Form, click ADD SAMPLE PAYLOAD.

A panel opens where you can enter the sample payload. Use JSON to paste the full payload, or switch to FORM to add it as key and value pairs. Click BACK when you are done.

6

Simplify the payload (optional)

Using complex payloads for placeholder mapping can be challenging, and using the same payload variable again and again in conditions is cumbersome. Simplify lets you create your own variables, map payload fields to them, build expressions from payload fields, and use these variables throughout the Workflow.

Once you’ve added the sample payload, click Simplify at the top right of the panel. The Payload Mapper opens.

7

Map fields in the Payload Mapper

The Payload Mapper lets you create mapper variables from the existing payload, or from derived fields using HBS syntax.

  1. Under MAPPER VARIABLES, enter a name for the variable, for example payment_status.
  2. Under PAYLOAD/HBS, select a payload key or enter HBS, for example {{$input.body.status}}.
  3. Click ADD to add more variables, then click CONFIRM.

  • When directly mapping payload data, you can link, for example, acquirer_data.authentication_reference_number to the variable ref_no.
  • If you’re using Handlebars (HBS), use the payload data as $input.body.status to map it to a variable like payment_status. Using just payload.status will result in an error. To know more about Handlebars, refer to our documentation.

There is no restriction on the number of mapper variables created. All mapper variable names need to be unique.

Mapper variable name must not be any of the following: body, headers, formdata, query or method.

8

Add Query Parameters (optional)

Expand Query Parameters (Optional) if the workflow URL will include query parameters. These are primarily used with GET requests and are appended to the URL path after a ? character, for example /users?page=1&per_page=20.

Enter each one in Enter Key and Enter Value. Click ADD ANOTHER to add more.

9

Add Headers (optional)

Expand Headers (Optional) if you want to send any HTTP headers when running the workflow. Headers give the server extra information to process the request, and each has a key and a value, for example Cache-Control: no-store, no-cache, must-revalidate.

Enter them in JSON or switch to FORM to add them field by field.

10

Save

Click SAVE. You will see the Workflow saved successfully! popup. Click COPY URL to copy the Workflow URL, since you will need it to invoke this workflow. You can read more in Workflow URL.

Once the trigger is saved, you can add action and condition blocks after it.

How does Workflow Work?

Let’s illustrate this with our payment gateway example used by the ABC company. When ABC creates the Workflow in Fyno, they will configure their payment gateway to call the Workflow URL anytime a payment is processed.

Let’s assume that the response sent by the payment gateway for a successful payment is the below JSON.

Payload for successful payment
{
"payment_id": "P1",
"order_id": "O121",
"payment_status": "success",
"customer_details": {
"name": "John Doe",
"email": "john@email.com"
},
"payment_details": {
"method": "card",
"card_number": "XXXXXXXXX1234"
}
}

When a payment succeeds, the gateway will invoke the Workflow URL by including the above response as a payload.

The details that we configure in the trigger step should reflect the details used by the source calling the Workflow. So in our example, if the gateway is invoking the Webhook/Workflow URL as a POST request, this is how ABC will configure the trigger:

SettingValueWhy
HTTP MethodPOSTThe gateway calls the URL with a POST request.
Query ParametersEmptyThe gateway does not add any query strings to the URL.
HeadersEmptyThe gateway does not pass any headers.
Content TypeJSONThe payload is of type JSON.
Sample PayloadThe JSON aboveThe payment success payload from the gateway.

The data configured in the trigger step is just a sample, used to build the rest of the Workflow. If the payment gateway adds a new attribute to the response, the Workflow will still run as expected with the old payload. However, if you need to use this new attribute in the Workflow, you must update the trigger step with the new payload.

Once the Trigger has been set up and saved, you can drag and drop any action block or condition block. In the example below, the Webhook trigger sends a Notification Event and then checks a Condition with If and Else branches.

Action

An Action block can be added immediately after the trigger or based on the outcome of a Condition.

Notification Event refers to the notification events created within Fyno. You can call one as an action for the payload added in the previous step of the workflow.

1

Select the notification event

Under Select Notification Event, pick an event from the Notification Event dropdown. Click the open icon next to it to view the event in a new tab. The tag below the field shows which version of the event is used, for example Test.

2

Map the destination

Under Map data, expand DESTINATION. Configure it with custom values or values from the workflow payload.

  • Distinct ID: If you are using Fyno’s user profile, select the value for the distinct ID from the payload, or a custom variable created using Simplify.
  • Channels: Otherwise, map the channel destinations, such as SMS, WhatsApp, Email and InApp, from the payload or custom variables. Only the channels configured in the template linked to the notification event appear here.

3

Map the data

You will see all the fields that you have specified as Placeholders (dynamic values) in the template linked to the notification event. If you do not see this section, there are no placeholders in the template.

4

Add additional data (optional)

Expand ADDITIONAL DATA to add placeholders used in the route or not saved in the template. Enter the Placeholder name and pick the Placeholder value. Click ADD ANOTHER to add more.

For instance, if your template contains Hi {{name}} but you did not add name as a placeholder, Fyno still treats name as a placeholder since it uses the {{ }} syntax. Add name here and select its value.

Notification event settings

Click the settings icon at the top right of the Notification Event panel. You will see three tabs. Click BACK to return to the mapping.

Select Do you want to receive a delivery report? to get the delivery status of this notification event. Under Configure callback, choose where to send it.

Under Delivery Report Endpoints, select up to three endpoints from your allowlist.

For both, you can also add a Custom ID (up to 200 characters) and Custom Field 1 to Custom Field 3 (up to 50 characters each). You can read more in Receive delivery reports.

Condition

The Condition feature within Workflow lets you add all the logic you need to handle different situations within a single workflow. Conditions can be written for the parameters in the payload received from the trigger, and help direct the flow based on them.

Choose what the condition should check:

  • Variable: Select the variable you want to base the condition on.
  • Operator: Select an operator from the list below.
  • Value: Specify the value the If/Else condition will check against.

Supported operators

The Operator field supports the following:

  • Equals
  • Not Equals
  • Starts With
  • Ends With
  • Contains
  • In
  • Greater Than
  • Less Than
  • Greater than or Equal
  • Less than or Equal
  • Is
  • Is Empty
  • nin
  • is boolean

Workflow URL

The URL is auto-generated when you create the workflow. You need to use this URL to invoke the Workflow. Once you save or go live with your workflow, you will see a popup as shown below.

You can also open the Workflow URL by clicking the Workflow URL icon at the top right, next to the GO LIVE button.

We provide URLs for both TEST and LIVE. Copy both URLs and configure them in your system or any third party tool where the webhook will be triggered. For more on this window, see Access and Settings on the Workflows page.

If you are using a public URL, you can select one of these 2 options:

  • BASIC AUTH: The URL consists of your workspace ID and the token which Fyno uses for authentication.
  • TOKEN AUTH: The URL includes a query parameter token=<Fyno_generated_token>.

Workflows are public by default. If you turn on Restricted after the workflow is created and save it, you must use the Restricted URLs (Live and Test) when running the workflow.

You can update the token using the "Customize Token" option in the workflow header.

Since the workflow URL can be called from anywhere, it is a good idea to update the token if you feel it has been compromised. Always remember to update the workflow URL (with the new token) wherever the workflow is called.

How to raise Approval requests

If your workspace has Approval turned on, clicking GO LIVE creates an approval request instead of publishing the workflow right away. You can read more about it on the Approval Request page.