-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - landbot #16804
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
New Components - landbot #16804
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
WalkthroughThis 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
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
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
Assessment against linked issues
Suggested labels
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/landbot/actions/send-image/send-image.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/landbot/sources/new-message-in-channel/new-message-in-channel.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/landbot/actions/send-text-message/send-text-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
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit 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. Note ⚡️ Faster reviews with cachingCodeRabbit 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 ✨ 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:
SupportNeed 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)
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: 4
🧹 Nitpick comments (8)
components/landbot/landbot.app.mjs (3)
7-42: Consider adding pagination handling for large datasets.The
optionsmethods forcustomerIdandchannelIdproperly 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
customerIdoptions 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
channelIdoptions 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 validationThe 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 managementThe 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 structureThe 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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 linkThe component follows the Pipedream pattern nicely with clear props and a straightforward implementation.
Resolves #13234
Summary by CodeRabbit