-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Trengo internal notes #17600
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
Trengo internal notes #17600
Conversation
- Add createInternalNote method to Trengo app - Add dedicated create-internal-note action for adding notes to tickets - Enhance send-a-message action with createInternalNote option - Update package version to 0.1.1 - Leverage existing new-internal-note webhook source for notifications
WalkthroughThe changes introduce and enhance internal note functionality for Freshdesk and Trengo integrations. New properties and methods allow adding internal notes to tickets, either as standalone actions or as options within existing ticket update or message-sending actions. Supporting methods and version increments were added to ensure proper API interaction and version tracking. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FreshdeskAction
participant FreshdeskAPI
User->>FreshdeskAction: Run update-ticket with internalNote and noteBody
alt internalNote is true and noteBody provided
FreshdeskAction->>FreshdeskAPI: POST /tickets/{ticketId}/notes (add internal note)
FreshdeskAPI-->>FreshdeskAction: Response
FreshdeskAction-->>User: Return note added summary
else
FreshdeskAction->>FreshdeskAPI: PUT /tickets/{ticketId} (update ticket)
FreshdeskAPI-->>FreshdeskAction: Response
FreshdeskAction-->>User: Return ticket updated summary
end
sequenceDiagram
participant User
participant TrengoAction
participant TrengoApp
participant TrengoAPI
User->>TrengoAction: Run create-internal-note with ticketId and note
TrengoAction->>TrengoApp: createInternalNote({ticketId, note})
TrengoApp->>TrengoAPI: POST /tickets/notes
TrengoAPI-->>TrengoApp: Response
TrengoApp-->>TrengoAction: Response
TrengoAction-->>User: Return note created summary
sequenceDiagram
participant User
participant SendMessageAction
participant TrengoApp
participant TrengoAPI
User->>SendMessageAction: Run send-a-message with createInternalNote flag
alt createInternalNote is true
SendMessageAction->>TrengoApp: createInternalNote({message, metadata})
TrengoApp->>TrengoAPI: POST /tickets/notes
TrengoAPI-->>TrengoApp: Response
TrengoApp-->>SendMessageAction: Response
SendMessageAction-->>User: Return internal note created summary
else
SendMessageAction->>TrengoApp: sendMessage({message, subject, ...})
TrengoApp->>TrengoAPI: POST /messages
TrengoAPI-->>TrengoApp: Response
TrengoApp-->>SendMessageAction: Response
SendMessageAction-->>User: Return message sent summary
end
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/trengo/actions/send-a-message/send-a-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 components/trengo/trengo.app.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/freshdesk/actions/update-ticket/update-ticket.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ 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 (
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
@seynadio is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
components/freshdesk/actions/update-ticket/update-ticket.mjs
(3 hunks)components/trengo/actions/create-internal-note/create-internal-note.mjs
(1 hunks)components/trengo/actions/send-a-message/send-a-message.mjs
(2 hunks)components/trengo/package.json
(1 hunks)components/trengo/trengo.app.mjs
(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
components/trengo/package.json (1)
Learnt from: jcortes
PR: PipedreamHQ/pipedream#14935
File: components/sailpoint/package.json:15-18
Timestamp: 2024-12-12T19:23:09.039Z
Learning: When developing Pipedream components, do not add built-in Node.js modules like `fs` to `package.json` dependencies, as they are native modules provided by the Node.js runtime.
components/trengo/actions/create-internal-note/create-internal-note.mjs (1)
Learnt from: jcortes
PR: PipedreamHQ/pipedream#14467
File: components/gainsight_px/actions/create-account/create-account.mjs:4-6
Timestamp: 2024-10-30T15:24:39.294Z
Learning: In `components/gainsight_px/actions/create-account/create-account.mjs`, the action name should be "Create Account" instead of "Create Memory".
components/trengo/actions/send-a-message/send-a-message.mjs (3)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-10-08T15:33:38.240Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Learnt from: jcortes
PR: PipedreamHQ/pipedream#14467
File: components/gainsight_px/actions/create-account/create-account.mjs:4-6
Timestamp: 2024-10-30T15:24:39.294Z
Learning: In `components/gainsight_px/actions/create-account/create-account.mjs`, the action name should be "Create Account" instead of "Create Memory".
components/freshdesk/actions/update-ticket/update-ticket.mjs (2)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-10-08T15:33:38.240Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
🔇 Additional comments (8)
components/trengo/package.json (1)
3-3
: LGTM: Appropriate version bump for new functionality.The version increment from 0.1.0 to 0.1.1 correctly reflects the addition of internal note functionality without introducing breaking changes.
components/trengo/trengo.app.mjs (1)
244-250
: LGTM: Well-implemented method following established patterns.The
createInternalNote
method is correctly implemented, following the same pattern as other methods in the file and using the appropriate POST request to the/tickets/notes
endpoint.components/freshdesk/actions/update-ticket/update-ticket.mjs (3)
8-8
: LGTM: Appropriate version bump for new functionality.The version increment reflects the addition of internal note functionality.
74-86
: LGTM: Well-structured props for internal note functionality.The boolean
internalNote
flag andnoteBody
string prop provide clear control over internal note creation.
120-133
: LGTM: Correct implementation of internal note creation.The early return pattern properly separates internal note creation from ticket updates, using the correct Freshdesk API endpoint
/tickets/{ticketId}/notes
with theprivate: true
flag.components/trengo/actions/create-internal-note/create-internal-note.mjs (1)
1-37
: LGTM: Clean and focused action implementation.The action is well-structured with appropriate props and correctly uses the app's
createInternalNote
method. The note prop is properly made mandatory, and the data structure withticket_id
andnote
fields is correct.components/trengo/actions/send-a-message/send-a-message.mjs (2)
6-6
: LGTM: Appropriate version bump for new functionality.The version increment reflects the addition of internal note functionality.
43-49
: LGTM: Clear prop definition for internal note toggle.The boolean prop with appropriate default and description provides clear control over the action behavior.
if (this.createInternalNote) { | ||
// Create internal note instead of sending message | ||
const resp = await this.app.createInternalNote({ | ||
$, | ||
data: { | ||
note: this.message, | ||
// Internal notes might need additional context | ||
metadata: { | ||
channel_id: this.channelId, | ||
contact_identifier: this.contactIdentifier, | ||
contact_name: this.contactName, | ||
}, | ||
}, | ||
}); | ||
$.export("$summary", "Internal note has been created"); | ||
return resp; | ||
} else { |
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.
Critical: Missing ticket_id for internal note creation.
Internal notes must be associated with a ticket, but no ticket_id
is being passed to the createInternalNote
method. This will likely cause API errors since the /tickets/notes
endpoint requires knowing which ticket to attach the note to.
Additionally, the metadata structure being passed is inconsistent with the dedicated create-internal-note
action which only passes ticket_id
and note
.
Consider one of these solutions:
- Add a
ticketId
prop to this action whencreateInternalNote
is true - Remove the internal note functionality from this action since it's better handled by the dedicated
create-internal-note
action - Clarify the API requirements for the
/tickets/notes
endpoint
data: {
+ ticket_id: this.ticketId, // Add this prop to the action
note: this.message,
- // Internal notes might need additional context
- metadata: {
- channel_id: this.channelId,
- contact_identifier: this.contactIdentifier,
- contact_name: this.contactName,
- },
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (this.createInternalNote) { | |
// Create internal note instead of sending message | |
const resp = await this.app.createInternalNote({ | |
$, | |
data: { | |
note: this.message, | |
// Internal notes might need additional context | |
metadata: { | |
channel_id: this.channelId, | |
contact_identifier: this.contactIdentifier, | |
contact_name: this.contactName, | |
}, | |
}, | |
}); | |
$.export("$summary", "Internal note has been created"); | |
return resp; | |
} else { | |
if (this.createInternalNote) { | |
// Create internal note instead of sending message | |
const resp = await this.app.createInternalNote({ | |
$, | |
data: { | |
ticket_id: this.ticketId, // Add this prop to the action | |
note: this.message, | |
}, | |
}); | |
$.export("$summary", "Internal note has been created"); | |
return resp; | |
} else { |
🤖 Prompt for AI Agents
In components/trengo/actions/send-a-message/send-a-message.mjs around lines 52
to 68, the internal note creation is missing the required ticket_id parameter,
which is necessary for associating the note with a ticket and avoiding API
errors. To fix this, add a ticketId property to the action and include it in the
data passed to createInternalNote, ensuring the payload matches the expected
structure of the dedicated create-internal-note action by passing only ticket_id
and note. Alternatively, consider removing the internal note functionality from
this action if it is better handled separately.
Closing this PR and replacing with #17606 which has only the Trengo changes (no accidental Freshdesk changes included) and improved validation logic |
WHY
- Added createInternalNote() method using /tickets/notes endpoint
- Dedicated action for creating internal notes on tickets
- Uses ticket ID and note content parameters
- Added createInternalNote boolean option
- Conditional logic to create internal notes instead of sending messages
- Version bumped to 0.0.3
- The new-internal-note webhook source already exists and listens for "NOTE" events
Summary by CodeRabbit
New Features
Improvements