Zammad and Webhook

At first: I am a total beginner here. Browsed the forum archive for “Zammad”, didn’t find anything related to my issue.

Describe the issue/error/question

I try to trigger my workflow using a POST webhook: the Zammad application calls the webhook (currently everytime a ticket is edited there) and I try to extract the Ticket-ID from the “raw body”.

Basically I want the following Zammad-Node to “Get a ticket” by using that

{{ $node[“Webhook”].json[“body”][“ticket”][“id”] }}

But that fails with “ERROR: Forbidden - perhaps check your credentials?”

I auth to Zammad via Token, the setup tests OK, the token has Admin privileges.

When I edit the Zammad Node to use the Operation “Get many”, it authenticates OK and returns all the tickets.

Maybe I use the wrong field from the webhook for the Ticket ID?

My bigger goal is to export tickets from Zammad and make a pdf out of them or something.
These should then be imported into a DMS (unfortunately not yet a Node available for that).

What is the error message (if any)?

ERROR: Forbidden - perhaps check your credentials?

Information on your n8n setup

  • n8n version: 0.205.0
  • Database: pgsql
  • Running n8n via Docker

Hi @sgw, welcome to the community!

I am actually using a Zammad trigger to send a webhook to n8n, then have the workflow add an article to a ticket. This is working fine for me so far, no auth problems.

I am using an HTTP Request node using OAuth authentication though, as the existing n8n node was rather limited when I looked at it. That said, I just tried fetching a ticket through the default Zammad node and didn’t run into any trouble here with an expression of {{$json["body"]["ticket"]["id"]}}:

Did you enable the agent permissions when generating your token? These were the only ones I needed for this to work:

image

Also, are you running the latest version of Zammad?

Ah, the Agent permissions were the key, it seems, thank you! I had “Admin” etc … simply was wrong.
Now I am that step further and have the whole ticket structure in n8n: great.
Do you have experience with fetching tickets from Zammad, via n8n? My job is to somehow setup an archiving pipeline to put closed tickets into a document managing system.

thanks for the welcome, btw
And yes, latest Zammad, also in a docker-compose stack, both stacks behind a HAproxy reverse proxy.

1 Like

I do have some experience with fetching tickets, but as said not so much with the actual Zammad node unfortunately.

In the past, I’ve used a workflow like this to fetch tickets in a given date range through the API:

That’s an old workflow and the pagination part is way more clumsy than it should be :smiley:

You could still use this as a starting point, though it might be easier to query the Zammad database directly.

Thanks. As I am just starting I won’t notice the clumsiness fully, I assume :wink:
Looking forward to try this and maybe come up with a fresher approach soon.

Could you maybe explain how you set up header auth with zammad?
I manage to get replies from Zammad by doing stuff like:

curl -H "Authorization: Token token=kUYOiSEgn2oJ_bla"  https://ticket.my.tld/api/v1/tickets/

In n8n I added a Header auth account but it seems to be wrong to paste the Token from Zammad into “Value” only. Browsing the forum already … thanks for any pointer.

To me your approach seems more powerful than using the Zammad Node: more explicit queries possible as far as I understand.

So if you want to add an Authorization header with a value of Token token=kUYOiSEgn2oJ_bla , you would need to set it up like so:

In your HTTP Request node, you can then use it like so:

If you’d like to verify the exact request made by n8n, you could generate a test URL using a service such as webhook.site (which simply accepts any HTTP Request and lets you inspect it afterwards):

Hope this helps!

Great, thanks! I was nearly there already … :slight_smile: slowly progressing and learning.

Do you know if it possible to retrieve ticket attachments via API?

seems like: Articles — Zammad documentation

Hm, I haven’t tried this before, but the below approach worked for me and returned all attachments for a single ticket:

This is the result:

If want to re-use this logic for multiple tickets it might be worth putting it in its own workflow, then use an Execute Workflow node whenever you need all attachments for a ticket.

Wow, amazing, didn’t expect that. Thanks. I will look into testing it asap.

Working on my workflow.

If I want to loop over all the tickets coming out of the workflow you showed me in Zammad and Webhook - #5 by MutedJam how would I proceed?

I need to fetch all the articles and attachments per ticket-id.

Maybe another approach would be better: trigger a webhook in Zammad as soon as a ticket gets closed … and by doing so transmit the single ticket-id to n8n. I am not yet sure which approach is better …

EDIT: maybe that’s what you wanted to tell me by pointing at the “Execute Workflow” …

Hi @sgw, I was thinking of a loop like this, going through each ticket and by one and then calling a sub-workflow for the respective ticket:

Using such an approach would make sure only the attachments of one ticket at a time are being processed.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.