iachat/spec
Shivam Mishra e4c3f0ac2f
feat: fallback on phone number to update lead (#13910)
When syncing contacts to LeadSquared, the `Lead.CreateOrUpdate` API
defaults to searching by email. If a contact has no email (or a
different email) but a phone number matching an existing lead, the API
fails with `MXDuplicateEntryException` instead of finding and updating
the existing lead. This accounted for ~69% of all LeadSquared
integration errors, and cascaded into "Lead not found" failures when
posting transcript and conversation activities (~14% of errors).

## What changed

- `LeadClient#create_or_update_lead` now catches
`MXDuplicateEntryException` and retries the request once with
`SearchBy=Phone` appended to the body, telling the API to match on phone
number instead
- Once the retry succeeds, the returned lead ID is stored on the contact
(existing behavior), so all future events use the direct `update_lead`
path and never hit the duplicate error again

## How to reproduce

1. Create a lead in LeadSquared with phone number `+91-75076767676` and
email `a@example.com`
2. In Chatwoot, create a contact with the same phone number but a
different email (or no email)
3. Trigger a contact sync (via conversation creation or contact update)
4. Before fix: `MXDuplicateEntryException` error in logs, contact fails
to sync
5. After fix: retry with `SearchBy=Phone` finds and updates the existing
lead, stores the lead ID on the contact
2026-03-26 12:32:27 +05:30
..
actions fix: Skip redundant contact saves in ContactIdentifyAction (#13778) 2026-03-11 21:40:38 -07:00
assets feat: Move email attachments from links to file attachments (#11304) 2025-04-15 23:43:12 -07:00
builders fix: Handle Facebook reel attachment type (#13691) 2026-03-06 08:49:41 +04:00
channels fix: Move contact events to account stream rather than individual user stream (#11082) 2025-03-13 17:46:48 -07:00
config feat: update bunny video support in HC (#13815) 2026-03-16 11:04:27 +05:30
configs chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
controllers feat(platform): Add email channel migration endpoint for bulk OAuth channel creation (#13902) 2026-03-25 15:58:08 -07:00
dispatchers Non blocking event dispatch (#652) 2020-03-29 19:18:30 +05:30
drops feat: Add the support for custom attributes in message variables (#8511) 2023-12-08 14:13:35 -08:00
enterprise feat: allow captain to access contact attributes (#13850) 2026-03-20 16:15:06 +05:30
factories feat(dialogflow): make language_code configurable instead of hardcoded (#13221) 2026-03-25 21:30:17 -07:00
finders perf: skip conversation loading in /meta endpoint (#13564) 2026-02-20 21:20:19 +05:30
fixtures feat: Add BE changes for captain pdf support for faq generation (#12113) 2025-08-27 20:31:22 +05:30
helpers chore: Refactor UTM params to stay compliant with standards (#12312) 2025-08-29 11:46:52 -07:00
integration Fix url in emails, add frontendURL helper (#19) 2019-08-25 19:59:28 +05:30
jobs feat: distributed scheduling for version check job (#13042) 2026-03-17 02:27:49 -07:00
lib feat(dialogflow): make language_code configurable instead of hardcoded (#13221) 2026-03-25 21:30:17 -07:00
listeners feat(rollup): add models and write path [1/3] (#13796) 2026-03-19 13:12:36 +05:30
mailboxes feat(CW-6187): include headers from incoming emails (#13139) 2026-01-07 12:45:54 +05:30
mailers fix(email): Allow inbox OAuth replies without global SMTP (#13820) 2026-03-17 11:10:42 +04:00
models fix: Annotaterb model annotation incomplete migration (#13132) 2026-03-25 17:51:06 -07:00
policies chore: Enforce custom role permissions on conversation access (#12583) 2025-10-22 20:23:37 -07:00
presenters fix: Send raw content in webhook payloads instead of channel-rendered markdown (#13896) 2026-03-25 16:56:22 +04:00
requests/api/v1 feat: APIs to assign agents_bots as assignee in conversations (#12836) 2025-11-18 18:20:58 -08:00
services feat: fallback on phone number to update lead (#13910) 2026-03-26 12:32:27 +05:30
support feat: Advanced Search Backend (#12917) 2026-01-07 15:30:49 +05:30
swagger feat: validate OpenAPI spec using Skooma (#13623) 2026-03-10 18:33:55 -07:00
coverage_helper.rb ci(circleci): switch coverage reporting to Qlty orb (#12337) 2025-08-31 00:39:34 +05:30
rails_helper.rb feat: validate OpenAPI spec using Skooma (#13623) 2026-03-10 18:33:55 -07:00
spec_helper.rb ci(circleci): switch coverage reporting to Qlty orb (#12337) 2025-08-31 00:39:34 +05:30
test_helper.rb ci(circleci): switch coverage reporting to Qlty orb (#12337) 2025-08-31 00:39:34 +05:30