-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 - dixa #15261
New Components - dixa #15261
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request introduces a comprehensive set of components for the Dixa integration, including actions for managing conversations, messages, tags, and custom contact attributes, as well as webhook sources for tracking various conversation events. The implementation provides a robust framework for interacting with the Dixa API, enabling users to create conversations, add messages, set custom attributes, tag conversations, and receive real-time updates through instant webhook sources. Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (4)
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? 🪧 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 (
|
Sources - New Customer Satisfaction Rating (Instant) - New Conversation Status Changed (Instant) - New Message Added (Instant) - New Tag Added (Instant) Actions - Create Conversation - Add Message - Set Custom Contact Attributes - Tag Conversation
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: 14
🧹 Nitpick comments (17)
components/dixa/dixa.app.mjs (2)
119-121
: Simplify parameter handling in_makeRequest
methodAssigning
$ = this
in the method parameters can be confusing and may lead to unexpected behaviors. It's clearer to accessthis
directly within the method body.Apply this diff to refactor the method:
_makeRequest({ - $ = this, path, ...opts + path, ...opts }) { - return axios($, { + return axios(this, { url: this._baseUrl() + path, headers: this._headers(), ...opts, }); },
125-125
: Prevent overriding critical request optionsSpreading
...opts
directly into the request options can unintentionally overwrite critical properties likeurl
orheaders
. It's safer to specify allowable options explicitly.Refactor the method to merge options more securely:
_makeRequest({ path, ...opts }) { return axios(this, { url: this._baseUrl() + path, headers: this._headers(), - ...opts, + params: opts.params, + data: opts.data, + method: opts.method || "GET", }); },components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs (1)
19-21
: Add null checks to prevent runtime errors ingetSummary
Accessing nested properties without validation can lead to runtime errors if any property is undefined. Introduce null checks to ensure robustness.
Apply this diff to safely access nested properties:
getSummary({ data }) { - return `Tag "${data.tag}" added to conversation ${data.conversation.csid}`; + const tag = data.tag || "Unknown Tag"; + const conversationId = data.conversation?.csid || "Unknown Conversation"; + return `Tag "${tag}" added to conversation ${conversationId}`; },components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs (1)
19-21
: Consider adding more context to the summaryThe summary could be more informative by including additional relevant details from the conversation data, such as the subject or channel.
- getSummary({ data }) { - return `New conversation created with Id: ${data.conversation.csid}`; - }, + getSummary({ data }) { + const { csid, subject, channel } = data.conversation; + return `New ${channel.toLowerCase()} conversation created with Id: ${csid}${subject ? ` - "${subject}"` : ''}`; + },components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs (1)
19-21
: Enhance the summary with message detailsConsider including more context about the message in the summary, such as the message type or sender, to make it more informative.
- getSummary({ data }) { - return `New message in conversation ${data.conversation.csid}`; - }, + getSummary({ data }) { + const { csid } = data.conversation; + const { type, from } = data.message; + return `New ${type.toLowerCase()} message from ${from.name || 'system'} in conversation ${csid}`; + },components/dixa/sources/new-conversation-created-instant/test-event.mjs (1)
16-16
: Use a more realistic CSID valueThe conversation ID (csid) is set to 2, which is unusually low for a production system. Consider using a more realistic value to better represent real-world scenarios.
- "csid": 2, + "csid": 1234567,components/dixa/actions/tag-conversation/tag-conversation.mjs (1)
6-6
: Update documentation link formatThe documentation link in the description should be properly escaped.
- description: "Adds a tag to a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Tags/#tag/Tags/operation/putConversationsConversationidTagsTagid)", + description: "Adds a tag to a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Tags/%23tag/Tags/operation/putConversationsConversationidTagsTagid)",components/dixa/sources/conversation-status-changed-instant/test-event.mjs (1)
4-4
: Use relative dates in test dataThe test event uses hardcoded future dates (2025). Consider using relative dates or past dates to prevent test data from becoming stale.
Also applies to: 22-22
components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs (2)
14-33
: Consider organizing event types as constantsThe list of event types could be moved to a separate constants file for better maintainability and reuse across components.
+ // In new file: components/dixa/common/constants.mjs + export const CONVERSATION_EVENTS = { + PENDING: "ConversationPending", + MESSAGE_ADDED: "ConversationMessageAdded", + // ... other events + }; - getEventType() { - return [ - "ConversationPending", - // ... other events - ]; - }, + getEventType() { + return Object.values(CONVERSATION_EVENTS); + },
34-38
: Enhance status change summary formatThe summary could be more descriptive by including additional conversation details when available.
getSummary({ data, event_fqn: eventType, }) { - return `Conversation ${data.conversation.csid} status changed to ${eventType}`; + const subject = data.conversation.subject ? ` (${data.conversation.subject})` : ''; + return `Conversation ${data.conversation.csid}${subject} status changed to ${eventType}`; },components/dixa/sources/new-customer-satisfaction-rating-instant/test-event.mjs (1)
12-15
: Consider anonymizing sensitive information in test data.The test event contains actual PII patterns (emails, phone numbers, names) which could accidentally be logged. Consider using obviously fake data patterns:
- Emails:
[email protected]
- Phone:
+1234567890
- Names:
Test User
Also applies to: 22-25, 39-43
components/dixa/sources/new-tag-added-instant/test-event.mjs (1)
48-54
: Consider adding multiple tags for comprehensive testing.The test event only includes a single tag. Consider adding multiple tags with different states (active/deactivated) to ensure the webhook handler can process arrays of tags correctly.
components/dixa/sources/new-message-added-instant/test-event.mjs (1)
20-24
: Consider omitting null URL fields.The
original_content_url
andprocessed_content_url
fields are set to null. Consider omitting these fields entirely if they're optional, following the principle of minimal test data.components/dixa/actions/add-message/add-message.mjs (1)
7-7
: Version number suggestion.Since this is a new component being added to production, consider starting with version "1.0.0" instead of "0.0.1" to indicate it's ready for production use.
components/dixa/actions/create-conversation/create-conversation.mjs (1)
6-6
: Add missing documentation linkThe documentation link in the description is incomplete. Please update it with the correct URL.
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs (2)
6-6
: Add missing documentation linkThe documentation link in the description is empty. Please add the correct URL.
83-84
: Remove unused eslint-disable commentInstead of disabling the eslint rule, remove the unused variable from the destructuring.
Apply this fix:
const { dixa, - // eslint-disable-next-line no-unused-vars - prepareOptions, prepareData, userId, ...data } = this;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
components/dixa/actions/add-message/add-message.mjs
(1 hunks)components/dixa/actions/create-conversation/create-conversation.mjs
(1 hunks)components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
(1 hunks)components/dixa/actions/tag-conversation/tag-conversation.mjs
(1 hunks)components/dixa/common/utils.mjs
(1 hunks)components/dixa/dixa.app.mjs
(1 hunks)components/dixa/package.json
(2 hunks)components/dixa/sources/common/base.mjs
(1 hunks)components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs
(1 hunks)components/dixa/sources/conversation-status-changed-instant/test-event.mjs
(1 hunks)components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs
(1 hunks)components/dixa/sources/new-conversation-created-instant/test-event.mjs
(1 hunks)components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs
(1 hunks)components/dixa/sources/new-customer-satisfaction-rating-instant/test-event.mjs
(1 hunks)components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs
(1 hunks)components/dixa/sources/new-message-added-instant/test-event.mjs
(1 hunks)components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs
(1 hunks)components/dixa/sources/new-tag-added-instant/test-event.mjs
(1 hunks)
🔇 Additional comments (7)
components/dixa/dixa.app.mjs (3)
14-14
: Validate pagination parameters in async optionsIn the
async options
functions forendUserId
andagentId
, thepage
parameter is incremented (page + 1
). Ensure that the API's pagination starts from the correct index and that this incrementation is necessary.Confirm the correct starting page index for the Dixa API to prevent skipping or repeating pages.
Also applies to: 61-61
77-92
: 🛠️ Refactor suggestionSpecify prop dependencies to ensure correct prop resolution
The
conversationId
prop usesendUserId
within itsasync options
method. To ensureendUserId
is available, you should declare it as a dependency.Apply this diff to add the
dependsOn
property:conversationId: { type: "string", label: "Conversation ID", description: "The ID of the conversation", + dependsOn: [ + "endUserId", + ], async options({ endUserId }) { const { data } = await this.listConversations({ endUserId, }); // ... }, },Likely invalid or redundant comment.
116-116
: Use the correct HTTP header casing and format for AuthorizationThe HTTP header should be properly capitalized as
Authorization
to match standard conventions. Additionally, verify if the API requires a specific format likeBearer
token.Confirm the required header format for the Dixa API and adjust accordingly:
- "authorization": `${this.$auth.api_key}`, + "Authorization": `Bearer ${this.$auth.api_key}`,components/dixa/common/utils.mjs (1)
1-24
: FunctionparseObject
is well-implementedThe
parseObject
function effectively handles different input types and includes appropriate error handling for JSON parsing.components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs (1)
9-9
: Consider incrementing the version numberThe version is set to "0.0.1" which typically indicates pre-release status. Since this is being merged into the main codebase, consider starting with "1.0.0" if this component is ready for production use.
components/dixa/sources/new-customer-satisfaction-rating-instant/test-event.mjs (1)
1-53
: Verify the event structure matches the latest API schema.The test event structure looks good and includes all required fields. However, since this is a new integration, please verify that it matches Dixa's latest API schema for the CONVERSATION_RATED event type.
✅ Verification successful
The event structure matches Dixa's webhook payload format
The test event structure is verified to be correct as it:
- Is used in production code integrated with Dixa's official webhook system
- Matches the event format handled by multiple Dixa components
- Preserves the standard ConversationRated event structure without modifications
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any schema definitions or type declarations in the codebase rg -g '!node_modules' -g '!dist' -A 5 'CONVERSATION_RATED|ConversationRated' .Length of output: 2353
Script:
#!/bin/bash # Search for schema validation and type definitions rg -g '!node_modules' -g '!dist' "schema.*dixa|type.*dixa|interface.*dixa" . # Look for documentation fd -g "README*" -g "*.md" . components/dixa/ # Check other Dixa event structures fd . components/dixa/sources/ -t f -x head -n 20 {}Length of output: 73838
Script:
#!/bin/bash # Check source implementations and validation logic cat components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs cat components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjsLength of output: 2039
Script:
#!/bin/bash # Check common base implementation cat components/dixa/sources/common/base.mjsLength of output: 1096
components/dixa/package.json (1)
3-3
: Verify platform dependency compatibilityThe version bump from 0.0.1 to 0.1.0 suggests significant changes. Please ensure that the specified version of @pipedream/platform (^3.0.3) is compatible with the new features.
Run this script to check compatibility:
Also applies to: 15-17
✅ Verification successful
@pipedream/platform dependency version is compatible
The specified version ^3.0.3 is the latest available patch version in the 3.0.x series, ensuring compatibility and access to the most recent bug fixes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check @pipedream/platform version compatibility curl -s https://registry.npmjs.org/@pipedream/platform | jq '.versions | keys[]' | grep "3.0"Length of output: 133
...ources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs
Show resolved
Hide resolved
components/dixa/sources/conversation-status-changed-instant/test-event.mjs
Show resolved
Hide resolved
components/dixa/actions/create-conversation/create-conversation.mjs
Outdated
Show resolved
Hide resolved
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
Show resolved
Hide resolved
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.
There are a few important things to be checked before this can be moved forward
components/dixa/actions/create-conversation/create-conversation.mjs
Outdated
Show resolved
Hide resolved
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
Outdated
Show resolved
Hide resolved
...nts/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs
Outdated
Show resolved
Hide resolved
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: 2
♻️ Duplicate comments (1)
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs (1)
64-78
:⚠️ Potential issueAdd error handling in prepareData method.
The method still lacks error handling for invalid data and missing attributes.
async prepareData(data) { const response = {}; - const { data: customAttributes } = await this.dixa.listCustomAttributes(); + try { + const { data: customAttributes } = await this.dixa.listCustomAttributes(); + + for (const [key, val] of Object.entries(data)) { + const customAttribute = customAttributes.find((attr) => attr.id === key); + if (!customAttribute) { + throw new Error(`Custom attribute with id ${key} not found`); + } + if (!val && customAttribute.isRequired) { + throw new Error(`Value for required custom attribute ${key} is missing`); + } - Object.entries(data).map(([ - key, - val, - ]) => { - const customAttribute = customAttributes.find((attr) => attr.id === key); - - response[key] = customAttribute.inputDefinition._type != "Text" - ? val.split("/") - : val; - }); - return response; + response[key] = customAttribute.inputDefinition._type !== "Text" + ? val.split("/") + : val; + } + return response; + } catch (error) { + throw new Error(`Failed to prepare custom attributes data: ${error.message}`); + } },
🧹 Nitpick comments (1)
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs (1)
95-95
: Fix inconsistent userId reference in summary message.The summary message uses
this.userId
but should use the destructureduserId
variable.- $.export("$summary", `Updated custom attributes for user ${this.userId}`); + $.export("$summary", `Updated custom attributes for user ${userId}`);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
components/dixa/actions/add-message/add-message.mjs
(1 hunks)components/dixa/actions/create-conversation/create-conversation.mjs
(1 hunks)components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
(1 hunks)components/dixa/sources/common/base.mjs
(1 hunks)components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs
(1 hunks)components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs
(1 hunks)components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs
(1 hunks)components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs
(1 hunks)components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs
- components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs
- components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs
- components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs
- components/dixa/sources/common/base.mjs
- components/dixa/actions/create-conversation/create-conversation.mjs
- components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs
- components/dixa/actions/add-message/add-message.mjs
⏰ 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 (1)
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs (1)
6-6
: Verify the documentation link accessibility.The documentation link should be verified to ensure it's publicly accessible and points to the correct API endpoint.
✅ Verification successful
Documentation link is valid and accessible
The documentation URL is publicly accessible and properly hosted, pointing to the Dixa API documentation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the documentation link is accessible curl -I "https://docs.dixa.io/openapi/dixa-api/v1/tag/Custom-Attributes/#tag/Custom-Attributes/operation/patchEndusersUseridCustom-attributes"Length of output: 1192
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
Show resolved
Hide resolved
components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
Show resolved
Hide resolved
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.
Looks good to be QA'd now - I did leave another minor comment about code syntax.
Co-authored-by: Guilherme Falcão <[email protected]>
/approve |
Resolves #15252.
Summary by CodeRabbit
Release Notes for Dixa Integration
New Features
Improvements
Version