Chapter 8
For your technical team
Two pieces connect Klosr to your systems: your payment platform tells Klosr when a deposit is paid, and your WhatsApp Business number carries the agent's chats. Both belong to your organization: Klosr never holds the money, and Meta bills your own account.
The payment webhook
In the panelSettingsPaymentsPayment settingsNew webhook secret
Klosr sends each buyer a link to your own payment page. When they pay, your platform calls Klosr's webhook, and Klosr marks the deposit paid, reserves the unit and tells the lead.
- In Settings > Payment settings, an admin presses New webhook secret. It shows the webhook address and the secret once: copy both somewhere safe.
- Make the link template point at your payment page, with the slots below.
- Have your platform call the address when a payment succeeds or fails, as described below.
A new secret replaces the old one at once: calls signed with the old secret are refused from then on.
The payment link
The link template can use these slots. Klosr fills them for each deal:
| Slot | Filled with |
|---|---|
{reference} | The deal's own reference. Required: send the same value back in the webhook, or Klosr cannot find the deal. |
{amount} | The deposit, from your deposit rule. |
{currency} | The project's currency, such as SAR. |
{unit_code} | The held unit, such as B-0703. |
{project} | The project's name. |
{lead_ref} | Klosr's number for the lead, such as L123: no personal details. |
https://pay.example.com/checkout?ref={reference}&amount={amount}¤cy={currency}&unit={unit_code}
The call Klosr expects
POST a JSON body to the address, signed with HMAC-SHA256 of the raw body and your secret, in this header:
X-Klosr-Signature: sha256=<hex digest>
{
"event_id": "unique-per-event",
"type": "paid",
"reference": "the {reference} from the link",
"amount": "10000.00",
"currency": "SAR",
"unit_code": "B-0703",
"payment_reference": "your platform's transaction id",
"paid_at": "2026-11-06T09:30:00Z"
}
typepaid,failedorpage_opened(the buyer opened your payment page).- Required
event_id,typeandreference, as strings. Forpaid, alsoamountandcurrency, unless the deposit rule is "Set on the payment page": then send them if you have them, and Klosr keeps the amount.unit_code- Send it when the buyer can pick the unit on your page. If it differs from the held unit, the deal moves to the unit paid for, in the same project: that unit is reserved and the held one goes back on sale.
event_id- Unique per event. A repeated
event_idgets the same answer and changes nothing, so retries are safe.
Klosr's answers
| Answer | Means |
|---|---|
204 | Received. Also the answer to a repeated event_id. |
403 | Wrong signature, or an unknown address. |
422 | A required field is missing. |
Some payments need a person, and Klosr gives your team a task for each:
- An amount below the deposit, or another currency, does not mark the deal paid.
- A
unit_codethat is taken, or that matches no single unit, still counts as paid; someone sorts out the unit. - A payment after the hold ended still counts. If the unit went to another buyer meanwhile, someone refunds the deposit or offers another unit.
WhatsApp setup
In the panelSettingsChannelsConnections
Klosr uses Meta's WhatsApp Cloud API directly, with no reseller. Your organization brings its own Meta Business account, phone number and secrets, so Meta bills your account. Allow a few days: Meta's business verification can take longer.
Before you start, agree three things inside your organization:
- A path to a person. WhatsApp's policy asks that automation offers a prompt, clear way to reach a human. Keep escalations on, and your team watching Conversations.
- Selling your own units only. Meta's terms do not allow AI as the main thing offered on WhatsApp. The agent sells your units to your buyers; keep it to that.
- Opt-in. Klosr sends marketing templates only to leads marked opted in. Meta asks that they agreed to hear from your business by name.
Part 1: at Meta
- Create or open your Meta Business account at business.facebook.com.
- Start business verification under Security Centre. Until it is done, the account reaches only 250 people in 24 hours.
- Get a phone number that is not on the WhatsApp app. To move a number that is, delete its WhatsApp account first.
- At developers.facebook.com, create an app of type Business and add the WhatsApp product. Connect your WhatsApp Business Account and add the number.
- Add a payment method in WhatsApp Manager. Meta charges for service replies beyond its monthly free allowance.
- Make a permanent token: Business settings > Users > System users > Add; then Add assets (the app and the WhatsApp account, full control); then Generate new token with
whatsapp_business_messagingandwhatsapp_business_management. - Switch the app to Live mode.
- Note four things: the Phone number ID and the WhatsApp Business Account ID (WhatsApp > API Setup), the App secret (App settings > Basic), and the token.
Part 2: connect it in Klosr
- In Settings > Channels, press New channel connection, choose WhatsApp, paste the four things and save. A token or secret saved here is never shown again: leave the field empty later to keep it.
- Open the connection with Edit. Copy the Callback URL and the Verify token.
- At Meta: your app > WhatsApp > Configuration > Webhook > Edit. Paste both, then Verify and save.
- On the same page, under Webhook fields, subscribe to
messagesanduser_preferences. - Back in Klosr, open the connection's WhatsApp menu and press Connect. It shows your number when the token works.
- If Meta answers that the number is not registered (error 133010), register it once, choosing any six digits as the PIN and keeping them:
curl -X POST "https://graph.facebook.com/v27.0/PHONE_NUMBER_ID/register" \
-H "Authorization: Bearer TOKEN" -H "Content-Type: application/json" \
-d '{"messaging_product":"whatsapp","pin":"123456"}'
- Press Submit templates in the same menu. Klosr submits its message templates, in English and Arabic, to your account. Once Meta has reviewed them, press Sync templates: it says how many are approved, and the connection's page lists each with its status. Sync again after any change at Meta.
- Turn on Default channel for this organization, so leads hear from WhatsApp first.
Klosr turns WhatsApp on for your organization with you. Until then, messages to the number are answered and thrown away, and nothing is sent.
Part 3: try it on your own phone
Put your own numbers in WhatsApp test numbers (Settings > General), with the country code and digits only. While the list holds numbers, nobody else reaches the agent on WhatsApp. Then, from your phone:
- Write to the business number. The agent answers, and the chat appears in Conversations with two ticks, then two blue ones when you read it.
- Send an Arabic voice note: it is written out on the lead's timeline and answered.
- Add yourself as a test lead, marked opted in, and send a first WhatsApp message from the lead's page. Tap the buttons in it: the agent answers. Tap Stop: you are marked opted out, and nothing more comes.
When it all works, empty the test numbers. Start with a small batch of leads, and watch your quality rating in WhatsApp Manager.
If something goes wrong
| What you see | What it means | What to do |
|---|---|---|
| Meta will not verify the webhook | The URL or the verify token differs, or the connection is not active | Copy both again from the connection's page. |
| Messages reach Meta but not Klosr | messages is not subscribed, the number is not on the test list, or WhatsApp is not on yet | Check those three. |
| Sends fail with code 190 | The token expired or was revoked | Make a new one and paste it on the connection's page. |
| Failed with code 131026 | The number is not on WhatsApp, or the app is very old | Nothing to do. |
| Failed with code 131049 | Meta held back a marketing message to protect the person | Do not resend for 24 hours. |
| Failed with code 131050 | The person stopped marketing messages | Klosr stops marketing to them; service messages still go. |
| Code 131048 or 368 | Meta has limited the account | Stop sending first messages and check WhatsApp Manager > Account quality. |
| A template shows a problem | Paused by Meta, or changed at Meta | Fix it at Meta, then Sync templates. |
To stop everything at once, use Stop the agent in Conversations: no reply and no template goes out until it is started again.