
Summary
Key points of this document
- Necessity of consolidating notification sources of different natures into one channel
- The acceptable behavior upon failure differs for each trigger.
- Technology Stack
Overview
When trying to consolidate multiple notification sources of different natures, such as incident monitoring, budget alerts, daily summaries, and inquiry form notifications, into a single chat tool, the first question that arises is whether to put everything into one common library. In practice, it becomes clear which parts benefit from consolidation and which parts become more fragile when consolidated. Here, we organize the thinking behind that distinction.
Necessity of consolidating notification sources of different natures into one channel
As a system grows, the number of situations where you want to send notifications to a chat tool naturally increases. Incident alerts from cloud monitoring services, anomaly detection for cost budgets, daily summaries from CI pipelines, incoming messages from inquiry forms, webhook notifications set by users themselves. These are often created by different teams or at different times, and before you know it, similar "post to chat" processes tend to exist redundantly in various places.
It's natural to think, "Let's consolidate everything into one common library" when you notice duplication. However, when you actually start working on it, you realize that even though the superficial process of sending notifications is similar, the execution environment, acceptable behavior upon failure, and update frequency of each trigger are completely different. This article organizes practical examples of where we chose to commonize and where we intentionally did not.
The acceptable behavior upon failure differs for each trigger.
For operational alerts like incident monitoring, a slight delay in sending the notification itself is not fatal, but it is crucial that it is delivered reliably. On the other hand, for summary notifications running within a CI pipeline, the entire pipeline should not be marked as failed just because the notification failed. It would be counterproductive for a completed task to be labeled "failed" due to a temporary notification processing error.
The handling of the same incident occurring repeatedly also differs. For operational alerts, if notifications are sent continuously for the same incident, recipients become fatigued, so suppression is necessary. On the other hand, for periodic notifications like daily summaries, the frequency is inherently low, so a suppression mechanism itself would be an overinvestment. If you design a monolithic system based only on the commonality of "sending notifications," you cannot absorb these differences between triggers.
Technology Stack
Product features and operational alert notifications are implemented as a common TypeScript package, supporting both webhook-based and API-based posting. For API-based posting, service account authentication is used to post messages as a pre-registered bot, allowing for thread specification and advanced formatting that are difficult to handle with simple webhooks. The CI pipeline side is implemented as an independent script in a different language (Python) and does not depend on the common package.
How to draw the boundary for commonization
What we consolidated into the common package were notifications occurring within long-running application servers, specifically product features (such as webhook notifications set by users) and operational monitoring alerts. These shared a common execution environment (the same server runtime), had almost zero cost for adding dependent packages, and duplication of similar code actually occurred with each feature addition, so the benefits of commonization directly translated into development efficiency.
The common package provides plain webhook posting, posting with thread specification, API posting via service accounts, and a builder for constructing structured card-format messages. The caller only needs to pass the data representing "what to convey," without needing to be aware of the specific Google Chat payload format.
- Scope of commonization: Parts running on the same application runtime with almost zero additional cost.
- What the common package provides: Webhook posting, thread specification, API posting, card-format message builder.
Decision to keep some implementations independent
On the other hand, only CI pipeline summary notifications are intentionally kept as independent implementations, not consolidated into the common package. The reason is simple: the CI pipeline's execution environment has a completely different lifecycle from the application server (one-off script execution that starts and ends each time), and therefore uses a different language runtime.
If we were to force the use of a common package here, it would require setting up a new cross-language package distribution mechanism, or a roundabout configuration like calling a subprocess in a different language only within the CI script. Prioritizing the general principle of "consolidating duplicate code" often leads to such forced commonization.
In reality, the notification processing on the CI side is a simple process of a few dozen lines, consisting only of plain text assembly and HTTP POST. For this level of duplication, we judged that the complexity of increasing cross-language dependencies outweighed the maintainability improvements gained by commonization, and thus intentionally did not commonize it. Even for "seemingly similar processes," if the environment they operate in is different, keeping them separate can ultimately be simpler.
- CI pipeline notifications remain independently implemented due to different execution environments (language runtimes).
- If duplication is small and the cost of cross-boundary commonization is greater, do not force consolidation.
Deduplication and suppression window design
In operational alert notifications, if the same incident is detected multiple times in a short period and a new message is posted each time, the recipient's chat will be flooded with identical content. To prevent this, we calculate a deduplication key from the alert type and target resource. If an alert with the same key occurs again within a certain period, a mechanism is in place to suppress it without creating a new message.
For suppression judgment, we use a short-lived in-memory map that holds recently sent keys and their send times. We decided that in-process memory was sufficient without using persistent queues or databases because the purpose of suppression is to "prevent humans from seeing the same notification multiple times," and some loss (e.g., suppression information being reset immediately after process restart) is acceptable.
Along with suppression, related messages are grouped by a thread key. By consolidating multiple pieces of information about the same incident (detection, status update, resolution) into a single thread, even if the number of notifications increases, the conversation remains unified, making it easier to follow the history later.
- Calculate a deduplication key from alert type + target resource and suppress re-notifications within a certain period.
- Manage suppression state in process memory, avoiding the complexity of persistence.
- Group multiple notifications about the same incident by threadKey to track the history as a thread.
Manage Webhook URLs as separate secrets for each trigger
Webhook URLs and API credentials for notification destinations are not hardcoded in code or logs; they are all injected via Secret Manager. What's important here is that they are managed as separate secret items for each type of trigger. Inquiry notifications, operational monitoring, status page incident notifications, and CI pipelines each have independent secret IDs.
If they were all bundled into one secret, a member involved in the implementation of one trigger could access the notification URLs of other triggers that they don't actually need access to. By separating secrets per trigger, if you need to review permissions for a certain channel or re-issue a Webhook URL, the scope of impact can be confined to only that trigger.
Notification failures should not stop the main process.
In places where notifications are not the primary purpose of the overall process, such as CI pipelines, we strictly adhere to the principle that even if a notification fails to send, the completed work itself should not be marked as failed. In terms of implementation, all notification sending calls are wrapped in exception handling, and even if they fail, the exception is not propagated upwards; it is merely logged.
However, simply suppressing failures means no one will realize that the notification "actually didn't arrive." In CI pipelines, if a notification fails to send, an alternative recording destination is provided: a comment is left on the tracking issue for the relevant task. Even if the immediate channel of chat notification is lost, a traceable path is always preserved—a two-pronged approach.
This decision to "protect the main process even by suppressing failures" is not applied to operational alerts. This is because the delivery of operational alerts is the purpose itself, and suppressing failures risks incidents being left unaddressed without anyone noticing. Even for the same event of "notification failed," the handling needs to change depending on whether the notification is the primary purpose or a byproduct of the process.
- Notifications as a byproduct (e.g., CI summaries) do not stop the main process even if they fail. However, traces of the failure are left via an alternative path.
- Notifications that are the purpose itself (e.g., incident alerts) do not suppress failures, and the design includes confirmation of delivery.
Usage of card format vs. plain text
For operational alerts and product notifications, we use card-format messages that can display structured fields like headings, details, and action links. The decision is to prioritize human comprehension at a glance and accept the implementation cost for structuring.
On the other hand, CI pipeline notifications are intentionally kept to plain text only, with a simple implementation that truncates text at a certain character limit. This is a result of prioritizing robustness and avoiding increased dependencies over adding logic to construct card formats. The criterion is whether the cost of implementing and maintaining the notification's visual richness is appropriate for the execution environment.
Verification points: Secret inventory and validity of suppression window
As notification paths increase, it becomes harder to understand which secret is tied to which trigger and who can access it. We make it a operational checklist item to regularly inventory secrets and their uses, and not leave secrets for unused paths unattended.
The length of the suppression window is not fixed and forgotten; we continuously gather feedback during actual incident responses, such as "suppression was too effective and we missed status changes" or "suppression was too short and the same content was sent repeatedly," and adjust it. Suppression is not a set-it-and-forget-it setting, but a parameter to be nurtured through operation.
Drawbacks of consolidating into one channel
Consolidating notification channels into one risks important incident alerts being buried under routine summary notifications as the frequency of each notification source accumulates. Deduplication and threading help reduce noise but are not fundamental solutions. It becomes necessary to review the notification channel design itself, such as separating high-priority notifications into different spaces or channels, or changing mention behavior based on priority.
Also, what is a useful notification for one team might be just noise for another. A design that consolidates notifications needs to proceed not only with technical commonization but also with operational agreement on who should receive what.
Summary: Commonization is a means, not an end.
When consolidating multiple notification sources into a single chat tool, it's not always correct to combine everything into one implementation. While it's good to centralize frequently used processes in the same execution environment to reduce duplication, processes with fundamentally different execution environments or lifecycles should be kept independent rather than forcibly unified. This results in a more robust system.
The deduplication, secret separation, error handling, and format selection discussed in this article are all ingenious contrivances to change behavior according to the context of each trigger, rather than the 'sending notifications' function itself. Just as how to stop AI, not its performance, determines maintenance quality, we believe that the quality of a notification infrastructure is determined not by the breadth of commonality, but by the judgment to identify where not to centralize.


