diff --git a/components/trengo/actions/create-contact/create-contact.mjs b/components/trengo/actions/create-contact/create-contact.mjs index c09e721040204..43fb84b0bbcad 100644 --- a/components/trengo/actions/create-contact/create-contact.mjs +++ b/components/trengo/actions/create-contact/create-contact.mjs @@ -3,9 +3,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-create-contact", - version: "0.0.3", + version: "0.0.4", name: "Create Contact", - description: "Creates a contact. If a contact with given identifier already exists, returns it. [See the docs](https://developers.trengo.com/reference/create-update-a-user)", + description: "Creates a contact. If a contact with given identifier already exists, returns it. [See the documentation](https://developers.trengo.com/reference/create-contact)", props: { app, channelId: { diff --git a/components/trengo/actions/find-contacts/find-contacts.mjs b/components/trengo/actions/find-contacts/find-contacts.mjs index 682b9c55b1551..248b1834423a6 100644 --- a/components/trengo/actions/find-contacts/find-contacts.mjs +++ b/components/trengo/actions/find-contacts/find-contacts.mjs @@ -4,9 +4,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-find-contacts", - version: "0.0.3", + version: "0.0.4", name: "Find Contacts", - description: "Finds contacts with the given term. [See the docs](https://developers.trengo.com/reference/as)", + description: "Finds contacts with the given term. [See the documentation](https://developers.trengo.com/reference/list-all-contacts)", props: { app, term: { diff --git a/components/trengo/actions/list-articles/list-articles.mjs b/components/trengo/actions/list-articles/list-articles.mjs index 588acca07fe4e..714213ce66137 100644 --- a/components/trengo/actions/list-articles/list-articles.mjs +++ b/components/trengo/actions/list-articles/list-articles.mjs @@ -4,9 +4,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-list-articles", - version: "0.0.1", + version: "0.0.2", name: "List Articles", - description: "List articles from a help center according to the specified criteria. [See the docs](https://developers.trengo.com/reference/list-all-articles)", + description: "List articles from a help center according to the specified criteria. [See the documentation](https://developers.trengo.com/reference/list-all-articles)", props: { app, helpCenterId: { diff --git a/components/trengo/actions/list-messages/list-messages.mjs b/components/trengo/actions/list-messages/list-messages.mjs new file mode 100644 index 0000000000000..24bd6a09321a1 --- /dev/null +++ b/components/trengo/actions/list-messages/list-messages.mjs @@ -0,0 +1,45 @@ +import utils from "../../common/utils.mjs"; +import app from "../../trengo.app.mjs"; + +export default { + key: "trengo-list-messages", + name: "List Messages", + description: "List messages from a ticket. [See the documentation](https://developers.trengo.com/reference/list-all-messages)", + version: "0.0.1", + type: "action", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "Maximum number of messages to return (if not specified, all results will be returned)", + optional: true, + }, + }, + async run({ $ }) { + const messages = []; + const resourcesStream = utils.getResourcesStream({ + resourceFn: this.app.getMessages, + resourceFnArgs: { + ticketId: this.ticketId, + }, + }); + for await (const item of resourcesStream) { + messages.push(item); + if (this.maxResults && messages.length >= this.maxResults) { + break; + } + } + const length = messages.length; + $.export("$summary", `Successfully retrieved ${length} message${length === 1 + ? "" + : "s"}`); + return messages; + }, +}; diff --git a/components/trengo/actions/list-tickets/list-tickets.mjs b/components/trengo/actions/list-tickets/list-tickets.mjs new file mode 100644 index 0000000000000..6f9d0e61fa3d1 --- /dev/null +++ b/components/trengo/actions/list-tickets/list-tickets.mjs @@ -0,0 +1,100 @@ +import utils from "../../common/utils.mjs"; +import app from "../../trengo.app.mjs"; + +export default { + key: "trengo-list-tickets", + name: "List Tickets", + description: "List tickets according to the specified criteria. [See the documentation](https://developers.trengo.com/reference/list-all-tickets)", + version: "0.0.1", + type: "action", + props: { + app, + status: { + type: "string", + label: "Status", + description: "The ticket's status", + optional: true, + options: [ + "OPEN", + "ASSIGNED", + "CLOSED", + "INVALID", + ], + }, + userIds: { + propDefinition: [ + app, + "toUserId", + ], + type: "integer[]", + label: "User IDs", + description: "Filter by one or more user IDs", + optional: true, + }, + channelIds: { + propDefinition: [ + app, + "channelId", + ], + type: "integer[]", + label: "Channel IDs", + description: "Filter by one or more channel IDs", + optional: true, + }, + lastMessageType: { + type: "string", + label: "Last Message Type", + description: "Filter by the type of the last message", + optional: true, + options: [ + "INBOUND", + "OUTBOUND", + ], + }, + sortDirection: { + type: "string", + label: "Sort Direction", + description: "Sort ascending or descending by last message date", + optional: true, + options: [ + "ASC", + "DESC", + ], + default: "DESC", + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "Maximum number of tickets to return (if not specified, all results will be returned)", + optional: true, + }, + }, + async run({ $ }) { + const tickets = []; + const resourcesStream = utils.getResourcesStream({ + resourceFn: this.app.getTickets, + resourceFnArgs: { + params: { + status: this.status, + users: this.userIds, + channels: this.channelIds, + last_message_type: this.lastMessageType, + sort: this.sortDirection === "ASC" + ? "date" + : "-date", + }, + }, + }); + for await (const item of resourcesStream) { + tickets.push(item); + if (this.maxResults && tickets.length >= this.maxResults) { + break; + } + } + const length = tickets.length; + $.export("$summary", `Successfully retrieved ${length} ticket${length === 1 + ? "" + : "s"}`); + return tickets; + }, +}; diff --git a/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs b/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs index cf684f71d6fb9..874cb16f867b2 100644 --- a/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs +++ b/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs @@ -3,9 +3,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-log-a-voice-call", - version: "0.0.3", + version: "0.0.4", name: "Log A Voice Call", - description: "Logs a phone call from external VOIP applications, [See the docs](https://developers.trengo.com/reference/log-a-phone-call)", + description: "Logs a phone call from external VOIP applications, [See the documentation](https://developers.trengo.com/reference/log-a-phone-call)", props: { app, channelId: { diff --git a/components/trengo/actions/send-a-message/send-a-message.mjs b/components/trengo/actions/send-a-message/send-a-message.mjs index 0506170781b37..75d2d6301e77a 100644 --- a/components/trengo/actions/send-a-message/send-a-message.mjs +++ b/components/trengo/actions/send-a-message/send-a-message.mjs @@ -3,9 +3,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-message", - version: "0.0.3", + version: "0.0.4", name: "Send A Message", - description: "This action can be used to easily send a message or an email without having to think about contacts or tickets, [See the docs](https://developers.trengo.com/reference/send-a-message-1)", + description: "This action can be used to easily send a message or an email without having to think about contacts or tickets, [See the documentation](https://developers.trengo.com/reference/send-a-message-1)", props: { app, channelId: { diff --git a/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs b/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs index a4a00520c2c7c..1274f3abebece 100644 --- a/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs +++ b/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs @@ -4,9 +4,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-team-chat-message", - version: "0.0.3", + version: "0.0.4", name: "Send A Team Chat Message", - description: "Send a message as a bot in the Team Chat, [See the docs](https://developers.trengo.com/reference/sending-a-bot-message)", + description: "Send a message as a bot in the Team Chat, [See the documentation](https://developers.trengo.com/reference/sending-a-bot-message)", props: { app, threadId: { diff --git a/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs b/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs index daf120398aac3..e84bfae1acca2 100644 --- a/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs +++ b/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs @@ -4,9 +4,9 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-whatsapp-message-template", - version: "0.0.3", + version: "0.0.4", name: "Send A WhatsApp Message Template", - description: "Sends a WhatsApp message template, [See the docs](https://developers.trengo.com/reference/start-a-conversation)", + description: "Sends a WhatsApp message template, [See the documentation](https://developers.trengo.com/reference/start-a-conversation)", props: { app, recepientPhoneNumber: { diff --git a/components/trengo/package.json b/components/trengo/package.json index b3e33e32bbe30..97aa3e23e3852 100644 --- a/components/trengo/package.json +++ b/components/trengo/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/trengo", - "version": "0.2.0", + "version": "0.3.0", "description": "Pipedream Trengo Components", "main": "trengo.app.mjs", "keywords": [ diff --git a/components/trengo/sources/new-inbound-message/new-inbound-message.mjs b/components/trengo/sources/new-inbound-message/new-inbound-message.mjs index d62e08ad53fe2..a859355d2eb4d 100644 --- a/components/trengo/sources/new-inbound-message/new-inbound-message.mjs +++ b/components/trengo/sources/new-inbound-message/new-inbound-message.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-new-inbound-message", name: "New Inbound Message Event (Instant)", - description: "Emit new events when an inbound message received. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when an inbound message is received. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/new-internal-note/new-internal-note.mjs b/components/trengo/sources/new-internal-note/new-internal-note.mjs index 5bd8e296682c3..a2ffb514dd0b4 100644 --- a/components/trengo/sources/new-internal-note/new-internal-note.mjs +++ b/components/trengo/sources/new-internal-note/new-internal-note.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-new-internal-note", name: "New Internal Note Event (Instant)", - description: "Emit new events when a internal note added. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when an internal note is added. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/new-outbound-message/new-outbound-message.mjs b/components/trengo/sources/new-outbound-message/new-outbound-message.mjs index 2f858d5265b26..02d88145ad7d1 100644 --- a/components/trengo/sources/new-outbound-message/new-outbound-message.mjs +++ b/components/trengo/sources/new-outbound-message/new-outbound-message.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-new-outbound-message", name: "New Outbound Message Event (Instant)", - description: "Emit new events when an outbound message sent. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when an outbound message sent. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/phone-call-ended/phone-call-ended.mjs b/components/trengo/sources/phone-call-ended/phone-call-ended.mjs index bbc3e5698595b..4a5ff370b97b1 100644 --- a/components/trengo/sources/phone-call-ended/phone-call-ended.mjs +++ b/components/trengo/sources/phone-call-ended/phone-call-ended.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-phone-call-ended", name: "New Phone Call Ended Event (Instant)", - description: "Emit new events when an phone call ended. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when a phone call ends. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/phone-call-missed/phone-call-missed.mjs b/components/trengo/sources/phone-call-missed/phone-call-missed.mjs index f4ba6ec69ffd3..c5b9a37f2b0b8 100644 --- a/components/trengo/sources/phone-call-missed/phone-call-missed.mjs +++ b/components/trengo/sources/phone-call-missed/phone-call-missed.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-phone-call-missed", name: "New Phone Call Missed Event (Instant)", - description: "Emit new events when an phone call missed. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when an phone call missed. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/phone-call-started/phone-call-started.mjs b/components/trengo/sources/phone-call-started/phone-call-started.mjs index 98ec31e967431..f2789bf740aea 100644 --- a/components/trengo/sources/phone-call-started/phone-call-started.mjs +++ b/components/trengo/sources/phone-call-started/phone-call-started.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-phone-call-started", name: "New Phone Call Started Event (Instant)", - description: "Emit new events when an phone call started. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when a phone call starts. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/ticket-closed/ticket-closed.mjs b/components/trengo/sources/ticket-closed/ticket-closed.mjs index 2f006f9d6ff09..f8781f633cd79 100644 --- a/components/trengo/sources/ticket-closed/ticket-closed.mjs +++ b/components/trengo/sources/ticket-closed/ticket-closed.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-ticket-closed", name: "Ticket Closed (Instant)", description: "Emit new event when a ticket is closed. [See the documentation](https://developers.trengo.com/docs/webhooks)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/ticket-label-added/ticket-label-added.mjs b/components/trengo/sources/ticket-label-added/ticket-label-added.mjs index 20c67ee00ccbf..3ba6e5ab7d389 100644 --- a/components/trengo/sources/ticket-label-added/ticket-label-added.mjs +++ b/components/trengo/sources/ticket-label-added/ticket-label-added.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-ticket-label-added", name: "New Ticket Label Added Event (Instant)", - description: "Emit new events when a ticket label added. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.3", + description: "Emit new event when a ticket label is added. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.4", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/ticket-reopened/ticket-reopened.mjs b/components/trengo/sources/ticket-reopened/ticket-reopened.mjs index 3a9acef8317b3..4d41cac90cff8 100644 --- a/components/trengo/sources/ticket-reopened/ticket-reopened.mjs +++ b/components/trengo/sources/ticket-reopened/ticket-reopened.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-ticket-reopened", name: "Ticket Reopened (Instant)", description: "Emit new event when a ticket is reopened. [See the documentation](https://developers.trengo.com/docs/webhooks)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs b/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs index d8c527551322a..4d2d3d42c8638 100644 --- a/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs +++ b/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs @@ -3,8 +3,8 @@ import common from "../common/common.mjs"; export default { key: "trengo-voice-call-recorded", name: "New Voice Call Recorded Event (Instant)", - description: "Emit new events when a voice call is recorded. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + description: "Emit new event when a voice call is recorded. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/trengo.app.mjs b/components/trengo/trengo.app.mjs index b674cc5b15743..2e4b6ae8920b6 100644 --- a/components/trengo/trengo.app.mjs +++ b/components/trengo/trengo.app.mjs @@ -288,5 +288,13 @@ export default { ...args, }); }, + async getMessages({ + ticketId, ...args + }) { + return this._makeRequest({ + path: `/tickets/${ticketId}/messages`, + ...args, + }); + }, }, };