Post new Enterprise sign-ups to Slack
Tell #sales the moment an Enterprise account signs up in PostgreSQL, once per account, with internal QA tenants filtered out. Trigger SQL and backtest included.
- PostgreSQL
- Slack
- Sales
- once per account
The trigger
One read-only SELECT against PostgreSQL. Rowfire polls it for new rows, and the rule fires once per account.
SELECT a.id AS account_id,
a.name AS account,
a.domain,
a.seats,
a.region,
a.owner_name,
a.owner_email,
a.created_at
FROM accounts a
JOIN plans p ON p.id = a.plan_id
WHERE p.name = 'Enterprise'
AND a.is_internal = falseThe clock is created_at and the key is account_id. The rule
announce_enterprise_signup fires once per account, so a plan change or a
re-import never announces the same customer twice.
A message template can use any column from the row:
New Enterprise account: {{ account }} ({{ domain }}), {{ seats }} seats in {{ region }}. Owner: {{ owner_name }}.
The query most people write first
The obvious version stops at WHERE p.name = 'Enterprise'. It looks right in
review, but internal QA tenants are Enterprise accounts too. In the demo, a
backtest of the two versions side by side over 120 days of sample data shows:
| query | posts to #sales |
|---|---|
without is_internal = false |
38 |
| with it | 26 |
That’s why a rule runs in shadow before it goes live: every request is rendered and recorded, and nothing is sent until you promote it.
For a ticket rather than a message, see declined cards to Slack and Zendesk.
Questions
Why does the query exclude internal accounts?
Internal QA tenants are on the Enterprise plan too. Without the filter, the demo's backtest posts 38 announcements over 120 days instead of 26. The example rows show which accounts make up the difference.
Will it announce accounts that signed up before the rule existed?
No. A trigger starts at now when it is first switched on, so history never fires.