Skip to content

Trengo new components #17792

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

Merged
merged 6 commits into from
Jul 30, 2025
Merged
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
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion components/trengo/actions/find-contacts/find-contacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
74 changes: 74 additions & 0 deletions components/trengo/actions/list-articles/list-articles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import utils from "../../common/utils.mjs";
import app from "../../trengo.app.mjs";

export default {
type: "action",
key: "trengo-list-articles",
version: "0.0.1",
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)",
props: {
app,
helpCenterId: {
propDefinition: [
app,
"helpCenterId",
],
},
localeCode: {
type: "string",
label: "Locale Code",
description: "The article's locale code",
optional: true,
default: "en",
},
filter: {
type: "string",
label: "Filter",
description: "The article's filter. You can choose one of the available options, specify `untranslated_<language_code>` for other language codes, or leave empty for all articles",
optional: true,
options: [
"draft",
"published",
"untranslated_en",
],
},
term: {
type: "string",
label: "Search Term",
description: "The article's search term (if not specified, all articles will be returned)",
optional: true,
},
maxResults: {
type: "integer",
label: "Max Results",
description: "Maximum number of articles to return (if not specified, all results will be returned)",
optional: true,
},
},
async run({ $ }) {
const articles = [];
const resourcesStream = utils.getResourcesStream({
resourceFn: this.app.getArticles,
resourceFnArgs: {
helpCenterId: this.helpCenterId,
params: {
localeCode: this.localeCode,
filter: this.filter,
term: this.term,
},
},
});
for await (const item of resourcesStream) {
articles.push(item);
if (this.maxResults && articles.length >= this.maxResults) {
break;
}
}
const length = articles.length;
$.export("$summary", `Successfully retrieved ${length} article${length === 1
? ""
: "s"}`);
return articles;
},
};
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-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: {
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -45,7 +45,7 @@ export default {
},
async run ({ $ }) {
if (!this.recepientPhoneNumber && !this.ticketId) {
throw new ConfigurationError("Either `Receipent Phone Number` or `Ticket ID` should be set!");
throw new ConfigurationError("Either `Recipient Phone Number` or `Ticket ID` should be set!");
}
const params = [];
if (this.whatsappTemplateParamsKeys && this.whatsappTemplateParamsValues) {
Expand All @@ -65,7 +65,8 @@ export default {
data: {
recipient_phone_number: this.recepientPhoneNumber,
hsm_id: this.hsmId,
ticket_id: this.ticketId,
// the docs specify this as string for some reason
ticket_id: this.ticketId?.toString?.() || this.ticketId,
params,
},
});
Expand Down
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.2.0",
"description": "Pipedream Trengo Components",
"main": "trengo.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 29 additions & 0 deletions components/trengo/sources/ticket-closed/ticket-closed.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/common.mjs";

export default {
key: "trengo-ticket-closed",
name: "Ticket Closed (Instant)",

Check warning on line 5 in components/trengo/sources/ticket-closed/ticket-closed.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a ticket is closed. [See the documentation](https://developers.trengo.com/docs/webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
...common,
methods: {
...common.methods,
getMeta(event) {
const ts = Date.now();
const id = event?.body?.ticket_id ?
parseInt(event.body.ticket_id) :
ts;
const summary = `Ticket closed: #${id} (Status: ${event?.body?.status})`;
return {
id,
ts,
summary,
};
},
getEvent() {
return "TICKET_CLOSED";
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 29 additions & 0 deletions components/trengo/sources/ticket-reopened/ticket-reopened.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/common.mjs";

export default {
key: "trengo-ticket-reopened",
name: "Ticket Reopened (Instant)",

Check warning on line 5 in components/trengo/sources/ticket-reopened/ticket-reopened.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a ticket is reopened. [See the documentation](https://developers.trengo.com/docs/webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
...common,
methods: {
...common.methods,
getMeta(event) {
const ts = Date.now();
const id = event?.body?.ticket_id ?
parseInt(event.body.ticket_id) :
ts;
const summary = `Ticket reopened: #${id} (Status: ${event?.body?.status})`;
return {
id,
ts,
summary,
};
},
getEvent() {
return "TICKET_REOPENED";
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
51 changes: 49 additions & 2 deletions components/trengo/trengo.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,20 @@ export default {
description: "The WhatsApp template ID.",
},
ticketId: {
type: "string",
type: "integer",
label: "Ticket ID",
description: "The ticket ID. Only required if `Recipient Phone Number` is not set.",
description: "Select a ticket or provide an ID",
async options({ page = 0 }) {
const response = await this.getTickets({
params: {
page: page + 1,
},
});
return response.data.map((ticket) => ({
label: `#${ticket.ticket_id} - ${ticket.subject || "No subject"}`,
value: ticket.ticket_id,
}));
},
},
whatsappTemplateParamsKeys: {
type: "string[]",
Expand Down Expand Up @@ -146,6 +157,22 @@ export default {
description: "Search term to find a contact. If not given, all contacts will be returned.",
optional: true,
},
helpCenterId: {
type: "integer",
label: "Help Center ID",
description: "Select a help center or provide an ID",
async options({ page = 0 }) {
const response = await this.getHelpCenters({
params: {
page: page + 1,
},
});
return response.data.map((helpCenter) => ({
label: helpCenter.name || helpCenter.slug,
value: helpCenter.id,
}));
},
},
},
methods: {
_getUrl(path) {
Expand Down Expand Up @@ -241,5 +268,25 @@ export default {
...args,
});
},
async getHelpCenters(args = {}) {
return this._makeRequest({
path: "/help_center",
...args,
});
},
async getArticles({
helpCenterId, ...args
} = {}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}/articles`,
...args,
});
},
async getTickets(args = {}) {
return this._makeRequest({
path: "/tickets",
...args,
});
},
},
};
3 changes: 1 addition & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading