--- title: "Example 3: Consent Management- Relay to SF" slug: "example-flow-consent-management-part-i" updated: 2024-11-13T15:30:26Z published: 2024-11-13T15:30:26Z canonical: "docs.relaynetwork.com/example-flow-consent-management-part-i" --- > ## 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 3: Consent Management- Relay to SF 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 3 Goals In this example, we will monitor inbound Relay events looking for TCPA consent changes. If a we receive a consent change event from Relay, we will try and locate the matching *Person Account* and update it’s consent value - only if it has changed. > [!WARNING] > IMPORTANT > > TCPA consent is to a mobile number not an individual person. This example assumes your backend rules only allow a mobile number to be associated with a single *Person Account*. If this is not the case, then instead of looking for a single *Person Account* by the *Relay CCID*, you should instead look for all *Person Accounts* that match the mobile number and update each record with the new consent value. ## Assumptions - The Relay Connected App has been configured. This is required to receive push events from Relay. - TCPA consent is stored in a *Person Account* record in a custom field called *HasConsentedToSMS__c.* - The *Person Account* has a custom field, *RelayCCID__c,* that holds the unique ID of the user. - *HasConsentedToSMS__c* is of type *checkbox* - We will leverage a custom flow resource, *ConsentMapping*, to convert the Relay consent values to our internal consent value which is a simple checkbox. ## Flow Resources For this example, the following flow resources are required. | Resource | Type | Description | | --- | --- | --- | | ConsentMapping | - Resource Type → Formula - Data Type → Boolean | This resource is used to map the Relay Consent values to the consent values of our business. For this example the business assume a logical consented or not consented (e.g. checkbox). The below formula will return **True** when the Relay Consent value is either **written** or **express** and will return **False** if the consent value is **stop**`.` ```plaintext IF ({!$Record.CurrentConsent__c} == "Written", true, IF ({!$Record.CurrentConsent__c} == "Express", true, IF ({!$Record.CurrentConsent__c} == "Stop", false, false ) ) ) ``` | ## Flow Logic ![sfdc-flows-example3-diagram](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/sfdc-flows-example3-diagram.png) ### (1) Configure the Start Element - Create a **Record-Triggered Flow** on the **RelayEvents__c** record type - Set the *Configure Trigger* to **A Record is Created** - Set the following *Entry Conditions:* - Conditions Requirements set to **All Conditions Are Met (AND)** - Field → **EventType__c → Equals → channel_consent** - Field → **EventSubType__c → Equals → update** ### (2) Get the Person Account Try and locate the *Person Account* that is related to the *Relay Event* record, identified by the CCID value. As an additional optimization, we will only return the found record if its consent value is different from the *Relay Event* record. - Add a **Get Records** action Set the *Filter Account Records* *Condition Requirements* as follows: - *Condition Requirements* set to **All Conditions Are Met (AND)** ![sfdc-flows-example3-get_records](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/sfdc-flows-example3-get_records.png) - Field → **RelayCCID__c → Equals → $Record > RelayCCID** - Field → **HasConsentedToSMS__c → Does not Equal → ConsentMapping** ### (3) Check for a Found User - Add a **Decision** element - Add an *Outcome* that verifies the record was found ![rn-sfdc-flows-example1-found-account](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/rn-sfdc-flows-example1-found-account.png) - *Resource* → **{!Get_Record_From_CCID}** → **Is Null** → **False** ### (4) If Found, Update the Person Account If found, update the *Person Account* record’s consent field checkbox with the new value from the *Relay Event.* - *Set Variable Values* as follows: - **{!Get_Record_From_CCID.HasConsentedToSMS__c}** → **Equals** → **ConsentMapping** ![sfdc-flows-example3-assign_consent](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/sfdc-flows-example3-assign_consent.png) ### (5) Update the Person Account Add an **Update Records** element to commit the *Person Account* changes. ![sfdc-flows-example3-update_record](https://cdn.us.document360.io/6738087b-455d-402f-b70a-a44a4231547e/Images/Documentation/sfdc-flows-example3-update_record.png)