-
Notifications
You must be signed in to change notification settings - Fork 31
Logging to Google Chat
RFLIB can post a notification to a Google Chat space whenever a log event is published at or above a configured severity threshold. The integration uses a Google Chat Incoming Webhook and Salesforce Named Credentials to keep the webhook URL secure.
- A Google Workspace account. Incoming Webhooks are a Google Workspace feature and are not available for personal Google (Gmail) accounts.
- A Google Chat space where you have permission to manage apps and webhooks
- Salesforce org with RFLIB v11.0.0 or later deployed
- Permission to manage Named Credentials in Salesforce Setup
- In Google Chat, open (or create) the space where notifications should appear.
- Click the space name at the top to open the space menu and choose Apps & integrations.
- Under Webhooks, click Add webhooks (or Manage webhooks if one already exists).
- Give the webhook a name (e.g.
RFLIB Logger), optionally provide an avatar URL, and click Save. - Google Chat generates a webhook URL. Copy it — this is your webhook URL.
https://chat.googleapis.com/v1/spaces/AAAA.../messages?key=...&token=...Keep this URL private. The
keyandtokenquery parameters act as a bearer token — anyone with the URL can post to your space.
The webhook URL must be stored as a Named Credential so it is never visible in code, Custom Settings, or SOQL queries. In the modern Salesforce model a Named Credential references an External Credential, so this step has three parts: create the External Credential, add a Principal, then create the Named Credential.
-
In Salesforce Setup, search for Named Credentials and open it.
-
Select the External Credentials tab and click New.
-
Fill in the fields:
Field Value Label Google ChatName Google_ChatAuthentication Protocol No AuthenticationThe Google Chat webhook URL embeds its own
keyandtoken, so no additional authentication protocol is required. -
Click Save.
- On the Google Chat External Credential detail page, scroll to the Principals section and click New.
- Set the Parameter Name to
RFLIB Google Chatand leave the Sequence Number as1. - Click Save. The Principal's Authentication Status should show Configured.
The running user (or the Automated Process user, depending on how the RFLIB Log Event Handler flow runs) must be granted access to the Google Chat External Credential through a Permission Set. Without this access, callouts fail with an authorization error.
-
Back on the Named Credentials tab, click New.
-
Fill in the fields:
Field Value Label RFLIB Google Chat IntegrationName RFLIB_GOOGLE_CHAT_WEBHOOK(must match exactly)URL Paste the Google Chat webhook URL from Step 1 Enabled for Callouts Checked External Credential Google Chat -
Click Save.
Sandbox vs Production: Named Credentials are org-specific. You must create this credential separately in each sandbox and in production. Using different webhook URLs per environment lets you route sandbox notifications to a dedicated Google Chat space.
-
In Salesforce Setup, search for Custom Settings and open
rflib_Logger_Settings__c(Logger Settings). -
Click Manage, then either edit the existing org default or click New to create one.
-
Set the Google Chat Log Level field to the minimum severity that should trigger a notification:
Value Behaviour NONEDisabled — no Google Chat notifications sent (default) FATALOnly FATAL events ERRORERROR and FATAL events WARNWARN, ERROR, and FATAL events INFOand belowNot supported (clamps to WARN at runtime) Most teams start with
ERRORorWARN. -
Click Save.
The Google Chat Log Level setting is a Hierarchy Custom Setting, meaning it can be overridden at the Profile or User level if finer-grained control is needed.
WARNis the enforced minimum — INFO, DEBUG, and TRACE events are never sent to Google Chat regardless of this setting.
When a rflib_Log_Event__e Platform Event is published, the RFLIB Log Event Handler flow fires. If the event's level meets the configured Google Chat Log Level threshold, rflib_SendLogEventGoogleChatAction posts a cardsV2 card message to the configured Google Chat space.
The message is a single card containing:
-
Header —
RFLIB Log Event – <Log Level>with the Org Name as the subtitle - Log Level — the severity of the event
- Created By — the Salesforce User ID that triggered the event
- Context — the logger context string
- Request ID — the transaction request ID for correlation
- Log Messages — the log output (truncated from the beginning at 2,800 characters so the exception at the tail is visible)
- Platform Info — governor limit snapshot in formatted JSON (truncated at 2,800 characters)
HTML escaping: Google Chat renders card text as limited HTML, so RFLIB escapes the HTML-significant characters (
&,<,>) in the log content. This ensures angle-bracket text such as XML/HTML snippets, generic type names, or<init>stack frames is delivered verbatim rather than being interpreted as markup.
Execution order in the flow:
Platform Event fires
│
▼
Log to HTTP Endpoint (rflib_HttpCalloutLogAction)
│ ← fault skips to next step
▼
Send Log Event to Slack (rflib_SendLogEventSlackAction)
│ ← fault skips to next step
▼
Send Log Event to Teams (rflib_SendLogEventTeamsAction) ← runs in a new transaction
│ ← fault skips to next step
▼
Send Log Event to Google Chat (rflib_SendLogEventGoogleChatAction) ← runs in a new transaction
│ ← fault skips to next step
▼
Archive Log Event (rflib_ArchiveLogAction)
│ ← fault skips to next step
▼
Send Log Event Emails (rflib_SendLogEventEmailAction)
Each step has a fault connector that continues to the next action, so a Google Chat failure never prevents archiving or email from running. The Google Chat step runs in a new transaction to isolate its governor limits from the preceding callout actions.
Notification cap: To protect against floods, RFLIB sends at most 20 Google Chat notifications per flow invocation by default. Override this with the
Max_GChat_Notifications_Per_InvocationGlobal Setting (rflib_Global_Setting__mdt). Events beyond the cap are skipped for that invocation.
- Verify the Named Credential name is exactly
RFLIB_GOOGLE_CHAT_WEBHOOK(case-sensitive). - Confirm Google Chat Log Level in Logger Settings is not
NONEand matches the severity of the events you are generating (remember the WARN floor). - Check the rflib_Application_Event__c object for records with
Event_Name__c = 'rflib-google-chat-log-event-failed'— these capture failure details including HTTP status codes and exception messages. - Confirm the webhook still exists in the space's Apps & integrations → Webhooks list; deleting the space or webhook invalidates the URL.
The webhook URL in the Named Credential may be incorrect, or the webhook may have been deleted. Recreate the webhook in the Google Chat space and update the Named Credential URL.
Google Chat caps card payloads at roughly 32 KB. RFLIB caps each text block at 2,800 characters. Log messages are truncated from the beginning (not the end) so the exception at the tail is always visible, prefixing the block with [TRUNCATED]. Platform info is also truncated at 2,800 characters. This is expected behaviour for very verbose log events. Consider raising the General Log Level setting to reduce noise captured in events.
Raise the Google Chat Log Level threshold (e.g., from WARN to ERROR). You can also set a user- or profile-level override in Logger Settings to suppress Google Chat notifications for high-volume automated processes, or lower the Max_GChat_Notifications_Per_Invocation Global Setting.
- The webhook URL is a secret. Store it only in the Named Credential — never in Custom Settings, Apex code, or Custom Metadata.
- Restrict edit access to the Named Credential to System Administrators only.
- Log messages processed by RFLIB are subject to masking rules (
rflib_Masking_Rule__mdt) before the Platform Event is published, so sensitive data masked at the logger level will not appear in Google Chat. - Rotate the webhook URL periodically (recreate the webhook in the space) and update the Named Credential accordingly.
- Home - Start here for installation and learning path
- Getting Started with Logging - Start here
- Logger Settings - Configure your logging
- Getting Started with Feature Switches - Control features
- Getting Started with Application Events - Track business metrics
- Getting Started with Logging - Core logging guide
- Logger Settings - Detailed configuration
- Log Archive - Long-term storage
- Using Log Aggregation - Trend analysis
- Using the Log Timer - Performance tracking
- Masking Log Messages - Security & privacy
- Logging in OmniStudio - OmniStudio integration
- RFLIB CLI Plugin - Automation tools
- Ops Center Overview - Central monitoring hub
- Logging Dashboard - View and analyze logs
- Management Console - System administration
- Permissions Explorer - Security validation
- Application Event Dashboard - Business insights
- Getting Started with the Trigger Framework - Metadata-driven triggers
- Getting Started with Retryable Actions - Reliable async processing
- Getting Started with HTTP Mocking - Integration testing
- Node / LWR Logger - Server-side Node.js / LWR logging
- Salesforce Functions - Serverless compute (EOL — see Node / LWR Logger)
- Logging to AWS CloudWatch - Cloud monitoring
- Logging to Azure App Insights - Azure observability
- Logging to OpenTelemetry - OTLP/HTTP forwarding
- Logging to Slack - Slack integrations
- Logging to Microsoft Teams - Teams integrations
- Logging to Google Chat - Google Chat integrations
- Getting Started with Pharos - External analytics
- [Outbound Callouts including the T