Skip to content

Add internal notes support to Trengo integration #17606

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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;
},
};
58 changes: 45 additions & 13 deletions components/trengo/actions/send-a-message/send-a-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.3",
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: {
Expand Down Expand Up @@ -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;
}
},
};
2 changes: 1 addition & 1 deletion components/trengo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/trengo",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pipedream Trengo Components",
"main": "trengo.app.mjs",
"keywords": [
Expand Down
12 changes: 12 additions & 0 deletions components/trengo/trengo.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
},
},
};