-
Notifications
You must be signed in to change notification settings - Fork 5.5k
OpenPhone — new message received trigger #16257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis PR implements several version bumps and minor refactorings across the OpenPhone integration. It updates version numbers in action and source modules, revises the method signature of Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant OpenPhoneApp
Client->>OpenPhoneApp: createWebhook({ webhookType, ...opts })
OpenPhoneApp->>API: POST /webhooks/{webhookType} with opts
API-->>OpenPhoneApp: Response
sequenceDiagram
participant Webhook
participant NewMsgSource
Webhook->>NewMsgSource: Incoming message payload
NewMsgSource->>NewMsgSource: getEvent() extracts event types
NewMsgSource->>NewMsgSource: getSummary() prepares summary
NewMsgSource-->>Webhook: Process event data
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/openphone/actions/create-contact/create-contact.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/openphone/actions/send-message/send-message.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/openphone/sources/common/base.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
components/openphone/sources/common/base.mjs (1)
58-64: 💡 Verification agent🧩 Analysis chain
Verify timestamp field compatibility with message events
The current
runmethod usesbody.data.object.completedAtfor the timestamp when emitting events. This works for call events, but message events (based on the test-event.mjs) usecreatedAtinstead ofcompletedAt.Please ensure that the new message received component either:
- Overrides this method to use the correct timestamp field, or
- Modifies this base implementation to handle both types of events
🏁 Script executed:
#!/bin/bash # Check if there's a file for the new message trigger component and if it overrides the run method find components/openphone/sources/new-message-received-instant -name "*.mjs" | xargs grep -l "async run" || echo "No run method override found"Length of output: 173
Action Required: Adjust Timestamp Handling for Message Events
The current implementation in
components/openphone/sources/common/base.mjs(lines 58–64) always usesbody.data.object.completedAtfor the event timestamp. Since message events actually use thecreatedAtfield (as evidenced by the test-event and your verification that no override exists incomponents/openphone/sources/new-message-received-instant), this discrepancy will likely result in incorrect timestamps for message events.
- Issue Location:
components/openphone/sources/common/base.mjs, lines 58–64- Current Behavior: Uses
Date.parse(body.data.object.completedAt)for the timestamp.- Problem: Message events require
createdAtinstead ofcompletedAt.- Recommendation:
- Option 1: Override the
runmethod in the new message trigger component (incomponents/openphone/sources/new-message-received-instant) to usecreatedAtfor date parsing.- Option 2: Modify the base implementation to handle both event types by checking for the existence of
completedAtand, if not present, falling back tocreatedAt.Please implement one of these fixes to ensure correct timestamp handling for message events.
🧹 Nitpick comments (1)
components/openphone/sources/new-message-received-instant/test-event.mjs (1)
1-21: Test event structure is well-definedThe test event structure correctly models an OpenPhone message webhook event with all necessary fields for a message received trigger.
I notice the test date is set to 2025. While this won't affect functionality, you might consider using a date in the past or present for consistency with other test events.
- "createdAt": "2025-04-10T21:41:01.247Z", + "createdAt": "2023-04-10T21:41:01.247Z", - "createdAt": "2025-04-10T21:41:00.983Z", + "createdAt": "2023-04-10T21:41:00.983Z",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (12)
components/openphone/actions/create-contact/create-contact.mjs(1 hunks)components/openphone/actions/list-phone-numbers/list-phone-numbers.mjs(1 hunks)components/openphone/actions/send-message/send-message.mjs(1 hunks)components/openphone/actions/update-contact/update-contact.mjs(1 hunks)components/openphone/openphone.app.mjs(1 hunks)components/openphone/package.json(1 hunks)components/openphone/sources/common/base.mjs(2 hunks)components/openphone/sources/new-call-recording-completed-instant/new-call-recording-completed-instant.mjs(2 hunks)components/openphone/sources/new-incoming-call-completed-instant/new-incoming-call-completed-instant.mjs(1 hunks)components/openphone/sources/new-message-received-instant/new-message-received-instant.mjs(1 hunks)components/openphone/sources/new-message-received-instant/test-event.mjs(1 hunks)components/openphone/sources/new-outgoing-call-completed-instant/new-outgoing-call-completed-instant.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (13)
components/openphone/package.json (1)
3-3: Version Bump in package.json:
The version number has been updated from a previous version to"0.3.0". This change is consistent with the coordinated version bumps applied across all OpenPhone components in this PR.components/openphone/actions/send-message/send-message.mjs (1)
7-7: Module Version Update for Send Message Action:
The version has been updated to"0.0.3"for this action. This update is in line with the version consistency requirements across similar actions and does not affect the underlying functionality.components/openphone/actions/update-contact/update-contact.mjs (1)
8-8: Version Increment in Update Contact Action:
The version value is updated to"0.0.3", matching the versioning standard applied throughout the OpenPhone integration components. The code overall remains clear and functionally unchanged.components/openphone/sources/new-outgoing-call-completed-instant/new-outgoing-call-completed-instant.mjs (1)
9-9: Updated Source Version for Outgoing Call Completed Trigger:
The version bump to"0.0.3"is correctly applied here. The source trigger’s implementation and control flow remain intact, and the update aligns with the overall versioning strategy of this PR.components/openphone/actions/create-contact/create-contact.mjs (1)
8-8: Consistent Version Update for Create Contact Action:
By updating the version to"0.0.3", this file now aligns with the other modules. The changes do not impact functionality, and version consistency is maintained across the integration.components/openphone/sources/new-incoming-call-completed-instant/new-incoming-call-completed-instant.mjs (1)
9-9: Version bump looks goodVersion update from "0.0.2" to "0.0.3" is appropriate as part of the coordinated version increment across OpenPhone components for this new feature release.
components/openphone/actions/list-phone-numbers/list-phone-numbers.mjs (1)
7-7: Version increment looks goodVersion update from "0.0.1" to "0.0.2" aligns with the versioning strategy being applied across other OpenPhone components in this PR.
components/openphone/sources/common/base.mjs (2)
35-37: Good addition of getWebhookType methodAdding this method provides a clean way for source components to specify their webhook type, which is necessary for the new message trigger to use "messages" instead of "calls".
48-48: Webhook parameter update is correctPassing the dynamically determined webhookType to createWebhook() is the right approach and enhances flexibility.
components/openphone/openphone.app.mjs (1)
102-108: Improved webhook creation with dynamic webhook typesThe refactoring of the
createWebhookmethod to accept a dynamicwebhookTypeparameter enhances the flexibility of the OpenPhone integration, allowing it to handle different types of webhooks through a single method.This change correctly implements destructuring to separate the webhook type from other options, and updates the request path to use this dynamic parameter.
components/openphone/sources/new-call-recording-completed-instant/new-call-recording-completed-instant.mjs (2)
9-9: Version bump for consistencyThe version update from "0.0.2" to "0.0.3" aligns with the component's release cadence and ensures consistency across the OpenPhone integration.
19-21: Method renamed for better semanticsRenaming
getEmittogetSummarybetter reflects the method's purpose - providing a summary description of the event rather than emitting it.components/openphone/sources/new-message-received-instant/new-message-received-instant.mjs (1)
1-27: Well-structured implementation of the new message received triggerThis new module properly implements a trigger for new message events in OpenPhone, following the established pattern of other source components:
- The correct event type
message.receivedis specified- The
getWebhookTypemethod returns "messages" which works with the refactoredcreateWebhookmethod- The module extends the common base functionality and provides appropriate versioning
The implementation will enable users to create workflows that trigger when new messages are received in OpenPhone.
jcortes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michelle0927 lgmt! Ready for QA!
Resolves #16250
Summary by CodeRabbit
New Features
Enhancements