Skip to content

Conversation

@luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Aug 2, 2024

Resolves #13095.

Summary by CodeRabbit

  • New Features

    • Introduced functionalities for assigning tags to contacts, creating contacts, and sending WhatsApp template messages.
    • Added event handling for new and cancelled appointments, as well as for newly created clients.
    • Enhanced prop definitions and methods for better management of contacts, tags, and locations within the Whautomate app.
    • Implemented webhook management capabilities, including creation and deletion.
  • Chores

    • Updated version number in package.json and added new dependencies for improved functionality.

@luancazarine luancazarine added the ai-assisted Content generated by AI, with human refinement and modification label Aug 2, 2024
@vercel
Copy link

vercel bot commented Aug 2, 2024

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 Aug 8, 2024 2:53pm
pipedream-docs ⬜️ Ignored (Inspect) Aug 8, 2024 2:53pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Aug 8, 2024 2:53pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes enhance the Whautomate application by introducing new functionalities for managing contacts, tags, and webhooks. New modules for creating contacts, assigning tags, sending WhatsApp template messages, and handling appointment events have been added, significantly improving API capabilities and streamlining integrations.

Changes

Files Change Summary
components/whautomate/actions/* New modules for assigning tags to contacts, creating contacts, and sending WhatsApp template messages, each with async run methods and appropriate metadata.
components/whautomate/common/constants.mjs Introduced a constant STAGE_OPTIONS for better maintainability regarding stage references.
components/whautomate/common/utils.mjs Added a utility function parseObject to handle JSON string parsing more robustly.
components/whautomate/sources/* New modules for emitting events related to appointment cancellations, scheduling, and client creation, including necessary methods and structured event objects.
components/whautomate/sources/common/base.mjs Introduced a base module for managing webhooks, including methods for activation, deactivation, and event processing.
components/whautomate/whautomate.app.mjs Enhanced propDefinitions and methods to include new functionalities for managing contacts and webhooks.
components/whautomate/package.json Version incremented to 0.1.0 and added dependency on @pipedream/platform.

Assessment against linked issues

Objective Addressed Explanation
Emit new event when an appointment is cancelled (13095)
Emit new event when a new appointment is scheduled (13095)
Emit new event when a new client is created (13095)
Assign one or more tags to an existing contact (13095)
Send a pre-defined WhatsApp message template (13095)
Create a new contact associated with a WhatsApp number (13095)

Poem

🐰 In fields of code, new features bloom,
With tags and messages, dispelling the gloom.
Appointments and clients, in harmony they play,
Whautomate's magic, brightens the day!
So hop along now, let changes take flight,
A world of connections, oh what a delight! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Sources
 - New Appointment Cancelled (Instant)
 - New Appointment Scheduled (Instant)
 - New Client Created (Instant)

Actions
 - Assign Tags Contact
 - Create Contact
 - Send Whatsapp Template Message
@luancazarine luancazarine marked this pull request as ready for review August 6, 2024 14:12
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: 16

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 78b1933 and 66f9a79.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (14)
  • components/whautomate/actions/assign-tags-contact/assign-tags-contact.mjs (1 hunks)
  • components/whautomate/actions/create-contact/create-contact.mjs (1 hunks)
  • components/whautomate/actions/send-whatsapp-template-message/send-whatsapp-template-message.mjs (1 hunks)
  • components/whautomate/common/constants.mjs (1 hunks)
  • components/whautomate/common/utils.mjs (1 hunks)
  • components/whautomate/package.json (2 hunks)
  • components/whautomate/sources/common/base.mjs (1 hunks)
  • components/whautomate/sources/new-appointment-cancelled-instant/new-appointment-cancelled-instant.mjs (1 hunks)
  • components/whautomate/sources/new-appointment-cancelled-instant/test-event.mjs (1 hunks)
  • components/whautomate/sources/new-appointment-scheduled-instant/new-appointment-scheduled-instant.mjs (1 hunks)
  • components/whautomate/sources/new-appointment-scheduled-instant/test-event.mjs (1 hunks)
  • components/whautomate/sources/new-client-created-instant/new-client-created-instant.mjs (1 hunks)
  • components/whautomate/sources/new-client-created-instant/test-event.mjs (1 hunks)
  • components/whautomate/whautomate.app.mjs (1 hunks)
Files skipped from review due to trivial changes (1)
  • components/whautomate/common/constants.mjs
Additional comments not posted (26)
components/whautomate/package.json (2)

3-3: Version increment approved.

The version number has been incremented to 0.1.0, indicating a new release with enhancements or new features.


15-17: Dependency addition approved.

The addition of @pipedream/platform with version ^3.0.0 is approved, indicating that new functionalities or features introduced in this release require this platform version.

components/whautomate/sources/new-appointment-cancelled-instant/new-appointment-cancelled-instant.mjs (4)

1-2: Imports look good.

The imports are necessary and correctly referenced.


4-11: Configuration looks good.

The webhook source configuration for "New Appointment Cancelled" is correctly defined.


12-22: Methods look good.

The getEvent and getSummary methods are correctly implemented.


23-23: SampleEmit reference looks good.

The sampleEmit object is correctly referenced.

components/whautomate/sources/new-appointment-scheduled-instant/new-appointment-scheduled-instant.mjs (4)

1-2: Imports look good.

The imports are necessary and correctly referenced.


4-11: Configuration looks good.

The webhook source configuration for "New Appointment Scheduled" is correctly defined.


12-22: Methods look good.

The getEvent and getSummary methods are correctly implemented.


23-23: SampleEmit reference looks good.

The sampleEmit object is correctly referenced.

components/whautomate/sources/new-client-created-instant/test-event.mjs (3)

1-7: Event object looks good.

The event object is correctly defined.


8-38: Client object looks good.

The client object is correctly defined.


1-39: Export statement looks good.

The export statement is correctly defined.

components/whautomate/actions/assign-tags-contact/assign-tags-contact.mjs (2)

1-2: Imports look good.

The imports are necessary for the functionality of the action.


4-24: Export default object looks good.

The properties are correctly defined and the descriptions are accurate.

components/whautomate/sources/common/base.mjs (3)

1-1: Import looks good.

The import is necessary for the functionality of the webhook sources.


3-16: Export default object looks good.

The properties are correctly defined and the descriptions are accurate.


40-49: Run method looks good.

The logic of the run method is correct and the emitted events are correctly formatted.

components/whautomate/sources/new-appointment-scheduled-instant/test-event.mjs (1)

1-48: Test event JSON object looks good.

The structure of the JSON object is correct and all necessary properties are included.

components/whautomate/sources/new-appointment-cancelled-instant/test-event.mjs (1)

1-47: LGTM! Ensure the data types and formats are correct.

The JSON structure for the cancelled appointment event is well-formed and includes detailed information. Ensure that the data types and formats (e.g., timestamps, IDs) are correct and consistent with the rest of the system.

components/whautomate/actions/create-contact/create-contact.mjs (3)

1-3: LGTM! Imports are correct.

The import statements correctly bring in the necessary constants, utility functions, and the whautomate module.


5-55: LGTM! Module definition and properties are well-defined.

The module definition includes a clear key, name, description, version, type, and properties. The required and optional fields are well-defined with appropriate descriptions and types.


56-79: LGTM! The run function is well-implemented.

The run function correctly extracts properties, calls the createContact method, and exports a summary message. The use of parseObject ensures proper formatting of tags and custom fields.

components/whautomate/actions/send-whatsapp-template-message/send-whatsapp-template-message.mjs (3)

1-3: LGTM! Imports are correct.

The import statements correctly bring in the necessary ConfigurationError class, utility functions, and the whautomate module.


5-58: LGTM! Module definition and properties are well-defined.

The module definition includes a clear key, name, description, version, type, and properties. The required and optional fields are well-defined with appropriate descriptions and types.


60-86: LGTM! The run function is well-implemented.

The run function correctly extracts properties, calls the sendWhatsAppMessageTemplate method, and handles errors. The use of parseObject ensures proper formatting of text and URL parameters. The error handling with ConfigurationError is appropriate.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 66f9a79 and fe183a2.

Files selected for processing (1)
  • components/whautomate/sources/common/base.mjs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • components/whautomate/sources/common/base.mjs

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, codebase verification and nitpick comments (1)
components/whautomate/sources/common/base.mjs (1)

48-57: Minor improvement: Use optional chaining for timestamp parsing.

The function is correctly implemented, but consider using optional chaining to avoid potential errors if body.event or body.event.timeStamp is undefined.

-  const ts = Date.parse(body.event.timeStamp);
+  const ts = Date.parse(body.event?.timeStamp);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fe183a2 and eea9ed9.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (3)
  • components/whautomate/actions/create-contact/create-contact.mjs (1 hunks)
  • components/whautomate/actions/send-whatsapp-template-message/send-whatsapp-template-message.mjs (1 hunks)
  • components/whautomate/sources/common/base.mjs (1 hunks)
Files skipped from review due to trivial changes (1)
  • components/whautomate/actions/send-whatsapp-template-message/send-whatsapp-template-message.mjs
Files skipped from review as they are similar to previous changes (1)
  • components/whautomate/actions/create-contact/create-contact.mjs
Additional comments not posted (4)
components/whautomate/sources/common/base.mjs (4)

1-1: LGTM!

The import statement is correct.


3-16: LGTM!

The props are well-defined and necessary for the component's functionality.


17-23: LGTM!

The methods _setWebhookId and _getWebhookId are correctly implemented.


25-47: Consider adding error handling in hooks.

The logic of the hooks is correct, but consider adding error handling to manage potential errors during the API calls.

hooks: {
  async activate() {
    try {
      const data = await this.whautomate.createWebhook({
        data: {
          webhookHeaders: [
            {
              "key": "Content-Type",
              "value": "application/json",
            },
          ],
          events: this.getEvent(),
          name: this.name,
          serverUrl: this.http.endpoint,
          active: true,
        },
      });
      this._setWebhookId(data.id);
    } catch (error) {
      console.error(`Failed to activate webhook: ${error.message}`);
      throw error;
    }
  },
  async deactivate() {
    try {
      const webhookId = this._getWebhookId();
      await this.whautomate.deleteWebhook(webhookId);
    } catch (error) {
      console.error(`Failed to deactivate webhook: ${error.message}`);
      throw error;
    }
  },
}

michelle0927
michelle0927 previously approved these changes Aug 6, 2024
Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@luancazarine
Copy link
Collaborator Author

/approve

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eea9ed9 and c847487.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (1)
  • components/whautomate/actions/assign-tags-contact/assign-tags-contact.mjs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • components/whautomate/actions/assign-tags-contact/assign-tags-contact.mjs

@luancazarine luancazarine merged commit 44871be into master Aug 8, 2024
@luancazarine luancazarine deleted the issue-13095 branch August 8, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Content generated by AI, with human refinement and modification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Components] whautomate

4 participants