Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 22, 2025

Resolves #13234

Summary by CodeRabbit

  • New Features
    • Introduced Landbot integration, enabling users to connect with the Landbot API.
    • Added the ability to send text and image messages to customers directly via Landbot.
    • Implemented an event trigger that emits events when new messages are received in a specified Landbot channel.
  • Chores
    • Added package metadata for the Landbot integration.

@vercel
Copy link

vercel bot commented May 22, 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) May 22, 2025 7:59pm
pipedream-docs ⬜️ Ignored (Inspect) May 22, 2025 7:59pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 22, 2025 7:59pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 22, 2025

Walkthrough

This update introduces a new Landbot integration, including an app module for API interactions, two action components for sending text and image messages, a source component for capturing new messages in a channel via webhooks, and supporting files such as a package manifest and a test event. The integration centralizes API communication and supports dynamic property selection.

Changes

File(s) Change Summary
components/landbot/landbot.app.mjs Added a new Landbot app integration module with prop definitions for dynamic option loading and methods for customer/channel management, webhook handling, and sending messages (text/image) via the Landbot API.
components/landbot/actions/send-image/send-image.mjs
components/landbot/actions/send-text-message/send-text-message.mjs
Introduced new action modules for sending image and text messages to customers via the Landbot API, with configurable props for customer selection and message content.
components/landbot/sources/new-message-in-channel/new-message-in-channel.mjs
components/landbot/sources/new-message-in-channel/test-event.mjs
Added a new source component to emit events for new messages in a channel using webhooks, including webhook lifecycle management and a test event for validation.
components/landbot/package.json Added package metadata for the Landbot integration, specifying dependencies and publishing configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionComponent as Send Text/Image Action
    participant LandbotApp
    participant LandbotAPI

    User->>ActionComponent: Provide customerId, message/imageUrl, etc.
    ActionComponent->>LandbotApp: Call sendTextMessage/sendImageMessage
    LandbotApp->>LandbotAPI: POST /customers/{customerId}/send_text or /send_image
    LandbotAPI-->>LandbotApp: API response
    LandbotApp-->>ActionComponent: Return response
    ActionComponent-->>User: Export summary and API result
Loading
sequenceDiagram
    participant LandbotAPI
    participant Webhook
    participant SourceComponent as New Message Source
    participant Downstream

    LandbotAPI-->>Webhook: POST new message event
    Webhook->>SourceComponent: Receive event payload
    SourceComponent->>Downstream: Emit event(s) for messages
Loading

Assessment against linked issues

Objective Addressed Explanation
Emit new event when a visitor reaches the 'Zapier Integration' Block within a Landbot (#13234) The implemented source emits new message events in a channel, not specifically Zapier Block.

Suggested labels

action, trigger / source

Poem

A hop and a skip, new features abound,
Landbot now listens for each message sound.
Send a quick text or an image with flair,
Webhooks and actions are handled with care.
With every new message, events leap and play—
The code rabbit smiles, for Landbot’s here to stay! 🐇✨

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/landbot/actions/send-image/send-image.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 Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

components/landbot/sources/new-message-in-channel/new-message-in-channel.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 Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

components/landbot/actions/send-text-message/send-text-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 Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

  • 2 others

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

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: 4

🧹 Nitpick comments (8)
components/landbot/landbot.app.mjs (3)

7-42: Consider adding pagination handling for large datasets.

The options methods for customerId and channelId properly implement basic pagination, but they don't handle the case when there are no more results to fetch. This could lead to empty options being displayed.

async options({ page }) {
  const { customers } = await this.listCustomers({
    params: {
      limit: DEFAULT_LIMIT,
      offset: page * DEFAULT_LIMIT,
    },
  });
+  if (!customers.length) {
+    return [];
+  }
  return customers.map((customer) => ({
    label: customer.name,
    value: customer.id,
  }));
},

11-24: Add name fallback for customers with empty names.

In the customerId options mapping, customers with empty names will appear without labels. Consider adding a fallback to customer ID when name is empty.

return customers.map((customer) => ({
-  label: customer.name,
+  label: customer.name || `Customer ${customer.id}`,
  value: customer.id,
}));

36-40: Add name fallback for channels with empty names.

Similarly, in the channelId options mapping, channels with empty names will appear without labels. Consider adding a fallback to channel ID when name is empty.

return channels.map((channel) => ({
-  label: channel.name,
+  label: channel.name || `Channel ${channel.id}`,
  value: channel.id,
}));
components/landbot/sources/new-message-in-channel/test-event.mjs (1)

1-41: Test event uses future timestamp.

The timestamp in the test event (1747943104.006807) appears to be set in the future (around 2025), which could cause unexpected behavior in testing scenarios. Consider using a current or past timestamp.

Also, some fields like sender.name and customer.name are empty, which might not represent realistic test data. Consider adding more representative values for thorough testing.

components/landbot/actions/send-image/send-image.mjs (1)

38-39: Enhance summary message with more details.

The summary message could be more informative by including details about the image being sent, such as the URL or caption.

- $.export("$summary", `Successfully sent image to Customer ID: ${this.customerId}`);
+ $.export("$summary", `Successfully sent image${this.caption ? ` with caption "${this.caption}"` : ""} to Customer ID: ${this.customerId}`);
components/landbot/actions/send-text-message/send-text-message.mjs (1)

23-33: Consider adding error handling and input validation

The run method could benefit from error handling in case the API call fails. Also, consider validating that the message is not empty before sending.

  async run({ $ }) {
+   if (!this.message?.trim()) {
+     throw new Error("Message cannot be empty");
+   }
+   
+   try {
      const response = await this.landbot.sendTextMessage({
        $,
        customerId: this.customerId,
        data: {
          message: this.message,
        },
      });
      $.export("$summary", `Successfully sent message to Customer ID: ${this.customerId}`);
      return response;
+   } catch (error) {
+     $.export("$summary", `Failed to send message: ${error.message}`);
+     throw error;
+   }
  },
components/landbot/sources/new-message-in-channel/new-message-in-channel.mjs (2)

22-41: Add error handling to webhook lifecycle management

The activate and deactivate hooks should include error handling to gracefully manage API failures and provide meaningful error messages.

  hooks: {
    async activate() {
+     try {
        const { hook } = await this.landbot.createWebhook({
          channelId: this.channelId,
          data: {
            url: this.http.endpoint,
          },
        });
        this._setHookId(hook.id);
+       console.log(`Created webhook with ID: ${hook.id} for channel: ${this.channelId}`);
+     } catch (error) {
+       console.error(`Failed to create webhook: ${error.message}`);
+       throw error;
+     }
    },
    async deactivate() {
      const webhookId = this._getHookId();
      if (webhookId) {
+       try {
          await this.landbot.deleteWebhook({
            channelId: this.channelId,
            webhookId,
          });
+         console.log(`Deleted webhook with ID: ${webhookId}`);
+       } catch (error) {
+         console.error(`Failed to delete webhook: ${error.message}`);
+         // Not rethrowing as this is in cleanup
+       }
      }
    },
  },

57-66: Add validation for message structure

The run method should validate the structure of each message before processing to prevent errors when accessing properties.

  async run(event) {
    const { body } = event;
    if (!body || !body.messages) {
      return;
    }
    for (const message of body.messages) {
+     // Validate message has required properties
+     if (!message || !message.timestamp || !message.type) {
+       console.warn("Received malformed message, skipping:", JSON.stringify(message));
+       continue;
+     }
      const meta = this.generateMeta(message);
      this.$emit(message, meta);
    }
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00690a7 and 2383b2f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/landbot/actions/send-image/send-image.mjs (1 hunks)
  • components/landbot/actions/send-text-message/send-text-message.mjs (1 hunks)
  • components/landbot/landbot.app.mjs (1 hunks)
  • components/landbot/package.json (1 hunks)
  • components/landbot/sources/new-message-in-channel/new-message-in-channel.mjs (1 hunks)
  • components/landbot/sources/new-message-in-channel/test-event.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (2)
components/landbot/package.json (1)

1-17: Package.json structure looks good.

The package definition follows Pipedream's standard conventions with appropriate metadata, version numbering, and dependency specification. The main entry point correctly points to the app file that will be used by the integration.

components/landbot/actions/send-text-message/send-text-message.mjs (1)

1-34: Well-structured component with good documentation link

The component follows the Pipedream pattern nicely with clear props and a straightforward implementation.

@michelle0927 michelle0927 merged commit 1e54be1 into master May 27, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-13234 branch May 27, 2025 14:41
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.

[Components] landbot

3 participants