Skip to content

Read a numeric zendesk_ticket_id in support bot conversations - #1744

Merged
jkmassel merged 1 commit into
trunkfrom
jkmassel/support-bot-zendesk-ticket-id
Nov 13, 2026
Merged

jkmassel merged 1 commit into
trunkfrom
jkmassel/support-bot-zendesk-ticket-id

Conversation

@jkmassel

Copy link
Copy Markdown
Contributor

Fixes BotConversation failing to parse when the server returns zendesk_ticket_id as a number.

Root Cause

zendesk_ticket_id is Option<String>, but once a conversation has a Zendesk ticket the server sends it as a number:

Response couldn't be parsed: invalid type: integer `11961779`, expected a string at line 1 column 276.

A ticket is created as soon as the first message asks for a human, so POST /odie/chat/<bot_id> fails for exactly that case. The conversation and its ticket are created on the server, but the apps show the error and give the message back, and each retry creates another ticket. Asking for a human later in a conversation isn't affected: replies go through /mobile-support/unified-conversations, whose model has no ticket field.

All 10 conversations with a ticket on the account I checked (jetpack-workflow-chat_mobile_support, back to 2026-10-28) return a number; conversations without one return null. The existing fixtures all have null, so the tests never covered it.

Both apps use this endpoint for the first message: WordPress-iOS (wordpress-rs 0.9.1) and WordPress-Android (0.10.0).

Fix

  • wp_api/src/wp_com/support_bots.rs: read zendesk_ticket_id with the existing deserialize_string_or_integer_or_null. It stays Option<String>, so the Swift and Kotlin API doesn't change, and it still reads a string or null.
  • create-conversation-response-with-ticket.json: the minimal-sources fixture with "zendesk_ticket_id": 12345678.

Test plan

  • cargo test -p wp_api --lib support_bots: 14 passed. Without the fix, test_bot_create_conversation_with_zendesk_ticket_deserialization and the number case of test_bot_conversation_zendesk_ticket_id_deserialization fail with the same invalid type: integer error.
  • Reproduced in the WordPress-iOS app (Jetpack, New Support on): a first message asking for a human shows the parse error, and the conversation and ticket exist on the server.
  • In the app with this fix: not checked yet. It needs a wordpress-rs release (or a PR build) and an app bump; I'll check it there.

The server returns `zendesk_ticket_id` as a number once a conversation
has a Zendesk ticket, which happens when the first message asks for a
human. `BotConversation` expected a string, so creating such a
conversation failed to parse: the ticket was created, but the apps
showed an error, and each retry created another ticket.

Keep the field an `Option<String>` and read it with
`deserialize_string_or_integer_or_null`, so it accepts a number, a
string or null without changing the Swift or Kotlin API.
@jkmassel jkmassel self-assigned this Nov 12, 2026
@jkmassel
jkmassel requested a review from adalpari November 12, 2026 23:27
@wpmobilebot

Copy link
Copy Markdown
Collaborator

XCFramework Build

This PR's XCFramework is available for testing. Add to your Package.swift:

.package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1744")

Built from ead379f

@adalpari adalpari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jkmassel
jkmassel merged commit 39cefd5 into trunk Nov 13, 2026
38 checks passed
@jkmassel
jkmassel deleted the jkmassel/support-bot-zendesk-ticket-id branch November 13, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants