Skip to main content

Webhook Server Setup

First we clone the following webhook example: https://github.com/indiemob/indieflow-webhook-example After cloning the repo go to its folder, run npm install and npm start Install and setup ngrok, this will allow external access to your webhook server Then run ngrok http 3000, this will show in your console your webhook public address i.e. https://0000-000-00-00-00.ngrok-free.app

Create a flow definition

The following command creates an example flow definition that we will tie to our webhook server
curl --request POST \
  --url https://api.indieflow.app/v1/flow/definition \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --data '{
  "name": "my_awesome_flow",
  "description": "A description of what my awesome flow is about",
  "webhook": {
    "url": "https://0000-000-00-00-00.ngrok-free.app/hook"
  },
  "steps": {
    "step_a": {
      "triggers": {
        "success": ["step_b", "step_c"]
      }
    },
    "step_b": {
      "depends_on": {
        "step_a": "success"
      },
      "triggers": {
        "success": ["step_d"]
      }
    },
    "step_c": {
      "depends_on": {
        "step_a": "success"
      },
      "triggers": {
        "success": ["step_d"]
      }
    },
    "step_d": {
      "depends_on": {
        "step_b": "success",
        "step_c": "success"
      }
    }
  }
}'
In the response body the webhook object will contain a signature_key i.e. wsk_upsjOIYYLME2zLPaiDDe9BpXP2ZS8xnw, copy that value and in your webhook server code replace the value of const SIGNATURE_KEY with the new value. Obviously for production you need to load that signature key from your configuration 🙂

Submit a flow execution

Then we submit a flow execution, starting with step_a
curl --request POST \
  --url https://api.indieflow.app/v1/flow/submit \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --data '{
  "flow_name": "my_awesome_flow",
  "flow_id": "my_awesome_flow_identifier",
  "step_name": "step_a"
}'
In this example: step_a will be executed and after being successful it will automatically trigger in parallel step_b and step_c and after both finish successfully they will both attempt to trigger step_d but this step will only be executed after all dependencies have been met