Create incidents from Jira work items

Page your on-call team the moment someone files an urgent Jira work item, for example a customer request in Jira Service Management. A Jira Automation flow creates the incident through the Incidents API, and two more flows acknowledge and resolve it as the work item moves.

1. Create two custom fields in Jira

The flows store the incident's ID and link on the work item.

  1. In Jira, go to Settings β†’ Work items β†’ Fields β†’ Custom fields and click Create custom field.
  2. Select Short text (plain text only) and click Next.
    Custom field type
  3. Name the field incident_id and associate it with all screens.
  4. Repeat for a field named BU_incident_url.

2. Create an incident when a work item is created

  1. In your Jira space, click More actions (…) β†’ Space settings β†’ Automation, then Create flow β†’ Create from scratch. To cover every space, create a global flow under Global administration instead.
  2. Select the Work item created trigger and click Save.
    Work item created trigger
  3. Add a condition, such as high priority, so only urgent work items page on-call.
  4. Add a Send web request action. Set Web request URL to https://incidents.betterstack.com/api/v2/incidents, HTTP method to POST and Web request body to Custom data:

    Custom data
    {
        "name": "{{issue.key}} - {{issue.summary}}",
        "summary": "{{issue.key}} - {{issue.summary}}",
        "requester_email": "{{reporter.emailAddress}}",
        "description": {{issue.description.asJsonString}},
        "policy_id": "{ESCALATION_POLICY_ID}"
    }
    

    Replace {ESCALATION_POLICY_ID} with the ID of the escalation policy to page. Add an Authorization header with your API token:

    Authorization header
    Bearer $TOKEN
    


  5. Check Delay execution of subsequent rule actions.

  6. Add an Edit work item action. Set incident_id to {{webResponse.body.data.id}} and BU_incident_url to https://incidents.betterstack.com/team/YOUR_TEAM_ID/incidents/{{webResponse.body.data.id}}, with your team's ID from its Better Stack URL.

  7. Click Save and enable.

Every new work item that matches your condition now creates a Better Stack incident.

3. Acknowledge and resolve the incident as the work item moves

These flows act on the incidents the flow above created, through the incident_id field. Work items Better Stack created get Acknowledge and Resolve buttons from Better Stack for Jira instead.

  1. Create another flow from scratch with the Work item transitioned trigger. Set To status to In Progress and click Save.
  2. Add a condition: incident_id is not empty.
  3. Add a Send web request action. Set Web request URL to https://incidents.betterstack.com/api/v2/incidents/{{incident_id}}/acknowledge, HTTP method to POST, the same Authorization header as above, and Web request body to Custom data:

    Custom data
    {"acknowledged_by": "{{assignee.displayName}}"}
    
  4. Click Save and enable.

  5. Repeat for resolving: To status Done, a Web request URL ending in /resolve, and this body:

    Custom data
    {"resolved_by": "{{assignee.displayName}}"}
    

Moving a work item to In Progress now acknowledges its incident, and moving it to Done resolves it.

Need help?

Please let us know at hello@betterstack.com.
We're happy to help! πŸ™