See llms.txt for all machine-readable content.

Back to Templates

Gate Telegram bot access with Stripe, Slack alerts, and daily reconciliation

Created by

Created by: Jessy Mariau || fractional-hq
Jessy Mariau

Last update

Last update 12 hours ago

Categories

Share


Quick overview

Most Stripe-and-bot setups catch the webhook, flip a flag, and quietly drift out of step with what people actually paid for. This one reads live subscription status every morning, compares it to the access it granted, and corrects anything that no longer matches.

How it works

  1. Triggers on Stripe webhook events for checkout completion, subscription updates, and subscription deletions.
  2. Checks a Data Table ledger to skip Stripe events that have already been processed, then records new event IDs to enforce idempotency.
  3. Extracts the Telegram user ID and subscription details from Stripe metadata, maps the Stripe Price ID to a tier, and marks the user as active or inactive based on the event type.
  4. Upserts the user’s entitlement (tier, active flag, and Stripe IDs) into a Data Table keyed by Telegram user ID.
  5. Runs daily on a schedule, reads all entitlement rows, fetches each subscription’s live status from the Stripe API, and detects mismatches using a configurable grace period for past-due statuses.
  6. Updates drifted entitlement rows to match Stripe and posts a summary of the corrections to a Slack channel.
  7. Triggers on incoming Telegram messages, looks up the sender’s entitlement in the Data Table, and either sends the protected message or replies with a Stripe Payment Link prompt.

Setup

  1. Add Stripe credentials for the Stripe Trigger and an HTTP Bearer Auth credential with your Stripe secret key for the Stripe subscription lookup request.
  2. Create two n8n Data Tables (one for entitlements and one for processed Stripe event IDs) and replace the placeholder table IDs in all Data Table steps.
  3. Add your Telegram bot credentials and ensure your Stripe checkout sets a telegramUserId in Stripe Customer or Checkout Session metadata so events can be linked to Telegram users.
  4. Set your Stripe Price ID→tier JSON mapping in both settings blocks, update the Stripe Payment Link URL and bot messages, and choose the Slack channel (and Slack credentials) for drift reports.