Skip to content

feat(whatsapp): read routing roles and keep ownership on partner template echoes - #1668

Merged
viethung0o0 merged 2 commits into
mainfrom
feat/whatsapp-routing-roles
Nov 8, 2026
Merged

viethung0o0 merged 2 commits into
mainfrom
feat/whatsapp-routing-roles

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Summary

Aligns WhatsApp Conversation Routing with Meta's partner guides: a partner's template no longer takes our thread, Meta's non-owner send rejection is recognised, and each number now shows the routing roles Meta assigned to this app.

Changes

  • whatsapp: a partner's template echo on standby is stored but no longer flips the thread to standby (templates never change ownership); a free-form echo still does
  • whatsapp: Meta error 131070 (Service send without ownership) is a permanent refusal: no retry, the thread is marked standby and the composer locks
  • whatsapp: GET /{phone_number_id}/routing_roles client; every thread_control call logs Meta's request_id or fbtrace_id
  • database: IntegrationWhatsapp.routingRoles snapshot ({ enabled, roles, isStandby, checkedAt }), stored only when newer than what is already there
  • business: syncRoutingRoles / findRoutingRoles / findRoutingRolesByInbox on the WhatsApp integration service
  • builder: "Your routing roles on this number" section with Check again on the WhatsApp settings card; the locked composer disables Take over up front when the stored roles say this app is not the escalation partner
  • public API / CLI: whatsappChannels.getRoutingRoles and whatsappChannels.syncRoutingRoles (whatsapp-channels routing-roles list|sync)
  • tests: signed fake-webhook chain suite replaying the Meta partner scenarios (SC-1…SC-7, E-1…E-7, T-1…T-7) through the real handler and worker against a throwaway database

Test plan

  • pnpm lint
  • pnpm check-types
  • pnpm test and pnpm --filter worker test:db (new: whatsapp-conversation-routing.chain, conversation-routing-api, error-mapper-thread-control, integration-whatsapp-routing-roles.service, routing-roles-section)
  • Review the migration 20261108054403_whatsapp_routing_roles before applying it
  • Manual: WhatsApp number → Settings → Check again shows the roles set in Meta Business Suite; on a standby thread, Take over is disabled when the number is not the escalation partner
  • Live run with two business portfolios per Meta's Partner Testing Scenario Guide before relying on routing in production

@github-actions github-actions Bot added the feature New feature or request label Nov 8, 2026
@viethung0o0
viethung0o0 marked this pull request as ready for review November 8, 2026 08:23
@viethung0o0
viethung0o0 force-pushed the feat/whatsapp-routing-roles branch from cbc5416 to 3b644d0 Compare November 8, 2026 08:24
@viethung0o0
viethung0o0 merged commit 0c91294 into main Nov 8, 2026
14 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants