# Paging Critical Incidents to PagerDuty using ClearFeed Automations

ClearFeed can automatically trigger PagerDuty incidents for urgent or high-priority requests. This recipe walks you through configuring a webhook to send events to PagerDuty whenever a critical ticket is created or updated.

## **Set Up the PagerDuty Integration**

Use ClearFeed Automations to send a webhook to PagerDuty’s Events API.

Steps:

* Create a new Automation in ClearFeed.
* Set the trigger to **“Ticket Created”** or **“Ticket Updated”**.
* Add a **Webhook Action** that posts to the PagerDuty Events API.
* For API reference: [PagerDuty Events API v2 Overview](https://developer.pagerduty.com/docs/events-api-v2-overview)
* For configuring the webhook in ClearFeed: [Webhook Actions](/clearfeed-help-center/clearfeed-helpdesk/automations.md#webhook)

## **Identify High-Priority Tickets**

You can decide which tickets should trigger a PagerDuty incident using:

* Manually assigned priorities (e.g., **High** or **Urgent**)
* ClearFeed's ML classifier to auto-label urgent requests
* Separate collections for high-value customers
* A custom AI prompt to compute priority dynamically
  * Configure the prompt to set priority
  * Trigger the PagerDuty webhook when the ticket priority becomes **Urgent**
  * See: [Auto-fill Fields with AI](/clearfeed-help-center/clearfeed-helpdesk/automations/automation-actions.md#auto-fill-fields)

## Example automation to identify and escalate high priority tickets with AI

This section shows an end-to-end example of using AI to classify new requests and automatically trigger a PagerDuty webhook for critical incidents.

### Overview

The automation flow works as follows:

* **Trigger** → On Ticket Creation
* **Action 1** → Use AI to classify if the ticket is critical
* **Condition** → Check if the classification returns `True`
* **Action 2** → Call PagerDuty webhook

### Step-by-Step Setup

Login to the ClearFeed Web Application, go to `More` on the Left Nav and select `Automate`. Create a new Automation as follows:

#### 1. Set the trigger

1. Click `Create automation`.
2. Click `Add trigger` and set the Trigger to `Ticket Creation`.
3. (Optional) Add a small delay (e.g., 1 minute). This allows for additional context to be gathered if the user types multiple messages quickly.

#### 2. Use AI to classify the ticket

4. In the `Action` block, click `Add action` and choose `Auto-fill Fields`.
5. Provide instructions to the AI to classify the request. Here's an example prompt:

   ```
   ## Task
   You are given a Conversation between the requester and the responders. Your job is to generate accurate values for the field below.

   - The Conversation includes messages, each prefixed with its author type — either **Requester** or **Responder**
   - Read all the messages carefully in the order they were sent.
   - Use context from both the Requester and the Responder to determine the correct field values.

   ## Conversation:
   {{request.all_messages}}

   ## Field

   ### Name
   is_critical:

   ### Description
   Whether the request represents a critical incident that requires immediate paging

   ### Values

   * True
     * Return a value of True if the request indicates a critical issue that requires immediate attention. Examples:
     * "Production is down"
     * "Our API is returning 500 errors"
     * "Users cannot log in"
     * "Database connection failed"
     * "Payment processing is broken"

   * False
     * Return a value of False for non-critical issues or routine requests. Examples:
     * "How do I configure the widget?"
     * "When will feature X be released?"
     * "Minor UI issue on the settings page"
     * "Can you update my permissions?"
   ```
6. In the `Output Configuration`, select `Create Automation Variables` and click `Add Variable`:
   * **Variable Name:** `is_critical`
   * **Data Type:** Boolean
   * **Description:** Whether the request represents a critical incident requiring immediate paging
   * **Required:** Yes
7. Use the test interface to test the prompt on previous requests and refine as needed.

#### 3. Add a condition for critical tickets

8. Click `Add a Condition` to filter which tickets should trigger the PagerDuty webhook.
9. Select the `Action - is_critical` field.
10. Set the condition to `is set to` - `True`

#### 4. Configure the PagerDuty webhook

11. Add another action below the condition and select `Webhook`.
12. Configure the webhook to post to the PagerDuty Events API v2:

```json
{
  "routing_key": "YOUR_PAGERDUTY_INTEGRATION_KEY",
  "event_action": "trigger",
  "dedup_key": "{{request.id}}",
  "payload": {
    "summary": "{{request.title}}",
    "severity": "critical",
    "source": "ClearFeed",
    "custom_details": {
      "request_url": "{{request.web_url}}",
      "requester": "{{request.requester.name}}"
    }
  }
}
```

13. Set the HTTP method to `POST` and the URL to `https://events.pagerduty.com/v2/enqueue`.

#### 5. Save and activate

14. Select the Collection(s) where this automation should apply.
15. Click `Save` to activate the automation.

## **Best Practices**

* Test with non-critical tickets before enabling on production channels.
* Add safeguards in your automation to avoid noise or accidental paging.
* Review automation rules periodically to ensure only real incidents trigger PagerDuty.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clearfeed.ai/clearfeed-help-center/advanced-recipes/paging-critical-incidents-to-pagerduty-using-clearfeed-automations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
