Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 10, 2025

Resolves #16250

Summary by CodeRabbit

  • New Features

    • Introduced a new event source for message notifications, enabling real-time alerts and concise summaries.
    • Added a sample event structure for simulating new message notifications.
  • Enhancements

    • Improved webhook configuration to support dynamic selection of webhook types.
    • Updated module versions across various components for consistency and smoother operation.

@vercel
Copy link

vercel bot commented Apr 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 10, 2025 10:02pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 10, 2025 10:02pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 10, 2025 10:02pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 10, 2025

Walkthrough

This 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 createWebhook to accept a dynamic webhookType, and adds a new module with supporting methods for a "new message received" trigger along with a test event module.

Changes

File(s) Change Summary
components/openphone/actions/(create-contact.mjs, send-message.mjs, update-contact.mjs) Version updated from "0.0.2" to "0.0.3".
components/openphone/actions/list-phone-numbers/list-phone-numbers.mjs Version updated from "0.0.1" to "0.0.2".
components/openphone/openphone.app.mjs Modified createWebhook method signature to { webhookType, ...opts } and updated the request path to include the dynamic webhookType.
components/openphone/package.json Package version updated from "0.2.0" to "0.3.0".
components/openphone/sources/common/base.mjs Added new method getWebhookType() that returns "calls".
components/openphone/sources/new-call-recording-completed-instant/new-call-recording-completed-instant.mjs Version updated from "0.0.2" to "0.0.3" and renamed method getEmit to getSummary.
components/openphone/sources/new-incoming-call-completed-instant/new-incoming-call-completed-instant.mjs Version updated from "0.0.2" to "0.0.3".
components/openphone/sources/new-message-received-instant/new-message-received-instant.mjs New module added with properties and methods (getEvent(), getSummary(), getWebhookType()) for the message received trigger.
components/openphone/sources/new-message-received-instant/test-event.mjs New module added exporting a sample event structure for handling message received notifications.
components/openphone/sources/new-outgoing-call-completed-instant/new-outgoing-call-completed-instant.mjs Version updated from "0.0.2" to "0.0.3".

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant OpenPhoneApp
    Client->>OpenPhoneApp: createWebhook({ webhookType, ...opts })
    OpenPhoneApp->>API: POST /webhooks/{webhookType} with opts
    API-->>OpenPhoneApp: Response
Loading
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
Loading

Assessment against linked issues

Objective Addressed Explanation
[APP] OpenPhone — new message received trigger (#16250)

Possibly related PRs

Suggested labels

ai-assisted

Suggested reviewers

  • lcaresia

Poem

I'm a rabbit with code in my paws,
Hopping through updates without a cause.
Webhooks now dance with types so new,
And message triggers join the crew.
With each small change I skip with pride,
Celebrating code changes on this joyful ride! 🐇

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/openphone/actions/create-contact/create-contact.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/openphone/actions/send-message/send-message.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/openphone/sources/common/base.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 8 others
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 run method uses body.data.object.completedAt for the timestamp when emitting events. This works for call events, but message events (based on the test-event.mjs) use createdAt instead of completedAt.

Please ensure that the new message received component either:

  1. Overrides this method to use the correct timestamp field, or
  2. 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 uses body.data.object.completedAt for the event timestamp. Since message events actually use the createdAt field (as evidenced by the test-event and your verification that no override exists in components/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 createdAt instead of completedAt.
  • Recommendation:
    • Option 1: Override the run method in the new message trigger component (in components/openphone/sources/new-message-received-instant) to use createdAt for date parsing.
    • Option 2: Modify the base implementation to handle both event types by checking for the existence of completedAt and, if not present, falling back to createdAt.

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-defined

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between ef0e890 and 1bc0af3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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 good

Version 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 good

Version 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 method

Adding 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 correct

Passing 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 types

The refactoring of the createWebhook method to accept a dynamic webhookType parameter 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 consistency

The 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 semantics

Renaming getEmit to getSummary better 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 trigger

This new module properly implements a trigger for new message events in OpenPhone, following the established pattern of other source components:

  1. The correct event type message.received is specified
  2. The getWebhookType method returns "messages" which works with the refactored createWebhook method
  3. 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.

Copy link
Collaborator

@jcortes jcortes left a 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!

@michelle0927 michelle0927 merged commit f1a0f20 into master Apr 14, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-16250 branch April 14, 2025 14:36
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.

[APP] OpenPhone — new message received trigger

3 participants