- 15 Jun 2022
- 5 Minutes to read
- DarkLight
Salesforce notification: Send Chatter message to account owners when products are being compared
- Updated on 15 Jun 2022
- 5 Minutes to read
- DarkLight
A buyer viewing G2 comparison pages for your product can be a clear signal that they are entering a critical stage of the buying process. Notifying your Salesforce account owners of this activity as it happens can provide an advantage over your competitors. This example notification sends a Chatter notification to Salesforce account owners when one of their mapped accounts views a comparison page for your product.
For more information on how to use Salesforce Chatter, review Salesforce’s Trailblazer training course for Chatter.
For more information on customizing your organization’sChatter feed, review Salesforce’s Customize Chatter Feed Tracking documentation.
1. Create the record-triggered flow
To create a new flow:
- At the top-right corner of any Salesforce page, select Setup.
- In the left sidebar, go to Build > Create > Workflow and Approvals > Flows.
If using Salesforce Lightning, go to Process Automation > Flows.
- Select New Flow to open the Flow Builder.
- Select Record-Triggered Flow, then Create.
- Find the G2 Event object by searching for
G2Crowd__G2_Event__c
in the Object search box. Set Configure Trigger to A record is created. - Set Entry conditions.
For this example, the entry conditions are used to filter for new G2 Event Tags that indicate a buyer organization has compared your product to a competitor. Set the Conditions Requirements dropdown to All Conditions Are Met (AND) and add the following conditions:
Row | Field | Operator | Value | Description |
---|---|---|---|---|
1 | G2Crowd__Tag__c | Starts With | comparisons | Screens for the G2 Event tag for comparisons ( ```comparisons.show’’ )’ |
2 | G2Crowd__Account__c | Is Null | False | Does not send a notification if G2 could not determine the organization responsible for the signal. Salesforce refers to this value as $GlobalConstant.False |
- Set Optimize the Flow to Actions and Related Records, then select Done.
- In the top-right corner of Flow Builder, select Save, then enter a name for your Flow (Flow Label). The Flow API Name auto-populates based on your Label entry.
- Select Save to finalize your Flow creation.
2. Create the notification Resources
Resources enable you to create custom variables, formulas, and text templates to customize your notification with specific event data, such as a record URL, an account name, and the account owner’s Salesforce ID. This notification uses variables to fill in G2 Event data, formulas to fill in direct URLs to the account and event records, and text templates to use the variables and formulas in the notification message body.
To create the variables for your notification:
- In the left sidebar of the Flow Builder, select New Resource, then select Variable from the Resource Type dropdown.
- Enter an API Name (this is the name for your variable), check Available for input, and set the Data Type to Text. A Default Value box will appear.
To enter a Default Value, you must understand how to access G2 custom objects in Salesforce.
For example, to access the email address of an account owner, select Record > G2Crowd__Account__ > Owner > Email. You must select the dropdown option at each step to build your Default Value. Your final Default Value is $Record.G2Crowd__Account__r.Owner.Email
.
The following table illustrates the API Name, the Default Value, and the search queries you should enter into the text box to quickly access the correct value.
API Name | Default Value | Search query |
---|---|---|
EmailAddress | $Record.G2Crowd__Account__r.Owner.Email | Record > Account__r > Owner > Email |
- Repeat steps 1 and 2 for each of the following variables, making sure to check Available for input and set the Data Type to Text for each new variable:
API Name | Default Value | Search query |
---|---|---|
OwnerID | $Record.G2Crowd__Account__r.OwnerId | Record > Account__r > OwnerId |
AccountID | $Record.G2Crowd__Account__c | Record > Account__c |
AccountName | $Record.G2Crowd__Account__r.Name | Record > Account__r > Name |
G2Title | $Record.G2Crowd__Title__c | Record > Title |
FirstName | $Record.G2Crowd__Account__r.Owner.FirstName | Record > Account__r > Owner > First Name |
LastName | $Record.G2Crowd__Account__r.Owner.LastName | Record > Account__r > Owner > Last Name |
Time | $Record.G2Crowd__Time__c | Record > Time |
G2URL | $Record.G2Crowd__URL__c | Record > URL |
G2EventID | $Record.Id | Record > Record ID |
City | $Record.G2Crowd__City__c | Record > City |
State | $Record.G2Crowd__State__c | Record > State |
Country | $Record.G2Crowd__Country__c | Record > Country |
To create formulas to populate your notification with Salesforce URLs that link directly to the G2 Event and account:
- In the left sidebar of the Flow Builder, select New Resource, then select Formula from the Resource Type dropdown.
- Set the Data Type to Text, enter the following information to build an account URL, then select Done:
| API Name | Formula |
| --- | --- |--- |
| AccountURL | LEFT({!$Api.Partner_Server_URL_260}, FIND( '/services', {!$Api.Partner_Server_URL_260})) + "/lightning/r/AccountID/" + {!AccountID} + "/view"
|
- Repeat step 2 with the following information to build a G2 Event record URL:
API Name | Data Type | Formula |
---|---|---|
G2EventURL | Text | LEFT({!$Api.Partner_Server_URL_260}, FIND( '/services', {!$Api.Partner_Server_URL_260})) + "/lightning/r/EventID/" + {!G2EventID} + "/view" |
To create the text template for your notification message body:
- In the left sidebar of the Flow Builder, select New Resource, then select Text Template from the Resource Type dropdown.
- Enter the name for your message template under API Name. G2 recommends the name MessageBody.
- Set the View dropdown to View as Plain Text.
- Enter your notification message into the Body text box. Your message should use the custom variables you created to fill in relevant data. Select Insert a resource to add one of the variables you created. For this example, you can paste the following message into the Body:
@[{!OwnerID}]
{!FirstName} {!LastName},
{!AccountName} has a Buyer Intent signal on G2.com.
G2 Page Title: {!G2Title}
G2 URL: {!G2URL}
Time of the G2 Activity: {!Time}
G2 Event Link: {!G2EventURL}
Account Link: {!AccountURL}
User Location: {!City}, {!State}, {!Country}
-Your Salesforce Admin
- Select Done.
3. Add the Chatter notification Action
- Select the + below the the Record-Triggered Flow Start, then select Action.
- Search for and select Post to Chatter to open the New Action editor.
- Enter a Label for your action, such as Chatter Post for G2 Events. The API Name auto-populates based on your label entry.
- Select your MessageBody Text Template from the Body search box.
- Select your AccountID Variable from the Target Name or ID search box.
- Select Done to commit your changes.
4. (Recommended) Test and activate your flow
G2 strongly recommends testing your flow before activation. To test your flow:
- Select Debug from the Flow Builder top-right menu.
- Leave all parameters set to their default settings.
- Enter a G2 Event ID into the G2 Event search bar to debug your event using a specific test case. You might have to go to the G2 Events tab in a separate window to find Event IDs.
G2 recommends choosing an event that meets your entry conditions and one that does not meet your entry conditions to assess that your Flow behaves as intended. For this example, test a G2 Event record with the Tag comparisons.show
, then test one that does not have the proper tag.
- Select Run to begin your debug.
- Open the Start Condition Requirements and Action (denoted by a lightning bolt icon) tabs to view how your Text Templates were filled with your custom Variables and Formulas.
- When satisfied, select Activate to turn on your flow.