Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Sep 9, 2025

Resolves #18234

Summary by CodeRabbit

  • New Features
    • Trengo: Added “List Messages” action to retrieve messages for a ticket with optional max results.
    • Trengo: Added “List Tickets” action to list tickets with filters (status, users, channels, last message type), sort direction, and optional max results.
  • Chores
    • Trengo package version bumped to 0.3.0.
    • Updated descriptions/metadata across multiple Trengo actions and event sources (copy/grammar and doc link text; no behavior changes).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 9, 2025

Walkthrough

Adds two new Trengo actions (list-tickets, list-messages), implements app method getMessages, and bumps versions and documentation wording across multiple Trengo actions and sources; package version moved to 0.3.0. No functional changes to existing logic beyond the new actions and the new app method.

Changes

Cohort / File(s) Summary of Changes
New Actions
components/trengo/actions/list-messages/list-messages.mjs, components/trengo/actions/list-tickets/list-tickets.mjs
Added actions: trengo-list-messages (streams messages for a ticket, optional maxResults) and trengo-list-tickets (filters, sort, optional maxResults), both using utils.getResourcesStream, exporting a $summary, and returning accumulated results.
App Method Addition
components/trengo/trengo.app.mjs
Added methods.getMessages({ ticketId, ...args }) which calls GET /tickets/{ticketId}/messages via _makeRequest.
Action Metadata Updates
components/trengo/actions/*create-contact*/create-contact.mjs, .../find-contacts/find-contacts.mjs, .../list-articles/list-articles.mjs, .../log-a-voice-call/log-a-voice-call.mjs, .../send-a-message/send-a-message.mjs, .../send-a-team-chat-message/send-a-team-chat-message.mjs, .../send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs
Bumped version fields and updated description wording from "docs" to "documentation"; no logic or API signature changes.
Source Metadata Updates
components/trengo/sources/new-inbound-message/..., .../new-internal-note/..., .../new-outbound-message/..., .../phone-call-ended/..., .../phone-call-missed/..., .../phone-call-started/..., .../ticket-closed/..., .../ticket-label-added/..., .../ticket-reopened/..., .../voice-call-recorded/...
Bumped version fields and adjusted description wording to singular phrasing and "documentation"; no behavioral changes.
Package Version
components/trengo/package.json
Updated package version from 0.2.0 to 0.3.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant PD as Pipedream Action (List Tickets)
  participant App as Trengo App
  participant API as Trengo API

  User->>PD: Invoke List Tickets (filters, sort, maxResults?)
  PD->>App: app.getTickets(params)
  App->>API: GET /tickets?...
  API-->>App: Paged ticket results
  loop Stream pages
    App-->>PD: Tickets page
    PD->>PD: Accumulate, enforce maxResults
  end
  PD-->>User: Tickets[] + $summary
Loading
sequenceDiagram
  autonumber
  actor User
  participant PD as Pipedream Action (List Messages)
  participant App as Trengo App
  participant API as Trengo API

  User->>PD: Invoke List Messages (ticketId, maxResults?)
  PD->>App: app.getMessages({ ticketId })
  App->>API: GET /tickets/{ticketId}/messages
  API-->>App: Paged message results
  loop Stream pages
    App-->>PD: Messages page
    PD->>PD: Accumulate, enforce maxResults
  end
  PD-->>User: Messages[] + $summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks (2 passed, 2 warnings, 1 inconclusive)

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The PR includes numerous unrelated metadata version bumps and documentation string updates for other Trengo actions and sources, as well as a package version bump, which are not part of the linked issue’s objective of adding list tickets and list messages actions. Please remove or move unrelated version and documentation metadata updates into a separate pull request to keep this change focused on the list tickets and list messages implementations.
Description Check ⚠️ Warning The pull request description only contains “Resolves #18234” and does not follow the repository’s required template since it lacks the “## WHY” section and any context explaining the purpose of the changes. Please update the description to include the “## WHY” section with a clear rationale for the changes and any additional context as specified by the repository template.
Title Check ❓ Inconclusive The current title “Trengo - new components” is overly broad and does not clearly convey the primary change of adding List Tickets and List Messages actions, making it vague and non-descriptive. Please rename the title to reflect the main change, for example “Trengo: add List Tickets and List Messages actions” to clearly summarize the pull request’s purpose.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues Check ✅ Passed The pull request correctly implements the objectives from issue #18234 by adding a List Tickets action and a List Messages action with the required props, run logic, and necessary app method getMessages, fully fulfilling the listed requirements.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

I nibble through diffs with a twitch and hop,
Tickets and messages flow—never stop.
Versions hop forward, descriptions align,
Streams gathered neatly, one carrot at a time.
A happy rabbit ships this tiny design. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-18234

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Sep 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Sep 9, 2025 6:16pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Sep 9, 2025 6:16pm

@michelle0927 michelle0927 marked this pull request as ready for review September 9, 2025 17:49
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: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs (1)

73-74: Fix incorrect summary text (copy/paste from contact create).

The action sends a WhatsApp template, not a contact create; current summary may also reference non-existent fields.

Apply:

-    $.export("$summary", `The contact has been created. (${resp.name} ID:${resp.id})`);
+    $.export("$summary", `WhatsApp template sent${this.ticketId ? ` for ticket ${this.ticketId}` : ""}${this.recepientPhoneNumber ? ` to ${this.recepientPhoneNumber}` : ""}.`);
components/trengo/actions/send-a-message/send-a-message.mjs (1)

22-22: Fix typo in user-facing description.
Change “en email” → “an email” and add a comma after “Channel ID”.

-      description: "The destination of the message. Based on the `Channel ID` this must be en email address or phone number.",
+      description: "The destination of the message. Based on the `Channel ID`, this must be an email address or phone number.",
components/trengo/sources/new-internal-note/new-internal-note.mjs (1)

19-20: Wrong summary text for this source.
Mentions “ticket label” instead of “internal note”.

-        summary: `New ticket label added event: ${event?.body?.message}`,
+        summary: `New internal note: ${event?.body?.message}`,
🧹 Nitpick comments (13)
components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs (1)

12-19: Optional: Standardize “recipient” spelling.

Prop name uses “recepient…”. Consider aliasing/renaming across app/props to “recipientPhoneNumber” to avoid user confusion.

I can prep a follow-up PR adding a backward-compatible alias and deprecation note.

components/trengo/actions/find-contacts/find-contacts.mjs (1)

33-34: Correct singular/plural verb agreement in summary.

Use “has” for 1, “have” otherwise.

-    $.export("$summary", `${contacts.length} contact${contacts.length == 1 ? "" : "s"} have been found.`);
+    $.export("$summary", `${contacts.length} contact${contacts.length === 1 ? "" : "s"} ${contacts.length === 1 ? "has" : "have"} been found.`);
components/trengo/sources/phone-call-missed/phone-call-missed.mjs (1)

6-6: Polish description grammar.

-  description: "Emit new events when an phone call missed. [See the docs here](https://developers.trengo.com/docs/webhooks)",
+  description: "Emit new events when a phone call is missed. [See the docs](https://developers.trengo.com/docs/webhooks)",
components/trengo/sources/ticket-label-added/ticket-label-added.mjs (1)

6-6: Polish description grammar.

-  description: "Emit new events when a ticket label added. [See the docs here](https://developers.trengo.com/docs/webhooks)",
+  description: "Emit new events when a ticket label is added. [See the docs](https://developers.trengo.com/docs/webhooks)",
components/trengo/sources/new-outbound-message/new-outbound-message.mjs (2)

6-6: Polish description grammar.

-  description: "Emit new events when an outbound message sent. [See the docs here](https://developers.trengo.com/docs/webhooks)",
+  description: "Emit new events when an outbound message is sent. [See the docs](https://developers.trengo.com/docs/webhooks)",

19-20: Fix typo in summary (“outbund”).

-        summary: `New outbund message event: ${event?.body?.message}`,
+        summary: `New outbound message event: ${event?.body?.message}`,
components/trengo/sources/ticket-reopened/ticket-reopened.mjs (1)

15-17: Specify radix for parseInt.
Prevents locale/format surprises; prefer base 10.

-      const id = event?.body?.ticket_id ?
-        parseInt(event.body.ticket_id) :
+      const id = event?.body?.ticket_id ?
+        parseInt(event.body.ticket_id, 10) :
components/trengo/actions/list-articles/list-articles.mjs (1)

26-35: Don’t restrict valid filter values to a fixed list.
Docs allow untranslated_<language_code>. Current options block other languages.

       optional: true,
-      options: [
-        "draft",
-        "published",
-        "untranslated_en",
-      ],
+      placeholder: "draft | published | untranslated_<language_code>",
components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs (1)

13-18: Use a single timestamp for id and ts.
Avoids micro-mismatches from two Date.now() calls.

   methods: {
     ...common.methods,
     getMeta(event) {
-      return {
-        id: Date.now(),
-        ts: Date.now(),
+      const ts = Date.now();
+      return {
+        id: ts,
+        ts,
         summary: `Voice call recorded: ${event?.body?.from} => ${event?.body?.to} (${event?.body?.duration}s)`,
       };
     },

Note: If the payload exposes a stable call ID (e.g., event.body.call_id), prefer that over a timestamp for dedupe.

components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs (1)

44-49: Tighten validation and fix typo in error message.
Treat empty arrays as missing and correct “Attachement”.

   async run ({ $ }) {
     if (!this.threadId && !this.toUserId) {
       throw new ConfigurationError("Either `Thread ID` or `To User ID` should be set!");
     }
-    if (!this.body && !this.attachmentIds) {
-      throw new ConfigurationError("Either `Body` or `Attachement IDs` should be set!");
+    if (!this.body && (!this.attachmentIds || this.attachmentIds.length === 0)) {
+      throw new ConfigurationError("Either `Body` or `Attachment IDs` must be set!");
     }
components/trengo/sources/ticket-closed/ticket-closed.mjs (1)

15-17: Specify radix for parseInt.

-      const id = event?.body?.ticket_id ?
-        parseInt(event.body.ticket_id) :
+      const id = event?.body?.ticket_id ?
+        parseInt(event.body.ticket_id, 10) :
components/trengo/sources/new-internal-note/new-internal-note.mjs (1)

15-17: Specify radix for parseInt.

-        id: event?.body?.message_id ?
-          parseInt(event?.body?.message_id) :
+        id: event?.body?.message_id ?
+          parseInt(event?.body?.message_id, 10) :
components/trengo/sources/new-inbound-message/new-inbound-message.mjs (1)

15-17: Specify radix for parseInt.

-        id: event?.body?.message_id ?
-          parseInt(event?.body?.message_id) :
+        id: event?.body?.message_id ?
+          parseInt(event?.body?.message_id, 10) :
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db457a5 and 6b1c93d.

📒 Files selected for processing (21)
  • components/trengo/actions/create-contact/create-contact.mjs (1 hunks)
  • components/trengo/actions/find-contacts/find-contacts.mjs (1 hunks)
  • components/trengo/actions/list-articles/list-articles.mjs (1 hunks)
  • components/trengo/actions/list-messages/list-messages.mjs (1 hunks)
  • components/trengo/actions/list-tickets/list-tickets.mjs (1 hunks)
  • components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs (1 hunks)
  • components/trengo/actions/send-a-message/send-a-message.mjs (1 hunks)
  • components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs (1 hunks)
  • components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs (1 hunks)
  • components/trengo/package.json (1 hunks)
  • components/trengo/sources/new-inbound-message/new-inbound-message.mjs (1 hunks)
  • components/trengo/sources/new-internal-note/new-internal-note.mjs (1 hunks)
  • components/trengo/sources/new-outbound-message/new-outbound-message.mjs (1 hunks)
  • components/trengo/sources/phone-call-ended/phone-call-ended.mjs (1 hunks)
  • components/trengo/sources/phone-call-missed/phone-call-missed.mjs (1 hunks)
  • components/trengo/sources/phone-call-started/phone-call-started.mjs (1 hunks)
  • components/trengo/sources/ticket-closed/ticket-closed.mjs (1 hunks)
  • components/trengo/sources/ticket-label-added/ticket-label-added.mjs (1 hunks)
  • components/trengo/sources/ticket-reopened/ticket-reopened.mjs (1 hunks)
  • components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs (1 hunks)
  • components/trengo/trengo.app.mjs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
components/trengo/actions/list-tickets/list-tickets.mjs (1)
components/trengo/actions/list-messages/list-messages.mjs (2)
  • resourcesStream (27-32)
  • length (39-39)
components/trengo/actions/list-messages/list-messages.mjs (1)
components/trengo/actions/list-tickets/list-tickets.mjs (2)
  • resourcesStream (72-85)
  • length (92-92)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (24)
components/trengo/actions/create-contact/create-contact.mjs (1)

6-6: Version bump LGTM.

No functional changes; safe to publish.

components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs (1)

7-7: Version bump LGTM.

No behavior change.

components/trengo/package.json (1)

3-3: Package version bump LGTM.

Matches new actions added in this release.

components/trengo/actions/find-contacts/find-contacts.mjs (2)

7-7: Version bump LGTM.


21-28: Generated new verification scripts to locate the getResourcesStream implementation and inspect its import in the find-contacts.mjs file, to confirm whether the resource function is bound correctly.

components/trengo/sources/phone-call-missed/phone-call-missed.mjs (1)

7-7: Version bump LGTM.

components/trengo/sources/ticket-label-added/ticket-label-added.mjs (1)

7-7: Version bump LGTM.

components/trengo/sources/new-outbound-message/new-outbound-message.mjs (1)

7-7: Version bump LGTM.

components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs (1)

6-6: Version bump LGTM.

components/trengo/actions/send-a-message/send-a-message.mjs (1)

6-6: LGTM: version bump only.

components/trengo/sources/ticket-reopened/ticket-reopened.mjs (1)

7-7: LGTM: version bump only.

components/trengo/actions/list-articles/list-articles.mjs (2)

7-7: LGTM: version bump only.


51-61: Ignore outdated review: no getArticles in this action (uses getAllArticles).

Likely an incorrect or invalid review comment.

components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs (1)

7-7: LGTM: version bump only.

components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs (1)

7-7: LGTM: version bump only.

components/trengo/sources/ticket-closed/ticket-closed.mjs (1)

7-7: LGTM: version bump only.

components/trengo/sources/new-internal-note/new-internal-note.mjs (1)

7-7: LGTM: version bump only.

components/trengo/sources/new-inbound-message/new-inbound-message.mjs (1)

7-7: LGTM: version bump only.

components/trengo/sources/phone-call-started/phone-call-started.mjs (1)

7-7: Version bump looks good

No functional changes; safe to publish.

components/trengo/sources/phone-call-ended/phone-call-ended.mjs (1)

7-7: Version bump looks good

No functional changes; safe to publish.

components/trengo/actions/list-tickets/list-tickets.mjs (2)

71-85: LGTM on streaming + early exit

The resources stream pattern and maxResults cap are correct.


75-83: Yes—please extract and paste the “Try it” section’s parameter details for the List all tickets endpoint, including:

  • Exact enum values and casing for status and last_message_type
  • Format for users and channels (array vs CSV)
  • Valid sort values (date vs -date)
components/trengo/trengo.app.mjs (1)

291-298: LGTM: adds messages endpoint wrapper

Signature matches usage in the action; args are forwarded for pagination.

components/trengo/actions/list-messages/list-messages.mjs (1)

25-45: LGTM: streaming messages with maxResults and summary

Solid implementation; aligns with existing patterns.

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

🧹 Nitpick comments (1)
components/trengo/actions/create-contact/create-contact.mjs (1)

40-41: Harden the summary against missing fields and improve readability.

Use null-safe access and consistent formatting.

-    $.export("$summary", `The contact has been created. (${resp.name} ID:${resp.id})`);
+    const name = resp?.name ?? "contact";
+    const id = resp?.id ?? "unknown";
+    $.export("$summary", `Contact created: ${name} (ID: ${id}).`);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b1c93d and beeac5c.

📒 Files selected for processing (16)
  • components/trengo/actions/create-contact/create-contact.mjs (1 hunks)
  • components/trengo/actions/find-contacts/find-contacts.mjs (1 hunks)
  • components/trengo/actions/list-articles/list-articles.mjs (1 hunks)
  • components/trengo/actions/list-tickets/list-tickets.mjs (1 hunks)
  • components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs (1 hunks)
  • components/trengo/actions/send-a-message/send-a-message.mjs (1 hunks)
  • components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs (1 hunks)
  • components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs (1 hunks)
  • components/trengo/sources/new-inbound-message/new-inbound-message.mjs (1 hunks)
  • components/trengo/sources/new-internal-note/new-internal-note.mjs (1 hunks)
  • components/trengo/sources/new-outbound-message/new-outbound-message.mjs (1 hunks)
  • components/trengo/sources/phone-call-ended/phone-call-ended.mjs (1 hunks)
  • components/trengo/sources/phone-call-missed/phone-call-missed.mjs (1 hunks)
  • components/trengo/sources/phone-call-started/phone-call-started.mjs (1 hunks)
  • components/trengo/sources/ticket-label-added/ticket-label-added.mjs (1 hunks)
  • components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs
🚧 Files skipped from review as they are similar to previous changes (14)
  • components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs
  • components/trengo/actions/send-a-message/send-a-message.mjs
  • components/trengo/sources/new-internal-note/new-internal-note.mjs
  • components/trengo/actions/find-contacts/find-contacts.mjs
  • components/trengo/actions/list-articles/list-articles.mjs
  • components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs
  • components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs
  • components/trengo/sources/ticket-label-added/ticket-label-added.mjs
  • components/trengo/sources/phone-call-ended/phone-call-ended.mjs
  • components/trengo/sources/new-outbound-message/new-outbound-message.mjs
  • components/trengo/sources/new-inbound-message/new-inbound-message.mjs
  • components/trengo/sources/phone-call-started/phone-call-started.mjs
  • components/trengo/actions/list-tickets/list-tickets.mjs
  • components/trengo/sources/phone-call-missed/phone-call-missed.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: pnpm publish
🔇 Additional comments (2)
components/trengo/actions/create-contact/create-contact.mjs (2)

8-8: Approve code changes
Endpoint documentation link is current and will not 404.


31-39: Remove incorrect duplication warning: channelId is a separate parameter used by createContact, while data.channel_id populates the request payload—this isn’t redundant.

Likely an incorrect or invalid review comment.

Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

LGTM!

@michelle0927 michelle0927 merged commit 6634864 into master Sep 10, 2025
10 checks passed
@michelle0927 michelle0927 deleted the issue-18234 branch September 10, 2025 14:40
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.

[ACTION] Trengo - list tickets + messages

2 participants