Skip to content

Webhooks

Andre edited this page Oct 17, 2022 · 35 revisions

Overview

A webhook can be enabled for a step by setting EnableWebhook to true. The webhook id can be set during workflow editing or left blank and Microflow will then auto-create webhook ids. Webhooks can be set to control child steps to run based on the action that is received by the webhook reply. A webook can contain a list of actions, and each action can contain a list of sub-steps. The action can be any string, for example "approve" and "decline". The action is optional. A webhook can be spawned and replied to with no reply actions since the webhookId is the identifier for the webhook. A list of sub-steps can also be set for when a webhook times out, by using the SubStepsToRunForWebhookTimeout object. The reply call to a webhook will return 200 OK, but can also possibly return a 202 ACCEPTED, in which case the external webhook reply call must retry and poll for a result.

API

Route Method Description HTTP Success Return Codes
webhooks/{webhookId}{action?} GET POST Reply URL of the webhook 200 202
  • {webhookId} : Uniquely identifies the webhook and can be set before-, or be auto set during workflow runtime.
  • {action?} : Optional action associated with the webhook. This is set in the WebhookSubStepsMapping.

Relevant Step Properties

  • EnableWebhook bool : Set this to true to make the step wait for a reply HTTP call.
  • WebhookId int : This value uniquely identifies the webhook and is present in the webhook URL. This can be pre-set during the workflow editing phase or it can be omitted and Microflow will generate a webhook guid during runtime.
  • WebhookTimeoutSeconds int : How long the webhook will wait for before timing out and continuing.
  • StopOnWebhookTimeout bool : When this is set to true then the entire workflow will stop if the webhook times out.
  • SubStepsToRunForWebhookTimeout List<int> : This indicates which steps to run if the webhook receives no reply within the timespan set by WebhookTimeoutSeconds. If this is not set, then the normal workflow defined child steps will run.
  • WebhookSubStepsMapping List<SubStepsMappingForActions> : This can be set to have a list of webhook actions that maps to other steps to run for the specific action.

Model Classes

public class SubStepsMappingForActions
{
    public string WebhookAction { get; set; }
    public List<int> SubStepsToRunForAction { get; set; } = new();
}
Clone this wiki locally