Created
April 19, 2018 18:02
-
-
Save jstanden/0ca0205a3d7bb043b74c0de2bb3da5d6 to your computer and use it in GitHub Desktop.
A Cerb bot behavior for automatically assigning an owner based on To/Cc recipients
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"behavior": { | |
"uid": "behavior_assign_by_to", | |
"title": "Assign new tickets based on 'To:'", | |
"is_disabled": false, | |
"is_private": false, | |
"priority": 50, | |
"event": { | |
"key": "event.mail.received", | |
"label": "New message added to ticket" | |
}, | |
"variables": { | |
"var_assignees": { | |
"key": "var_assignees", | |
"label": "Assignees", | |
"type": "ctx_cerberusweb.contexts.worker", | |
"is_private": "1", | |
"params": [] | |
} | |
}, | |
"nodes": [ | |
{ | |
"type": "switch", | |
"title": "Is new?", | |
"status": "live", | |
"nodes": [ | |
{ | |
"type": "outcome", | |
"title": "Yes", | |
"status": "live", | |
"params": { | |
"groups": [ | |
{ | |
"any": 0, | |
"conditions": [ | |
{ | |
"condition": "is_first", | |
"bool": "1" | |
}, | |
{ | |
"condition": "is_outgoing", | |
"bool": "0" | |
} | |
] | |
} | |
] | |
}, | |
"nodes": [ | |
{ | |
"type": "action", | |
"title": "Parse To/Cc headers for recipients and build a search query", | |
"status": "live", | |
"params": { | |
"actions": [ | |
{ | |
"action": "_set_custom_var", | |
"value": "{% set recipients = headers.to ~ ', ' ~ headers.cc %}\r\n{{'email:(email:' ~ recipients|parse_emails|keys|join(') OR email:(email:') ~ ')'}}", | |
"format": "", | |
"is_simulator_only": "0", | |
"var": "query" | |
} | |
] | |
} | |
}, | |
{ | |
"type": "action", | |
"title": "Match the recipient email addresses to workers", | |
"status": "live", | |
"params": { | |
"actions": [ | |
{ | |
"action": "var_assignees", | |
"search_mode": "quick_search", | |
"quick_search": "{{query}}", | |
"limit": "", | |
"limit_count": "10", | |
"mode": "replace", | |
"worklist_model": { | |
"options": [], | |
"columns": [ | |
"w_title", | |
"a_address_email", | |
"w_is_superuser", | |
"w_at_mention_name", | |
"w_language", | |
"w_timezone" | |
], | |
"params": [], | |
"limit": 10, | |
"sort_by": "w_first_name", | |
"sort_asc": true, | |
"subtotals": "", | |
"context": "cerberusweb.contexts.worker" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "switch", | |
"title": "Do we have a single worker?", | |
"status": "live", | |
"nodes": [ | |
{ | |
"type": "outcome", | |
"title": "Yes", | |
"status": "live", | |
"params": { | |
"groups": [ | |
{ | |
"any": 0, | |
"conditions": [ | |
{ | |
"condition": "var_assignees", | |
"oper": "is", | |
"value": "1" | |
} | |
] | |
} | |
] | |
}, | |
"nodes": [ | |
{ | |
"type": "action", | |
"title": "Set ticket owner", | |
"status": "live", | |
"params": { | |
"actions": [ | |
{ | |
"action": "set_owner", | |
"worker_id": "var_assignees" | |
} | |
] | |
} | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment