docs(websockets): fix event type check for incoming messages - #208
Open
DigitalVeer wants to merge 1 commit into
Open
docs(websockets): fix event type check for incoming messages#208DigitalVeer wants to merge 1 commit into
DigitalVeer wants to merge 1 commit into
Conversation
tldr; the WebSockets documentation incorrectly checks `event.type` for the value `"message_received"`
---
Right now, the WebSockets documentation checks if `event.type` equals `"message_received"`. In contrast, the API and SDK send `type: "event"` with `event_type: "message.received"`. This example code runs fine, but as a side effect ends up skipping incoming email events since the event branch is never reached.
This PR updates the code examples, doc comments, and overly strict type annotations across the WebSockets overview.
---
### Comparison
* What the WebSocket Docs check:
```js
if (event.type === "message_received") { ... }
```
* What the server actually sends:
```json
{ "type": "event", "event_type": "message.received", ... }
```
### Changes
1. Fixed five checks across code and documentation to correctly use `event.type === "event" && event.eventType === "message.received"`.
1. Removed annotations on message handler to remove compilation errors.
1. Corrected the Message Properties table and code to use the correct `from`.
1. Removed two unused `AgentMail` imports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tldr; the WebSockets documentation incorrectly checks
event.typefor the value"message_received".The WebSockets overview checks if
event.typeequals"message_received". However, the server and SDK actually emit{ type: "event", event_type: "message.received" }.As a result, the example code ends up skipping incoming email events since that branch is not executable.
This PR updates the code examples, doc comments, and overly strict type annotations across the WebSockets overview.
Comparison
What the WebSocket Docs check:
What the server actually sends:
{ "type": "event", "event_type": "message.received", ... }Changes
event.type === "event" && event.eventType === "message.received".from.AgentMailimports.