--- title: "Onboard a User to Relay" slug: "onboard-a-user-to-relay" updated: 2025-09-19T15:30:59Z published: 2025-09-19T15:30:59Z canonical: "docs.relaynetwork.com/onboard-a-user-to-relay" excludeFromExternalSearch: true --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.relaynetwork.com/llms.txt > Use this file to discover all available pages before exploring further. # Example 1: Onboarding a User to Relay NOTE This example should be used as a reference to understand basic concepts and ideas on integrating with Relay Network. It should not be taken literally as this is how integration to Relay must be done. You should replace your record types, field names, business logic, etc. with those that match your business process and setup. ## Example 1 Goals Whenever a *Person Account* is created or updated perform the following: - Check a field to see if the account has already been onboarded to Relay - If no, then call the Relay onboarding action, with a ***welcome*** trigger - If yes, then call the Relay onboarding action, without a message trigger, to update the user profile in Relay > [!NOTE] > NOTE > > Using an asynchronous path is always a good idea when integrating with Relay. This ensures all of your primary business logic is executed as fast as possible and prevents any issues in the Relay flow from effecting your records from being inserted or updated. ## Assumptions - The user’s data is stored in a *Person Account* record - The *Person Account* **ID** field will be used for the Relay **CCID**. - We have created a custom checkbox field, **HasBeenOnboardedToRelay__c,** on the *person account.* This field is used to determine if the user has already been onboarded to Relay. - A Relay **Welcome** experience will be triggered for new users only. ## Flow Resources | Resource Name | Type | Description | | --- | --- | --- | | OnboardingRequest | - Variable, Apex-defined - [RelayOnboardingRequest](/v1/docs/relayonboardingrequest) - Allow multiple values, no | This resource will be populated with the details about the user to be onboarded. | | ext_AgentName | - Variable, Apex-defined - [RelayDynamicInput](/v1/docs/relaydynamicinput) - Allow multiple values, no | In this example, we will be passing the Agent’s name (assigned to the person account) as an dynamic **ext_** field to Relay. See [Relay Dynamic Inputs](/v1/docs/relay-dynamic-inputs) | | CollectionExtFields | - Variable, Apex-defined - [RelayDynamicInput](/v1/docs/relaydynamicinput) - Allow multiple values, yes | When passing dynamic **ext_** fields to Relay, all of the fields must be grouped into a collection. See [Relay Dynamic Inputs](/v1/docs/relay-dynamic-inputs) | ## Flow ![rn-sfdc-flow-example1-onboarding](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flow-example1-onboarding.png) ## Flow Logic ### (1) Configure the Start Element - Create a **Record-Triggered Flow** on the **Account** record - Set *Configure Trigger* as **a record is created or updated** - Set any specific **Entry Conditions**. For this example we have included the following conditions: - Ensure the SMS TCPA consent value is not **Stop.** For this example consent is stored in the custom **RelayConsent__c** field*.* - Ensure the **PersonMobilePhone** field is not null. - Enable the **Run Asynchronously** path ![rn-sfdc-flow-ex1-start](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flow-ex1-start.png) ### (2) Populate the Onboarding Request Resource - Add an **Assignment** element to populate our **OnboardingRequest** resource - Set the values for the **OnboardingRequest** resource as follows: - **{!OnboardingRequest.ccid} → {!$Record.RelayCCID__c}** - **{!OnboardingRequest.mobilePhone} → {!$Record.PersonMobilePhone}** - **{!OnboardingRequest.consent} → {!$Record.RelayConsent__c}** - **{!OnboardingRequest.firstName} → {!$Record.FirstName}** - We leave the **Trigger ID** field empty. If this is a new user, then the **Trigger ID** will be populated in the decision branch. ![rn-sfdc-flows-example1-onboard%20request](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-onboard%20request.png) ### (3) Populate the ext_ field data We will be adding a custom ext_ field to the Relay onboarding request. This ext_ field will contain the name of the agent assigned to the *Person Account* and will be added to the user record in the Relay platform. - Add and **Assignment** element - **{!ext_AgentName.inputName} → Agent Name** - **{!ext_AgentName.inputValue} → {!$Record.AgentName__c}** ![rn-sfdc-flows-example1-ext_AgentName](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-ext_AgentName.png) ### (4) Add the ext_ Resource to the Collection Ext resources are passed to the *Relay Onboarding Action* as a collection. Therefore, for each ext_ field/value pair we want to send to Relay, we have to add it to a collection. - Add and an **Assignment** element - Add the **ext_AgentName** (populated in step 3). resource to the collection of **ext_** values ***CollectionExtValues****.* ![rn-sfdc-flows-example1-AddToExrtCollection](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-AddToExrtCollection.png) ### (5) Check if the User has Already Been Onboarded - Add a **Decision** element - Check the custom **HasBeenOnboardedToRelay__c** field to see if the user has already been onboarded to Relay. If this user has not been onboarded to Relay, then the **No** branch will add a **Welcome** trigger to the onboarding request. If the user was previously onboarded, then the **Trigger ID** will remain blank and we will only be updating the user’s information in Relay. ![rn-sfdc-flows-example1-decision-alreadyonboarded](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-decision-alreadyonboarded.png) ### (6) No Outcome - Add Welcome Trigger Id If the user has not been previously onboarded to Relay, we add a welcome trigger ID to the onboarding request. In this example the Relay trigger ID we are using is: **Welcome.** - Add an **Assignment** element - Set **{!OnboardingRequest.triggerId}** → **Equals** → **Welcome** ![rn-sfdc-flow-ex1-add_welcome_trigger](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flow-ex1-add_welcome_trigger.png) ### (7) Onboard User to Relay Leverage the [Relay Onboard Customer](/v1/docs/onboarding-action) flow action to callout to Relay and onboard the user. - Add the **Relay Onboard Customer** action element - Set the **Deactivate Previous Connections** value to **{!$GlobalConstant.True}** - Set the **Single Request** value to the **OnboardingRequest** resource we populated in step (2) - Set the **Ext Data** input value to **{!CollectionExtFields}** resource - Set the **Onboard Synchronously** value to **{!$GlobalConstant.True}**.` `This is required in order to check the status of the onboarding request within the flow (step 8 below). - Leave the **Send via Future** off. The flow is already running in a Future by way of the **asynchronous path**. ![rn-sfdc-flows-example1-onboard-action](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-onboard-action.png) ### (8) Check the Onboarding Callout Status When integrating to external systems with callouts, it is always a good practice to check the return status code to ensure the callout was successful. For the **Relay Onboard Customer** action as **responseCode** of **200** or **204** means success. If you receive a **202** response code, then your did not property set the input value for the **Onboard Synchronously** property. - Add a **Decision** element - Set the **Condition Requirements to Execute Outcome** to **Any Condition is Met (OR)** - Add the following conditions: - **{!Onboard_to_Relay.responseCode}** → **Equals** → **200** - **{!Onboard_to_Relay.responseCode}** → **Equals** → **204** If there was an error during the onboarding action, you can add any action as required by your business process. Some examples are: - Sending an Email Alert - Sending a Slack Message - Writing the error to another object ![rn-sfdc-flows-example1-decision-action-results](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-decision-action-results.png)