Skip to content

feat(chat): add callbackUrl to buttons and modals#454

Merged
bensabic merged 24 commits into
mainfrom
josh/wf
May 8, 2026
Merged

feat(chat): add callbackUrl to buttons and modals#454
bensabic merged 24 commits into
mainfrom
josh/wf

Conversation

@dancer
Copy link
Copy Markdown
Collaborator

@dancer dancer commented May 6, 2026

summary

add callbackUrl prop to Button and Modal. when a button is clicked or modal submitted, the SDK POSTs action data to the callback URL in addition to firing existing handlers. enables awaitable button/modal patterns with webhook-based workflow engines

  • callback tokens stored server-side in state adapter (30-day TTL), only a short token goes in the platform payload
  • original button value stored alongside the callback URL in state, keeping encoded values to 21 chars across all platforms
  • works on Slack, Teams, Google Chat, WhatsApp, Telegram, and Discord
  • Discord encodes value in custom_id (100 char limit, throws ValidationError if exceeded)
  • Telegram's 64-byte callback_data limit accommodated by token-only encoding
  • callback POST runs in parallel with handler execution, awaited at the end for serverless safety
  • modal callback POST uses waitUntil to avoid blocking the submit response
  • callbackUrl processed in thread.post(), postEphemeral(), schedule(), edit(), and all channel equivalents

test plan

  • callback-url unit tests: encode/decode, processCardCallbackUrls (flat, nested sections, immutability), resolveCallbackUrl (stored, legacy format, missing), postToCallbackUrl (success, non-2xx, network error)
  • chat.test.ts integration tests: action handler decode + POST, no-value token, handlers fire alongside callback, expired/unknown token preserves raw value, modal submit POST
  • channel.test.ts: callback URL encoding on channel.post
  • discord cards.test.ts: encode/decode round-trip, validation throws on overflow, card rendering with values

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 May 8, 2026 0:17am
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 May 8, 2026 0:17am

@dancer dancer closed this May 7, 2026
@dancer dancer reopened this May 7, 2026
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 7, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​workflow@​4.2.4991008598100

View full report

@dancer dancer marked this pull request as draft May 7, 2026 16:25
@dancer dancer requested review from nandorojo and visyat May 7, 2026 16:26
Copy link
Copy Markdown
Collaborator

@visyat visyat left a comment

Choose a reason for hiding this comment

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

Looks good for the most part. The workflow example you added to the example app is very interesting – may be worth adding to the "Durable Chat Agents" guide as well. I would really like replay tests, and workflow integration tests ideally!!

@dancer dancer marked this pull request as ready for review May 7, 2026 22:04
@bensabic bensabic merged commit c1cd9b5 into main May 8, 2026
13 checks passed
@bensabic bensabic deleted the josh/wf branch May 8, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants