Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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,65 @@
import app from "../../trengo.app.mjs";

export default {
type: "action",
version: "0.0.1",
key: "send-a-ticket-message",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
name: "Send A Ticket Message",
description: "Send a message to a ticket. [See the documentation](https://developers.trengo.com/reference/send-a-message)",
props: {
app,
ticketId: {
propDefinition: [
app,
"ticketId",
],
},
message: {
propDefinition: [
app,
"message",
],
},
internalNote: {
type: "boolean",
label: "Internal Note",
description: "If true, this message will be visible only to your team",
optional: true,
default: false,
},
subject: {
type: "string",
label: "Subject",
description: "The subject of the message. Only used when the message is an email.",
optional: true,
},
attachmentIds: {
propDefinition: [
app,
"attachmentIds",
],
optional: true,
},
},
async run({ $ }) {
const resp = await this.app.sendTicketMessage({
$,
ticketId: this.ticketId,
args: {
message: this.message,
internal_note: this.internalNote,
subject: this.subject,
attachment_ids: this.attachmentIds,
},
});

$.export("$summary", `Message sent to ticket ${this.ticketId}`);

return resp;
},
};
10 changes: 10 additions & 0 deletions components/trengo/trengo.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@ export default {
...args,
});
},
async sendTicketMessage({
ticketId,
args = {},
}) {
return this._makeRequest({
method: "POST",
path: `/tickets/${ticketId}/messages`,
...args,
});
},
async getHelpCenters(args = {}) {
return this._makeRequest({
path: "/help_center",
Expand Down
Loading