Sample Flows

This article presents a possible use case and a corresponding sample flow that you can support. This can be a helpful jumping off point as you plan your implementation.

Run an invoked action

Wix calls Invoke to run your action as part of the automation flow. If your action has an output schema, include the results in your response.

For example, let's say your app manages membership tiers for site members based on how active they are in the site owner's community. When a member contributes regularly to the community, they move up a membership tier.

  1. When a member contributes a predetermined number of pieces of content, the automation is triggered by the contribution-level-reached trigger. Wix calls Invoke with the action parameters as specified in the action's input schema:

    Copy
  2. Your action checks the member's total community contributions. If they meet the upgrade criteria, your action updates that member's membership tier. In this case, the action returns the upgraded tier:

    Copy

    Wix receives the results and continues to the next step in the automation.

Run an invoked action with a timeout

When Wix calls Invoke to run your action, you can tell Wix to wait for your action to complete before continuing to the next step in the automation. This is useful when your action takes time to complete, such as waiting for visitor input or querying large amounts of data.

Let's say your app provides booking services to gyms. When a new client signs up for their first training session, the trainer must first approve them based on their health data. Your app includes an action that notifies trainers of the new client and waits for their approval to confirm the session.

  1. When a new client signs up, the automation is triggered by the new-client-signed-up trigger. Wix calls Invoke with the action parameters as specified in the action's input schema:

    Copy

    Make sure to save activationContext.invocationToken for later use.

  2. Because it might take time for a trainer to respond, your response specifies a timeout period during which Wix waits for your action to complete:

    Copy

    Wix now waits 24 hours for you to confirm that the action has completed.

  3. Several hours later, a trainer reviews and approves the health form. Your app calls Report Action Invocation Completed to tell Wix that the action completed successfully.

    Include the invocation token from Wix's original call to Invoke, as well as any output data defined in your action's output schema:

    Copy
  4. Once Wix receives the response, the automation continues to the next action, which might send a confirmation code to the new client. Because the trainer approved the session during the timeout period, Wix sends the confirmation code successfully.

    However, if a trainer doesn't approve the health form in 24 hours, your app doesn't call Report Action Invocation Completed. In this case, Wix marks the action as failed and continues to the next action. The second action may fail if it requires output data from the first action, and the client might not receive a confirmation code.

Did this help?