Auto-reply to messenger requests with queuing and payment: wiring an n8n bot, a spreadsheet and a payment webhook in one evening

Picture a one-person shop selling custom cakes. Orders arrive in Telegram at 11 p.m., while the owner is asleep. By morning there are six unread chats, two people have already bought elsewhere, and one transfer sits in the bank app with no name attached to it. Nothing here is a technology problem — it is a bookkeeping problem that a bot, a spreadsheet and a payment webhook solve in one evening.

By the end of that evening you will have this: a customer messages the bot, answers three questions, and gets an order number. The order appears as a row in a spreadsheet with the status new. When the payment provider's webhook fires, that same row turns to paid and the customer receives a confirmation in the chat. You will see it work without opening the code — the spreadsheet is your dashboard.

This is not a chatbot project. It is a small request-processing system with three outside dependencies (Telegram Bot API, a spreadsheet, a payment provider) and one piece of logic in the middle. That framing matters, because almost every failure in this build comes from the outside systems, not from the logic.

What you are actually building, and what "done" looks like

Three moving parts, one queue:

  1. Intake. The Telegram bot asks a fixed set of questions and collects answers. The Telegram Bot API is what your automation tool talks to; you do not host the bot server yourself if you use a platform like n8n.
  2. Queue. Every finished request becomes a row in a spreadsheet: order id, timestamp, Telegram user id, the answers, and a status column. The status column is the queue — new, paid, done, cancelled.
  3. Payment. The provider calls your webhook URL when money arrives. The webhook finds the row by order id and flips the status.
From a late-night message to a paid row: the three handoffs that must not lose the order
1
Telegram bot
collects answers, assigns order id
2
Spreadsheet queue
row with status new
3
Payment webhook
matches order id, checks amount, flips to paid
4
Confirmation
sent once, idempotent

"Done" is not "the bot replied". Done is: you place a test order, the row appears with new, you pay with a test card, the row becomes paid within seconds, and the confirmation lands in the chat. If any of those four does not happen, the build is not finished.

The spreadsheet is doing more work than it looks. It is your database, your admin panel and your audit log at once. That is why the status column must be edited only by the automation — the moment a human starts typing statuses by hand, you lose the ability to trust the row.

Before you write a single node: the access you need

Most of the evening is lost here, not in the logic. Collect these first.

What Where it comes from What can go wrong
Bot token @BotFather in Telegram, /newbot Token leaked into a screenshot or a public repo — revoke and reissue
Spreadsheet with edit access Your own Google account or equivalent Sharing the sheet with the automation's service account, not your personal login
Payment provider webhook secret Provider dashboard, API/webhook section Some providers sign the payload, some do not — check the docs before assuming
Public URL for the webhook Your automation platform's webhook node The URL must be reachable from the internet, not localhost

A few honest limits. If your payment provider has no webhook and only sends email receipts, this build cannot close the loop automatically — you would need to poll a statement or accept manual status changes. If your spreadsheet tool has no API in your plan tier, the queue has to live somewhere else. Both are worth checking before you start, because they change the shape of the project, not just a setting. More on the topic: “AI for Professionals: Automating Your Own Work End to End — An Advanced Program for Professionals Who Want to Stop "Trying ChatGPT" and Start Saving Hours”.

The token is the whole bot Anyone with the bot token can read and send messages as your bot. Keep it in the automation platform's credential store, never in a node's plain text field, and rotate it the moment it appears in a screenshot or a chat.

The build, step by step, with an owner for each step

The division of labour is simple: the AI writes the boring, verifiable parts — node wiring, the sheet schema, the handler that parses the webhook body. The human owns anything that touches money, identity or the outside world. A step without a check is not done.

Step 1. The sheet schema — AI drafts, you approve

Ask the AI for a table schema with these columns: order id, created at, Telegram user id, customer name, request text, amount, status, payment reference, updated at. It will produce something reasonable in seconds.

Your job is to decide the rules the AI cannot guess:

  • Order id format. Something short and unique, like a date prefix plus a counter. It goes into the payment description, so the customer will see it.
  • Status vocabulary. Fix it now: new, awaiting_payment, paid, done, cancelled. Free-text statuses are how queues die.
  • Who may edit status. Only the automation. Humans add notes in a separate column.

Check: create three fake rows by hand and confirm the sheet rejects a duplicate order id (use data validation or a unique constraint if your tool has one).

Step 2. The bot conversation — AI writes, you test the edges

The AI generates the n8n flow: a Telegram trigger, a switch on the current step, and a write to the sheet at the end. The Telegram Bot API side is well documented, so this part is usually correct on the first pass. More on the topic: “Telegram Bot Development: What to Know Before You Start with aiogram, FSM and Payments”.

The human checks what the AI tends to skip:

  • What happens if the customer sends a photo instead of text mid-conversation?
  • What happens if they send /start again halfway through?
  • Does the flow store the conversation step per user, or does it assume one user at a time?

That last one is the classic beginner bug. If the step is kept in a single variable rather than keyed by Telegram user id, two customers chatting at once will overwrite each other's progress.

Check: open two Telegram accounts, start the conversation in both, and interleave the answers. Each order must land in its own row with its own answers.

Step 3. The payment link and the webhook — AI scaffolds, you own the money

The AI can generate the webhook node, the JSON parsing and the sheet update. What it cannot do is know your provider's payload. Open the provider's documentation and confirm the exact field names for the order reference, the amount and the signature header. Do not let the AI guess these — a guessed field name means a webhook that silently matches nothing.

Two things the human must decide:

  • Amount check. The webhook amount must equal the amount stored in the row. If they differ, do not flip to paid — flag the row for review.
  • Idempotency. The same webhook will arrive more than once. That is normal, not a bug. The handler must be safe to run twice: look up the row, and if the status is already paid, exit without sending a second confirmation.
The webhook is the only place money enters your system Treat every incoming webhook as untrusted until the signature is verified and the amount is matched against the row. If the provider signs payloads, verify the signature before reading any field.

Step 4. The confirmation message — AI writes, you read it as a customer

The AI will produce a perfectly grammatical confirmation. Read it as the customer: does it contain the order id, the amount actually charged, and what happens next? A confirmation that says "Payment received" and nothing else generates a support message.

Check: the message must state the order id and the amount. If the amount in the message is hardcoded rather than read from the row, you have found a bug the AI introduced.

Where this build breaks, and what to do about each

These are the three that actually bite in production, in rough order of how often they appear.

Repeated webhooks. Providers retry on timeouts, and a slow response from your automation looks exactly like a failure. The result is a second delivery of the same payment event. Without an idempotency check, the customer gets two confirmations and the sheet gets a second paid write. Fix: read the current status first, exit early if it is already paid, and store the provider's event id in a column so you can see duplicates in the log.

Lost conversation state. If the automation platform restarts mid-conversation, or the step is stored in memory, the customer is left answering a question the bot no longer remembers asking. Fix: store the step in the sheet (or a keyed store) next to the user id, and add a /start handler that resets cleanly. Test it by restarting the workflow in the middle of a conversation.

Timeouts on the payment side. If your webhook handler does heavy work before responding — sending messages, writing several rows — the provider may time out and retry, which feeds straight into the duplicate problem. Fix: acknowledge the webhook quickly, then do the sheet update and the Telegram message. Keep the handler short.

Test with the provider's test mode, not a real card Most payment providers offer a sandbox or test mode that sends real webhooks with fake money. Use it for every iteration, and do exactly one live low-value payment at the very end to confirm the production credentials.

How to prove it works on a real scenario

Run these by hand, in this order. Each has a success sign you can see without reading logs.

  1. Happy path. New Telegram account, place an order, pay in test mode. Success: one row, status paid, one confirmation in the chat, amount matches.
  2. Duplicate delivery. Resend the same webhook from the provider dashboard (most test tools allow it). Success: status stays paid, no second confirmation is sent.
  3. Two customers at once. Two accounts, interleaved answers. Success: two separate rows, correct answers in each.
  4. Abandoned conversation. Start an order, close Telegram, return an hour later. Success: the bot either resumes correctly or restarts cleanly — it never hangs waiting for a step it lost.
  5. Wrong amount. Send a test webhook with a different amount. Success: the row is not marked paid; it is flagged for review.

If all five pass, the build is done. If step 2 or 5 fails, do not ship — those are the two that cost money.

What it costs you, honestly

The order of magnitude is one evening for someone comfortable with a visual automation tool, and a full day for someone learning it. The breakdown depends on three things: whether your provider documents the webhook payload clearly, whether your spreadsheet tool's API is available on your plan, and how many edge cases you are willing to leave untested.

Money-wise, the recurring cost is the automation platform plan and the spreadsheet plan, both of which scale with the number of executions per month. For a small shop the volume is low; for a business taking hundreds of requests a day, the platform tier becomes the real line item. Check current pricing on both — do not build a budget on a number someone quoted you a year ago. More on the topic: “Low-Code / No-Code Platforms: No-Code Business Automation — Where It Breaks and How to Avoid the Pitfalls”.

The hidden cost is maintenance. Statuses drift, providers change payload fields, and the person who built it moves on. Keep the sheet schema documented in one page next to the workflow.

If the evening turns into a week — the provider has no clear docs, the spreadsheet API is locked, the payment flow needs refunds — it is reasonable to hand the whole thing over rather than fight it alone.

The build is only as good as its idempotency If you take one thing from this article: the webhook handler must be safe to run twice. Everything else is recoverable by hand; a double payment confirmation is not.

asibiont.com takes such projects on turnkey: the developer names the price, the client pays it by topping up the balance — which is a sensible option when the queue, the payment webhook and the confirmations need to be right the first time. You can see how that works on the subscription tiers page.

The real measure of this build is not that the bot replies. It is that months from now, when someone asks "did this customer pay?", you open one spreadsheet, find one row, and the answer is there — without scrolling through a chat and a bank statement trying to match them up.

If you want the same project built and handed over, the developer names the price and you top up the balance — details on the same subscription tiers page.

AssetMaterials for this article

A document from this article — download and apply it.

  • XLSXOrder Pipeline Verification Checklist Telegram → Spreadsheet → Payment Webhook.xlsxXLSX · 9.4 KBDownload
← All posts

Ask AI about this article

Ask a question about this article — ASI Biont will answer based on its text and the attached files.