Trigger a flow from an ION event
Use the ion-webhooks component to start a flow when an ION event fires, such as a run being created or a purchase order changing state.- In Workflow Builder, create a new workflow and give it a name.
- Add the ion-webhooks component and set it as the flow’s trigger.
- Configure the trigger’s Connection. Select an existing ION connection, or add one:
- Enter a name for the connection.
- Enter the Client ID and Client Secret from your ION API keys.
- Select the Environment your ION instance runs in, such as Production or Sandbox.
- Set a Webhook Receiver Name. ION uses this name for the receiver it creates, so matching it to the flow name keeps the two easy to trace.
- Add one or more trigger events as resource-and-action pairs, such as Runs - Create to fire whenever a run is created. A flow can trigger on more than one event.
ion-webhooks only triggers the flow. To read or write ION data once the flow is running, add the ion-api component as described below.
Read or write ION data with the ion-api component
Use the ion-api component to run a GraphQL query or mutation against ION from inside a flow, such as looking up a record the trigger referenced, or writing a value back to it.- Add a step to the flow and search for ion-api. You may also see First Resonance ION in the results: it’s the same component, listed twice because one listing is public and the other is private to ION customers. Either works, but ion-api is the one kept up to date, so prefer it when both appear.
- Choose the action for what you want to do. ion-api has a dedicated action for most common reads and writes, such as Get Part or Update Part Attribute, as well as a general Run GraphQL Query action for anything else. See the ion-api actions reference for the full list.
- Configure the step’s Connection. The first time you use ion-api in a flow, set this up the same way as the ion-webhooks connection above. Once a connection exists, later ion-api and ion-webhooks steps in the same flow can select it from the dropdown instead of creating a new one, since both components connect to ION the same way.
- Fill in the action’s fields, such as the record’s ID. Reference a value from an earlier step, such as the ID the trigger received, instead of typing it in directly.
- GraphQL Query: the query or mutation to run.
- GraphQL Variables: a JSON object of the variables the query declares. Reference an earlier step’s output for any variable that should come from the flow rather than be typed in, such as the ID of the record the trigger fired for.
Example: set a custom attribute automatically when a part is created
This example builds a flow that sets a part’sTracking Strategy custom attribute whenever a part is created, based on its tracking level and sourcing strategy:
- Create a flow triggered by Parts - Create, following Trigger a flow from an ION event above.
- Add an ion-api step using the Get Part action to look up the new part’s tracking and sourcing details. Set Part ID to the part ID from the trigger.
- Add a branch step that checks whether the part’s tracking level is set. Route parts with no tracking level to one branch, and every other part to another.
- On the no-tracking branch, save the value
N/Afor use in a later step. - On the other branch, save a value built from the part’s tracking level and sourcing strategy, such as
Lot - Make. - Add an ion-api step using the Update Part Attribute action to write the saved value to the part’s
Tracking Strategyattribute. Set Part ID and Etag to the values Get Part returned, Attribute Key toTracking Strategy, and Attribute Value to the value you saved.
Tracking Strategy attribute set automatically, without anyone setting it by hand.