How to Get a list of Relays to Swap at RunTime

If you require to get 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.

Setup Synatic Admin connector, Obtain the name of Org and Synatic Admin API key.
Click 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.

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.

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.

Create a flow in Synatic and Add the Synatic Admin step as the source, Select the connection created and choose Relay as the Resource

After the Pass Through reader step, Add a calculator step with the following code

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.

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

Add a Synchronous flow to pass the values into another flow to change the change the relay connections at run time.
Note: Relay connections need to be set at the top level since the replace of the parameter happens when the flow starts

For more information on changing the connection at run time, Refer to: How to Swap Relay Connections at Runtime