Loop

THIS PAGE
Introduction
Creating a Loop Webhook
Configuration
Nesting Webhooks within a Loop
Testing the Loop Webhook
Example
Best Practices

Introduction

Loop webhooks in Canonic allow you to iterate over a set of data and execute actions for each item, similar to a 'for loop' in programming.

Screenshot

Example: If you have a list of products, you can loop over them to perform actions such as updating their status or validating their availability.

Creating a Loop Webhook

  1. Within your workflow, decide where the Loop webhook is needed and click the + icon to add it.
  2. Select the Loop webhook type to start configuring your loop.

Configuration

Configure the Loop webhook by setting the Name and the Property to loop over:

  • Name: Enter a descriptive name for the loop webhook.
  • Key: Automatically generated based on the Name but can be customized for reference within the project.
  • Property to loop over: Define the data path that contains the items you wish to loop over.

Nesting Webhooks within a Loop

  1. To nest webhooks within a loop, add the desired webhooks by clicking the + icon beneath the Loop webhook.
  2. These nested webhooks will execute for each iteration of the loop based on the items in your specified data set.

Testing the Loop Webhook

Before finalizing your workflow, use the Test feature to ensure that the Loop webhook is configured correctly and that the response from the Loop is as expected.

Example

Suppose you have a workflow that needs to send personalized emails to a list of users:

  • You add a Loop Webhook named "Email Users".
  • The Loop webhook is configured to iterate over a list of user data.

Configuring the Loop Webhook

  • Name: "Email Users".
  • Property to loop over: Set this to the data path that holds your user list, such as params[1].data.userList.

Adding Actions within the Loop

  • Inside the loop, add an Email integration webhook that sends an email to each user.
  • Configure the Email integration webhook to use the user's email address and other relevant data available in each iteration.

Setting Up the Workflow

  1. In your workflow, at the point where the user list is ready, add the "Email Users" Loop webhook.
  2. Under this Loop webhook, add the Email integration webhook, and configure it to use data from the current iteration, such as params[1].data.current.email for the email address.

Best Practices

  • Use descriptive names for your Loop webhook to easily identify their purpose within complex workflows.
  • Ensure that the Property to loop over is correctly pointing to a list of items to prevent errors during execution.

Note: All changes must be published to be effective in the live environment.

Did you find what you were looking for?
πŸ‘
πŸ‘Ž
What went wrong?
Need more help?We have a thriving Discordcommunity that can help you with all things Canonic. β†’