WordPress Lead Processing Automation with amoCRM and Telegram
Case · WordPress, amoCRM and application automation · 2026
Reconfigured the processing of applications for WordPress so that the lead is saved even before going to the page « Thank you ». amoCRM, Telegram and the sending of a commercial offer are placed in an independent queue with repeated attempts. An external service failure no longer results in the loss of an application.
Problem.
The site has already worked forms, integration with amoCRM and automatic sending of a commercial offer to the client. But the architecture had a critical point of failure: part of the further processing was associated with the old form handler and the user's transition to the « page.
If the browser closed, the connection broke or the external service did not respond temporarily, the application could not go through the entire route. However, the manager could not always determine at what stage the data was lost.
The task was not just to connect another API, but to restructure the mechanism so that First, it is guaranteed to save the lead and then perform all external actions..
New way of application
-
Interception of form on site
All WordPress target forms are processed by a single JavaScript module. When sent, a unique
JavaScript · FormData · request_idrequest_idForm fields, UTM tags, entry page, referrer and application source are collected. -
Save via WordPress REST API
The browser sends data to a separate REST endpoint. The server checks the input data and saves the application in its own WordPress table.
POST /wp-json/coolstory/v1/lead -
Go to « Thank you »
Redirect is executed only after successful preservation is confirmed. The gratitude page is no longer involved in the transfer of data to CRM and is not part of the critical application path.
DB saved → success → /thanks/ -
Commercial offer
If the client has specified email, the system separately sends a HTML letter with the offer and the necessary PDF materials. The set of investments is determined by the category of the application.
SMTP · HTML email · PDF -
Transmission to amoCRM
After processing the commercial offer, the application is synchronized with amoCRM. The system looks for an existing contact, analyzes related transactions and then decides to create a new one.
amoCRM API v4 · contacts · leads -
Notification in Telegram
Telegram operates as an independent notification channel. The Telegram error does not block the saving of an order, sending a commercial offer or the operation of CRM.
Telegram Bot API · async delivery
What happens when you reapply
Customer search
The phone is brought to a normalized appearance. Contact is first sought by phone, then the exact email is used if necessary.
No extra deals.
If a contact already has an active transaction, a new transaction is not automatically created. Information on the re-application is added to the existing one.
New client
If there is no suitable active transaction, the appeal is created in a configured amoCRM funnel with the source, form, city and responsible manager.
Protection against doubles
- request_id — each form submission receives a unique identifier
- unique — repeat request with the same identifier does not create a second lead
- fingerprint applications — additional protection against fast re-sending
- amoCRM — Existing contact and active transaction are verified before new entities are created
- offer — receives status after successful shipment
sentand does not re-send the usual passage of the queue
queue instead of synchronous shipment
The main architectural change of — is that external services are no longer involved in saving the application itself. WordPress accepts the lead quickly, and further delivery is performed by the queue.
Commercial offer
There's email.The letter is sent to the client and receives the status sent.
No emailStage gets status skipped It does not block CRM.
SMTP errorThe error text and the number of attempts for reprocessing are saved.
amoCRM and Telegram
amoCRMProcessed after the completion of the commercial offer stage.
TelegramIt works independently of mail and CRM.
CronRegularly starts the processor of accumulated and erroneous tasks.
Commercial offer
The old letter sending from the form handler was moved to a separate service. Existing prices, texts and PDF materials have been retained, but the sending itself is now controlled by a queue.
For different directions, your own set of materials is automatically selected: kindergarten, grade 4 or 9–11 classes. The letter is designed in HTML in the style of the site and contains a commercial offer along with the attached PDF.
The result of sending is recorded directly from the application: status, time of successful delivery, number of attempts and the last error.
Integration with amoCRM
Search and comparison
Telephone.The number is normalized before searching.
EmailIt is used as an additional customer ID.
Deals.Existing contacts are checked so that repeated treatment does not produce duplicates.
Creation of treatment
SourceCRM transmits the Cool-story source.
FormThe name of the specific form of the site is retained.
RegionThe application city is transferred to the corresponding field amoCRM.
ResponsibleA new deal is immediately assigned to a configured manager.
UTM and source of application
Marketing data is kept separate from external integrations. The system captures UTM parameters, URL pages with the form, the original landing page and referrer.
UTM tags are stored in the browser and can be transferred with the application even when the user has moved to another page of the site before filling out the form.
Monitoring status
Each external channel has its own state. This distinguishes a « application from a specific technical problem such as the temporary unavailability of SMTP, Telegram or amoCRM.
Proposal
pending, sent, error or skippedTime to send, number of attempts and last error.
amoCRM
Synchronization status, identifiers of created entities and diagnostic information are stored.
Telegram
A separate delivery status allows you to repeat the notification regardless of CRM and email.
Architecture
WordPress
FrontendA single JavaScript interceptor of existing forms.
REST APIAccepts and validates applications.
MySQLThe application is kept pending any external requests.
CronStarts asynchronous queue processing.
External services
amoCRM API v4Contacts, transactions, user fields and notes.
SMTPHTML-commercial offer and PDF-investment.
Telegram Bot APIPrompt notification of new applications.
Safety and fault tolerance
- The application is saved until external API is contacted.
- Integration secrets are not transferred to JavaScript
- Service endpoint queue is protected by a separate key
- Error of one external service does not result in loss of lead
- Repeated attempts are performed only for unfinished operations
- Successfully sent commercial offer is not resent by routine queue start
- Telegram, mail and amoCRM have independent delivery statuses.
The result
Critical dependence on the page « Thank you » eliminated. Now the main fact is the entry of the application in the WordPress database. Only then does the interface report success and move the visitor further.
The commercial offering, amoCRM and Telegram are separate processing steps. A temporary SMTP or API error no longer means a loss of the client: the system knows the status of each step and can repeat the unfinished operation.
As a result, the conventional form of WordPress has evolved into a small fault-tolerant lead processing system with its own storage, deduplication, queue and controlled integration with CRM.
WordPress · PHP · JavaScript · REST API · MySQL · amoCRM API v4 · Telegram Bot API · SMTP · Cron · Queue · Idempotency
