Skip to content

Vapi SDK event schema#33

Closed
sahilsuman933 wants to merge 2 commits intomainfrom
cursor/vapi-sdk-event-schema-3b96
Closed

Vapi SDK event schema#33
sahilsuman933 wants to merge 2 commits intomainfrom
cursor/vapi-sdk-event-schema-3b96

Conversation

@sahilsuman933
Copy link
Contributor

Fix JSON parsing errors by adding missing client-side event types and making AppMessage.MessageType gracefully handle unknown event types.

The SDK previously failed to decode AppMessage when the server sent an event type not explicitly defined in the AppMessage.MessageType enum, leading to "The data couldn't be read because it isn't in the correct format" errors. This PR introduces a custom Codable implementation for AppMessage.MessageType to allow for unknown event types, preventing parsing failures, and adds models for all currently missing event types from the API schema.


Open in Web Open in Cursor 

cursoragent and others added 2 commits March 1, 2026 04:43
Add AnyCodable helper for decoding unstructured JSON payloads.
Add ToolCall, ToolCallFunction, ToolCallList for tool-calls events.
Add ToolCallResult for tool-calls-result events.
Add TransferUpdate and TransferDestination for transfer-update events.
Add LanguageChangeDetected for language-change-detected events.
Add WorkflowNodeStarted for workflow.node.started events.

Co-authored-by: Sahil Suman <sahilsuman933@users.noreply.github.com>
The SDK was failing to parse messages with types not in the
AppMessage.MessageType enum (e.g. assistant.started, tool-calls,
transfer-update). This caused JSON decoding errors like:

  Error parsing app message: The data couldn't be read because it
  isn't in the correct format.

Changes:
- Replace String-backed enum with custom Codable implementation that
  maps raw type strings to cases and falls back to .unknown(String)
  for any unrecognized types, preventing parsing failures.
- Add 13 missing event types from the api.vapi.ai/api-json schema:
  assistant.started, workflow.node.started, tool-calls,
  tool-calls-result, transfer-update, language-change-detected,
  chat.created, chat.deleted, session.created, session.updated,
  session.deleted, call.deleted, call.delete.failed
- Add corresponding Event enum cases and switch handlers in the
  message processing pipeline.
- Update SwiftUI example to use default case for forward compatibility.

Co-authored-by: Sahil Suman <sahilsuman933@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Mar 1, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

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.

2 participants