diff --git a/components/trengo/actions/create-contact/create-contact.mjs b/components/trengo/actions/create-contact/create-contact.mjs index a4f713cd29bdf..c09e721040204 100644 --- a/components/trengo/actions/create-contact/create-contact.mjs +++ b/components/trengo/actions/create-contact/create-contact.mjs @@ -3,7 +3,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-create-contact", - version: "0.0.2", + version: "0.0.3", 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)", props: { diff --git a/components/trengo/actions/create-internal-note/create-internal-note.mjs b/components/trengo/actions/create-internal-note/create-internal-note.mjs new file mode 100644 index 0000000000000..8edfcb6819d15 --- /dev/null +++ b/components/trengo/actions/create-internal-note/create-internal-note.mjs @@ -0,0 +1,38 @@ +import app from "../../trengo.app.mjs"; + +export default { + type: "action", + key: "trengo-create-internal-note", + version: "0.0.1", + name: "Create Internal Note", + description: "Create an internal note on a ticket that is only visible to team members. [See the docs](https://developers.trengo.com/reference/create-internal-note)", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + note: { + propDefinition: [ + app, + "note", + ], + optional: false, + description: "The internal note content that will be added to the ticket.", + }, + }, + async run({ $ }) { + const resp = await this.app.createInternalNote({ + $, + data: { + ticket_id: this.ticketId, + note: this.note, + }, + }); + $.export("$summary", `Successfully created internal note on ticket ${this.ticketId}`); + return resp; + }, +}; + diff --git a/components/trengo/actions/find-contacts/find-contacts.mjs b/components/trengo/actions/find-contacts/find-contacts.mjs index fca3ebb6dd6ea..682b9c55b1551 100644 --- a/components/trengo/actions/find-contacts/find-contacts.mjs +++ b/components/trengo/actions/find-contacts/find-contacts.mjs @@ -4,7 +4,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-find-contacts", - version: "0.0.2", + version: "0.0.3", name: "Find Contacts", description: "Finds contacts with the given term. [See the docs](https://developers.trengo.com/reference/as)", props: { 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 d20c39aca8bdb..cf684f71d6fb9 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,7 +3,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-log-a-voice-call", - version: "0.0.2", + version: "0.0.3", 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)", props: { 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 f91922ad67cbc..043fcba17f489 100644 --- a/components/trengo/actions/send-a-message/send-a-message.mjs +++ b/components/trengo/actions/send-a-message/send-a-message.mjs @@ -3,7 +3,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-message", - version: "0.0.2", + 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)", props: { @@ -40,19 +40,51 @@ export default { "emailSubject", ], }, + createInternalNote: { + type: "boolean", + label: "Create Internal Note", + description: "Create an internal note instead of sending a message to the contact (requires ticket ID)", + optional: true, + default: false, + }, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + description: "Required when creating an internal note", + optional: true, + }, }, async run ({ $ }) { - const resp = await this.app.sendMessage({ - $, - data: { - channel_id: this.channelId, - contact_identifier: this.contactIdentifier, - contact_name: this.contactName, - message: this.message, - email_subject: this.emailSubject, - }, - }); - $.export("$summary", "The message has been sent"); - return resp; + if (this.createInternalNote) { + if (!this.ticketId) { + throw new Error("Ticket ID is required when creating an internal note"); + } + // Create internal note instead of sending message + const resp = await this.app.createInternalNote({ + $, + data: { + ticket_id: this.ticketId, + note: this.message, + }, + }); + $.export("$summary", `Internal note created on ticket ${this.ticketId}`); + return resp; + } else { + // Send regular message + const resp = await this.app.sendMessage({ + $, + data: { + channel_id: this.channelId, + contact_identifier: this.contactIdentifier, + contact_name: this.contactName, + message: this.message, + email_subject: this.emailSubject, + }, + }); + $.export("$summary", "The message has been sent"); + return resp; + } }, }; 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 d940c98c51f24..a4a00520c2c7c 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,7 +4,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-team-chat-message", - version: "0.0.2", + version: "0.0.3", 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)", props: { 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 9d06f4b7a0bc3..7112098eac0e3 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,7 +4,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-whatsapp-message-template", - version: "0.0.2", + version: "0.0.3", name: "Send A WhatsApp Message Template", description: "Sends a WhatsApp message template, [See the docs](https://developers.trengo.com/reference/start-a-conversation)", props: { diff --git a/components/trengo/package.json b/components/trengo/package.json index f5c320c6d33ab..34720ef0aaa66 100644 --- a/components/trengo/package.json +++ b/components/trengo/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/trengo", - "version": "0.1.0", + "version": "0.1.1", "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 ad69b07d7a180..d62e08ad53fe2 100644 --- a/components/trengo/sources/new-inbound-message/new-inbound-message.mjs +++ b/components/trengo/sources/new-inbound-message/new-inbound-message.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 2d24d257a07cf..5bd8e296682c3 100644 --- a/components/trengo/sources/new-internal-note/new-internal-note.mjs +++ b/components/trengo/sources/new-internal-note/new-internal-note.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 ea32eed86f23c..2f858d5265b26 100644 --- a/components/trengo/sources/new-outbound-message/new-outbound-message.mjs +++ b/components/trengo/sources/new-outbound-message/new-outbound-message.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 5237f0ff0788a..bbc3e5698595b 100644 --- a/components/trengo/sources/phone-call-ended/phone-call-ended.mjs +++ b/components/trengo/sources/phone-call-ended/phone-call-ended.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 963a25d01815c..f4ba6ec69ffd3 100644 --- a/components/trengo/sources/phone-call-missed/phone-call-missed.mjs +++ b/components/trengo/sources/phone-call-missed/phone-call-missed.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 f7def7a1b42f8..98ec31e967431 100644 --- a/components/trengo/sources/phone-call-started/phone-call-started.mjs +++ b/components/trengo/sources/phone-call-started/phone-call-started.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 225af3fe5ad50..20c67ee00ccbf 100644 --- a/components/trengo/sources/ticket-label-added/ticket-label-added.mjs +++ b/components/trengo/sources/ticket-label-added/ticket-label-added.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", 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 8033d408bb519..d8c527551322a 100644 --- a/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs +++ b/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs @@ -4,7 +4,7 @@ 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.1", + version: "0.0.2", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/trengo.app.mjs b/components/trengo/trengo.app.mjs index d7f4019a1e73b..2933964e2146e 100644 --- a/components/trengo/trengo.app.mjs +++ b/components/trengo/trengo.app.mjs @@ -241,5 +241,17 @@ export default { ...args, }); }, + /** + * Create an internal note on a ticket + * @param {object} args - Request arguments + * @returns {object} Response from Trengo API + */ + async createInternalNote(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/tickets/notes", + ...args, + }); + }, }, };