Help creating periodically launched tickets

Infos:

  • Used Zammad version: 2.2.x
  • Used Zammad installation source: DEB repo
  • Operating system: deb 9
  • Browser + version: all

Explanation

We’re already launching tickets via the systemd timers. The ticket data comes from a specific file which contains f. e. the following information:

{
"title":"This is my Ticket-Title",
"group": "Helpdesk",
"article":{"subject":"To-Do","body":"You really need to do your stuff","type":"note","internal":true},
"customer":"periticket@neuwied.de",
"note": "Note"
}

This is working nice so far. In addition to that we’re trying to assign the ticket to an agent at launch. We tried stuff like:

"agent": "$agentemail"
"agent": "$agentlogin"
"agent": "$agentfullname"

Update:
Alright after playing around a bit it seems that the needed attribute is owner_id which probably is the equivalent to the user_id.

So after getting the information from my user with User.find_by(login:"whatever") in rails i’m getting user id: 12.
Therefore using something like this should work:

   {
    "title":"This is my Ticket-Title",
    "group": "Helpdesk",
    "owner_id":"12",
    "article":{"subject":"To-Do","body":"You really need to do your stuff","type":"note","internal":true},
    "customer":"periticket@neuwied.de",
    "note": "Note"
    }

But it just launches a ticket without assigning any owner to it…

I already confirmed that the owner_id really matches the user_id for my user by creating a ticket and assigning it to myself manually.

Is there any documentation which fields can be used for this and how? We didn’t seem to find what we’re looking for on https://docs.zammad.org/en/latest/index.html.

Solution

Meh… silly me. It was a matter of rights after all. Just make sure the user who is creating the tickets has the rights to do this in each group. If this is given, something like this will work:

{
"title":"This is my Ticket-Title",
"group":"Helpdesk",
"owner":"$agentlogin",
"article":{"subject":"To-Do","body":"You really need to do your stuff","type":"note","internal":true},
"customer":"$customerlogin",
"note":"Note",
"tags":"fancy",
"location":"Somewhere"
}
2 Likes

Hi,

you are creating tickets now via REST and a custom script to create scheduled tickets? Or what do you use?

regards
Hannes

Hey,

we created a systemd service for accessing the zammad api periodically.

Example

For creating a “backup control” ticket Mo-Fri at 6am we created two files.

The service-file:

/etc/systemd/system/ticketTimer@backup-control.service

   [Unit]
   Description=periodische Tickets erstellen %I

   [Service]
   ExecStart=/usr/bin/curl -H "Authorization: Token token=$AccessTokenOfTheDefinedUser" -H "Content-Type: application/json"  --data "@/home/zammad/periTickets/%i"  https://$ServerURL/api/v1/tickets
   User=$LinuxUserExecutingThis

The timer-file:

/etc/systemd/system/ticketTimer@backup-control.timer

   [Unit]
   Description=Launch %i Ticket every x

   [Timer]
   OnCalendar=Mon..Fri *-*-* 06:00:00
   #Syntax: DayOfWeek Year-Month-Day Hour:Minute:Second
   #Beispiel: OnCalendar=Mon,Tue *-*-01..04 12:00:00


   [Install]
   WantedBy=timers.target

Inside the .service-file we defined that the data for the ticket comes from a file (/home/zammad/periTickets/%i, %i being whatever is between the @ and the . of the service-file).

So all the information for the api to create a ticket goes into this file:

/home/zammad/periTickets/backup-control

    {
     "title":"Daily backup control",
     "group":"Helpdesk",
     "owner":"$WhoEverTheOwnerShouldBe(leave empty for no owner)",
     "article":{
      "subject":"To-Do",
      "body":"Please check the status of the daily backup\n\nSee https://backupserver for more information.",
      "type":"note",
      "internal":true},
     "customer":"$WhoEverTheCustomerShouldBe",
     "note":"Notiz",
     "tags":"backupcontrol",
    }

Once we have all those files we only need one command to enable the timer:

systemctl enable ticketTimer@backup-control.timer --now

Now the ticket is launched based on the definition inside the timer-File.
To start a ticket manually (for testing) you can do:

systemctl start ticketTimer@backup-control.service

To check if all the timers a set correctly you can do:

systemctl list-timers

Of course you could do all this with cron but we prefer systemd for this :slight_smile:.

3 Likes

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