How to retrieve a list of relays to swap at runtime

If required to retrieve a list of relays to swap at runtime, please follow the instructions below:

Illustrated below is an example of a flow that gets specific information about relays within an organization, organizes the received details, and passes them to another flow to dynamically change relay connections at runtime.

  1. Setup Synatic Admin connector, obtain the name of Org and Synatic Admin API key. This credentials can be obtained by clicking on the user menu which is located on the top right of the Synatic instance and click on Settings as illustrated in the below image.

  1. The Admin Portal API Key is located in the Legacy API Keys section as per the image below. Click on the Regenerate API Key button to generate a new API key, copy it, and store it in a safe place.

  1. Create a new Synatic Admin connection to use in the Synatic Admin steps. For the credentials, type the name of the org and paste the API Key as illustrated in the below image.

  1. Create a flow in Synatic and add the Synatic Admin step as the source. Select the connection created and choose Relay as the Resource as highlighted in the image below.

  1. After the Pass Through reader step, add a calculator step with the following code:
let inputRecord = input.record;
let relays=inputRecord.endpoints.map(e=>({relay:`$$relay:${inputRecord.name}|${e.name}`}))
return {
    relays:relays
};

The code takes input record and extracts the endpoints from it. For each endpoint, it creates a new object with a “relay” property that combines the input record’s name and the endpoint’s name into the correct format required to change the relay at run time. Finally, returns an object with a “relays” property containing an array of these newly created relay objects.

  1. Add a Split step to split on Relays array, followed by a default calculator to see the results.

  1. Add a Synchronous flow to pass the values into another flow to change the change the relay connections at run time as illustrated in the image below.

Note: Relay connections need to be set at the top level since the replacement of the parameter occurs when the flow starts.

For more information on changing the connection at run time, refer to the below link:

How to Swap Relay Connections at Runtime