File tree Expand file tree Collapse file tree 3 files changed +77
-2
lines changed Expand file tree Collapse file tree 3 files changed +77
-2
lines changed Original file line number Diff line number Diff line change 1+ import common from "../common/common.mjs" ;
2+
3+ export default {
4+ key : "trengo-ticket-closed" ,
5+ name : "Ticket Closed (Instant)" ,
6+ description : "Emit new event when a ticket is closed. [See the documentation](https://developers.trengo.com/docs/webhooks)" ,
7+ version : "0.0.1" ,
8+ type : "source" ,
9+ dedupe : "unique" ,
10+ ...common ,
11+ methods : {
12+ ...common . methods ,
13+ getMeta ( event ) {
14+ const ts = Date . now ( ) ;
15+ const id = event ?. body ?. ticket_id ?
16+ parseInt ( event . body . ticket_id ) :
17+ ts ;
18+ const summary = `Ticket closed: #${ id } (Status: ${ event ?. body ?. status } )` ;
19+ return {
20+ id,
21+ ts,
22+ summary,
23+ } ;
24+ } ,
25+ getEvent ( ) {
26+ return "TICKET_CLOSED" ;
27+ } ,
28+ } ,
29+ } ;
Original file line number Diff line number Diff line change 1+ import common from "../common/common.mjs" ;
2+
3+ export default {
4+ key : "trengo-ticket-reopened" ,
5+ name : "Ticket Reopened (Instant)" ,
6+ description : "Emit new event when a ticket is reopened. [See the documentation](https://developers.trengo.com/docs/webhooks)" ,
7+ version : "0.0.1" ,
8+ type : "source" ,
9+ dedupe : "unique" ,
10+ ...common ,
11+ methods : {
12+ ...common . methods ,
13+ getMeta ( event ) {
14+ const ts = Date . now ( ) ;
15+ const id = event ?. body ?. ticket_id ?
16+ parseInt ( event . body . ticket_id ) :
17+ ts ;
18+ const summary = `Ticket reopened: #${ id } (Status: ${ event ?. body ?. status } )` ;
19+ return {
20+ id,
21+ ts,
22+ summary,
23+ } ;
24+ } ,
25+ getEvent ( ) {
26+ return "TICKET_REOPENED" ;
27+ } ,
28+ } ,
29+ } ;
Original file line number Diff line number Diff line change @@ -68,9 +68,20 @@ export default {
6868 description : "The WhatsApp template ID." ,
6969 } ,
7070 ticketId : {
71- type : "string " ,
71+ type : "integer " ,
7272 label : "Ticket ID" ,
73- description : "The ticket ID. Only required if `Recipient Phone Number` is not set." ,
73+ description : "Select a ticket or provide an ID" ,
74+ async options ( { page = 0 } ) {
75+ const response = await this . getTickets ( {
76+ params : {
77+ page : page + 1 ,
78+ } ,
79+ } ) ;
80+ return response . data . map ( ( ticket ) => ( {
81+ label : `#${ ticket . ticket_id } - ${ ticket . subject || "No subject" } ` ,
82+ value : ticket . ticket_id ,
83+ } ) ) ;
84+ } ,
7485 } ,
7586 whatsappTemplateParamsKeys : {
7687 type : "string[]" ,
@@ -271,5 +282,11 @@ export default {
271282 ...args ,
272283 } ) ;
273284 } ,
285+ async getTickets ( args = { } ) {
286+ return this . _makeRequest ( {
287+ path : "/tickets" ,
288+ ...args ,
289+ } ) ;
290+ } ,
274291 } ,
275292} ;
You can’t perform that action at this time.
0 commit comments