0

for a while now I am stuck, trying to listen to the event where the agent sends a reply to the ticket. I have tried listening to ticket.comments.changed and ticket.conversation.changed but have not been successful.

I can't use the ticket.submit.[done|fail|always] or ticket.save because I don't have a way of knowing if it is the event I want or is being called with another event.

Maybe someone who knows of a configuration or some way that would allow me to do this, I would be very grateful.

jonabtc
  • 3
  • 1
  • Both events are not suitable as they will only fire after the save hook has allowed the ticket to be submitted. Please share more about your use case to suggest a suitable approach. – ahmedsabriz Feb 09 '23 at 13:45
  • 1
    Hi @ahmedsabriz, thank you for replying... what I want to do is to send the ticket payload to a webhook every time the ticket changes status or the agent adds a response. – jonabtc Feb 10 '23 at 20:29
  • It sounds like you could use a trigger for that instead of an app. – ahmedsabriz Feb 11 '23 at 01:07
  • Yes, but I need to store the app in the zendesk marketplace, so I can't use triggers to do that. – jonabtc Feb 13 '23 at 15:52

1 Answers1

0

You can configure triggers and webhooks to be added to your app as requirements. If you must use a ticket_sidebar app, you can listen to the following events:

var client = ZAFClient.init();
    client.on('ticket.comments.changed', (e) => {
        // Here is the latest comment
        let comment = e[0];
        console.log(comment);

        // Check author role
        console.log((comment.author.role !== "end-user") ? "Comment made by agent" : "Comment made by end user");
        
        // Get ticket object if needed
        client.get('ticket').then(
            (res) => {
                // Send ticket payload to my backend
            },
            (err) => {
                console.error(err);
            }
        )
    });
    client.on('ticket.status.changed', (e) => {
        // Here is the new status
        console.log("Status changed to", e);
        
        // Get ticket object if needed
        client.get('ticket').then(
            (res) => {
                // Send ticket payload to my backend
            },
            (err) => {
                console.error(err);
            }
        )
    });
ahmedsabriz
  • 392
  • 1
  • 3
  • 9
  • I tried that. The `ticket.comments.changed` trigger is never called. But, I fixed it, I am listening to the trigger `ticket.submit.start` and validating when the comment text is empty. Thank you for taking the time to help me!! – jonabtc Feb 14 '23 at 23:18