Created
September 14, 2022 12:52
-
-
Save natalyjazzviolin/cc272e0ebf44eb9cb5dfb9e287f94b75 to your computer and use it in GitHub Desktop.
ZIS bundle
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
{ | |
"name": "Post Slack message on ticket creation", | |
"description": "Posts ticket data to Slack channel on ticket creation", | |
"zis_template_version": "2019-10-14", | |
"resources": { | |
"get_zendesk_ticket_http_action": { | |
"type": "ZIS::Action::Http", | |
"properties": { | |
"name": "get_zendesk_ticket_http_action", | |
"definition": { | |
"method": "GET", | |
"path": "/api/v2/tickets/{{$.ticketId}}.json", | |
"headers": [ | |
{ | |
"key": "Authorization", | |
"value": "Bearer {{$.token}}" | |
} | |
] | |
} | |
} | |
}, | |
"post_message_to_slack_http_action": { | |
"type": "ZIS::Action::Http", | |
"properties": { | |
"name": "post_message_to_slack_http_action", | |
"definition": { | |
"method": "POST", | |
"url": "https://slack.com/api/chat.postMessage", | |
"headers": [ | |
{ | |
"key": "Authorization", | |
"value": "Bearer {{$.token}}" | |
} | |
], | |
"requestBody": { | |
"channel": "{{$.channel}}", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "{{$.title}}" | |
}, | |
"fields": [ | |
{ | |
"type": "mrkdwn", | |
"text": "*Subject*" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*Description*" | |
}, | |
{ | |
"type": "plain_text", | |
"text": "{{$.ticketSubject}}" | |
}, | |
{ | |
"type": "plain_text", | |
"text": "{{$.ticketDescription}}" | |
} | |
] | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "{{$.link}}" | |
} | |
} | |
] | |
} | |
} | |
} | |
}, | |
"post_ticket_created_flow": { | |
"type": "ZIS::Flow", | |
"properties": { | |
"name": "post_ticket_created_flow", | |
"definition": { | |
"StartAt": "LoadSettings", | |
"States": { | |
"LoadSettings": { | |
"Type": "Action", | |
"ActionName": "zis:common:action:LoadConfig", | |
"Parameters": { | |
"scope": "slackNotification" | |
}, | |
"ResultPath": "$.settings", | |
"Next": "GetZendeskTicket" | |
}, | |
"GetZendeskTicket": { | |
"Type": "Action", | |
"ActionName": "zis:{app_name}:action:get_zendesk_ticket_http_action", | |
"Parameters": { | |
"token.$": "$.connections.zendesk.access_token", | |
"ticketId.$": "$.input.ticket_event.ticket.id" | |
}, | |
"ResultPath": "$.retrievedTicket", | |
"Next": "PostMessageToSlack" | |
}, | |
"PostMessageToSlack": { | |
"Type": "Action", | |
"ActionName": "zis:{app_name}:action:post_message_to_slack_http_action", | |
"Parameters": { | |
"token.$": "$.connections.slack.access_token", | |
"channel.$": "$.settings.channel", | |
"ticketSubject.$": "$.retrievedTicket.ticket.subject", | |
"ticketDescription.$": "$.retrievedTicket.ticket.description", | |
"title.$": "*_New ticket #{{$.input.ticket_event.ticket.id}}_*", | |
"link.$": "<{{$.input.ticket_event.ticket.id}}| View" | |
}, | |
"ResultPath": "$.postMessageResponse", | |
"Next": "Done" | |
}, | |
"Done": { | |
"Type": "Succeed" | |
} | |
} | |
} | |
} | |
}, | |
"post_ticket_updated_flow": { | |
"type": "ZIS::Flow", | |
"properties": { | |
"name": "post_ticket_updated_flow", | |
"definition": { | |
"StartAt": "GetZendeskTicket", | |
"States": { | |
"GetZendeskTicket": { | |
"Type": "Action", | |
"ActionName": "zis:{app_name}:action:get_zendesk_ticket_http_action", | |
"Parameters": { | |
"token.$": "$.connections.zendesk.access_token", | |
"ticketId.$": "$.input.ticket_event.ticket.id" | |
}, | |
"ResultPath": "$.retrievedTicket", | |
"Next": "PostMessageToSlack" | |
}, | |
"PostMessageToSlack": { | |
"Type": "Action", | |
"ActionName": "zis:{app_name}:action:post_message_to_slack_http_action", | |
"Parameters": { | |
"token.$": "$.connections.slack.access_token", | |
"channel.$": "$.settings.channel", | |
"ticketSubject.$": "$.retrievedTicket.ticket.subject", | |
"ticketDescription.$": "$.retrievedTicket.ticket.description", | |
"title.$": "*_Updated ticket #{{$.input.ticket_event.ticket.id}}_*", | |
"link.$": "{{$.input.ticket_event.ticket.id}}| View" | |
}, | |
"ResultPath": "$.postMessageResponse", | |
"Next": "Done" | |
}, | |
"Done": { | |
"Type": "Succeed" | |
} | |
} | |
} | |
} | |
}, | |
"post_message_to_slack_on_ticket_created": { | |
"type": "ZIS::JobSpec", | |
"properties": { | |
"name": "post_message_to_slack_on_ticket_created_job_spec", | |
"event_source": "support", | |
"event_type": "ticket.TicketCreated", | |
"flow_name": "zis:{app_name}:flow:post_ticket_created_flow" | |
} | |
}, | |
"post_message_to_slack_on_ticket_updated": { | |
"type": "ZIS::JobSpec", | |
"properties": { | |
"name": "post_message_to_slack_on_ticket_updated_job_spec", | |
"event_source": "support", | |
"event_type": "ticket.CommentAdded", | |
"flow_name": "zis:{app_name}:flow:post_ticket_updated_flow" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment