Ticket Automatic Tasks
The five endpoints that set up and manage the rules running on tickets by themselves.
Overview
Automatic tasks are rules that run on tickets by themselves. Every task has two halves: the conditions saying which tickets it looks at, and the results saying what it does to them.
The conditions are department, status, priority and waiting time. The results are moving a ticket, turning its status, changing its priority, assigning it, locking it and replying to the client. A task has to carry at least one field from each half.
The commonest use is closing solved tickets after a while. Take care when a task sends a reply: the rule mails the client on every ticket it matches.
Reference
Listing the Tasks
Returns the rules that run on tickets by themselves.
curl 'https://panel.example.com/api/v1/admin/tickets/auto-tasks' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/tickets/auto-tasks', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/tickets/auto-tasks');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Each row carries both CONDITION and RESULT fields side by side; read them apart.
$tasks = Api::Tickets()->GetTicketAutoTasks()['data'];Creating a Task
Sets up a new rule to run on tickets.
curl -X POST 'https://panel.example.com/api/v1/admin/tickets/auto-tasks' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"name":"Cozulenleri kapat","statuses":["solved"],"delay_time":72,"mark_locked":true}'const res = await fetch('https://panel.example.com/api/v1/admin/tickets/auto-tasks', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Close solved tickets',
statuses: ['solved'], // kosul
delay_time: 72, // kosul
mark_locked: true, // sonuc
}),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/tickets/auto-tasks');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Close solved tickets',
'statuses' => ['solved'],
'delay_time' => 72,
'mark_locked' => true,
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// At least ONE condition and ONE result are needed; sending only conditions gives a 422.
Api::Tickets()->CreateTicketAutoTask([
'name' => 'Close solved tickets',
'statuses' => ['solved'], // condition
'delay_time' => 72, // condition
'mark_locked' => true, // result
]);Reading One Task
Returns a single automatic task.
curl 'https://panel.example.com/api/v1/admin/tickets/auto-tasks/3' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/tickets/auto-tasks/${tid}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/tickets/auto-tasks/' . $tid);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// An empty condition field does NOT narrow the task, it widens it: every department matches.
$task = Api::Tickets()->GetTicketAutoTask(['tid' => $tid])['data'];Updating a Task
Changes the task fields you send.
curl -X PATCH 'https://panel.example.com/api/v1/admin/tickets/auto-tasks/3' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"delay_time":48}'const res = await fetch(`https://panel.example.com/api/v1/admin/tickets/auto-tasks/${tid}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ delay_time: 48 }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/tickets/auto-tasks/' . $tid);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['delay_time' => 48]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The condition-and-result rule is checked on the MERGED set: emptying the last one fails.
Api::Tickets()->UpdateTicketAutoTask(['tid' => $tid, 'delay_time' => 48]);Deleting a Task
Removes an automatic task.
curl -X DELETE 'https://panel.example.com/api/v1/admin/tickets/auto-tasks/3' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/tickets/auto-tasks/${tid}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/tickets/auto-tasks/' . $tid);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// There is NO switch to pause a task; deleting it is the only way to stop it.
Api::Tickets()->DeleteTicketAutoTask(['tid' => $tid]);Pitfalls
A task has to carry at least one condition and at least one result. Sending conditions alone gives a match that does nothing, and sending results alone would give a rule applying to every ticket. Either one missing means the call is refused.
A condition field left empty draws no distinction: an empty department list matches tickets in every department. Reading that as "none" leads to writing a rule that touches the whole installation. To narrow the reach, fill the field in rather than leaving it empty.
A task with the reply field filled writes that text on every ticket matching the condition, and mail goes to the client. Paired with a wide condition, one rule change reaches hundreds of clients at once. Try a new reply rule against a narrow condition first.
With repeat on, a task runs again every time the condition holds. On a rule that replies, that can mean the same text reaching the same client over and over. Leave repeat off for work that should happen once.
Automatic tasks have no live switch; deleting a rule is the only way to stop it. To pause one, save its definition on your side, delete it and create it again later. The recreated task comes back with a new id.
Related Articles
Vielen Dank für Ihre Rückmeldung!
Unser Support-Team ist rund um die Uhr für Sie da, wenn Sie oben nicht fündig werden.