Featured Answer:
PagerDuty is used for on-call and incident response. Browser automation provides schedule management, escalations, and postmortem data sync when API access is limited or UI-based.
Table of Contents
Introduction
PagerDuty is used for incident response, on-call scheduling, escalation policies, and alerting. While PagerDuty offers a REST API, browser automation provides a powerful solution for managing on-call schedules, escalations, and postmortem data sync when API access is limited or when teams rely on the PagerDuty web UI.
Why Use Browser Automation for PagerDuty?
- Limited API Access: API tokens and rate limits can restrict bulk or UI-only workflows
- On-Call Schedules: View and edit schedules, overrides, and rotations from the portal when API or integrations are restricted
- Escalations: Manage escalation policies, trigger or escalate incidents, and view escalation history from the UI
- Postmortem Data Sync: Export incident and response data for postmortems; sync to docs or sheets when API export is limited
- UI-Only Features: Many schedule and reporting views are easiest via the web interface
- Cross-Service and Cross-Team: Operate across services and teams in one session
- Audit and Compliance: Export activity and response data for governance reviews
Setting Up PagerDuty Automation
Here's how to automate on-call schedules, escalations, and postmortem sync in PagerDuty using browser automation:
import { chromium } from 'playwright';
const response = await fetch("https://api.anchorbrowser.io/api/sessions", {
method: "POST",
headers: {
"anchor-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
'headless': false,
'proxy': { 'type': 'residential', 'country': 'US' }
}),
});
const { id } = await response.json();
const connectionString = `wss://connect.anchorbrowser.io?apiKey=YOUR_API_KEY&sessionId=${id}`;
const browser = await chromium.connectOverCDP(connectionString);
const context = browser.contexts()[0];
const ai = context.serviceWorkers()[0];
const page = context.pages()[0];
await page.goto("https://app.pagerduty.com");
await ai.evaluate(JSON.stringify({
prompt: 'Log in to PagerDuty using the provided credentials. Complete SSO or 2FA if required and wait for the home or dashboard to load.'
}));
Use Case 1: On-Call Schedules
View and manage schedules and overrides from the PagerDuty web UI:
const runScheduleAdmin = async (page, ai, criteria) => {
await ai.evaluate(JSON.stringify({
prompt: 'Navigate to People > Schedules (or On-Call Schedules). Open the schedule list or a specific schedule.'
}));
await page.waitForLoadState('networkidle');
await ai.evaluate(JSON.stringify({
prompt: criteria.action === 'override'
? `Add or edit an override for schedule ${criteria.scheduleName || 'current'}. Set user and time range. Save.`
: criteria.action === 'audit'
? 'Extract current schedule and layer assignments: schedule name, layers, users, rotation. Return as structured JSON.'
: 'List schedules and current on-call users. Return as JSON array.'
}));
await page.waitForLoadState('networkidle');
const result = await ai.evaluate(JSON.stringify({
prompt: 'Return summary: schedule updated or current config. As JSON. No secrets.'
}));
return { result: typeof result === 'string' ? JSON.parse(result) : result, completedAt: new Date().toISOString() };
};
Use Case 2: Escalations
Manage escalation policies and incident escalation from the portal:
const runEscalationOps = async (page, ai, criteria) => {
await ai.evaluate(JSON.stringify({
prompt: 'Navigate to Services > Escalation Policies (or Incidents). Open list or a specific policy.'
}));
await page.waitForLoadState('networkidle');
await ai.evaluate(JSON.stringify({
prompt: criteria.action === 'escalate'
? `Escalate incident(s) matching ${criteria.scope || 'current open'}. Do not escalate without criteria.`
: criteria.action === 'audit'
? 'Extract escalation policies: name, levels, targets, services. Return as structured JSON.'
: 'List open incidents and escalation status. Return as JSON array.'
}));
await page.waitForLoadState('networkidle');
const summary = await ai.evaluate(JSON.stringify({
prompt: 'Return JSON: { processed: number, action: string }.'
}));
return { ...JSON.parse(summary), completedAt: new Date().toISOString() };
};
Use Case 3: Postmortem Data Sync
Export incident and response data for postmortems and sync to docs or sheets:
const runPostmortemSync = async (page, ai, criteria) => {
await ai.evaluate(JSON.stringify({
prompt: 'Navigate to Incidents. Apply date range and filters for resolved or triggered incidents.'
}));
await page.waitForLoadState('networkidle');
await ai.evaluate(JSON.stringify({
prompt: criteria.action === 'export'
? 'Export incident list (CSV or report) if available. Wait for download. Otherwise extract table data as JSON.'
: 'List incident summary: id, title, service, status, triggered_at, resolved_at, responders. Return as JSON array.'
}));
const download = await page.waitForEvent('download', { timeout: 20000 }).catch(() => null);
const path = download ? await download.path() : null;
if (path && criteria.syncTo) {
await ai.evaluate(JSON.stringify({
prompt: `Use exported data to sync or append to ${criteria.syncTo} (e.g. Google Sheet or doc). Do not expose PII or secrets.`
}));
}
return { path, completedAt: new Date().toISOString() };
};
Exporting Activity and Audit Data
Pull incident history and audit data for compliance:
const exportPagerDutyActivity = async (page, ai, scope) => {
await ai.evaluate(JSON.stringify({
prompt: scope === 'audit'
? 'Navigate to Account Settings or Audit Log. Set date range. Export or copy audit events.'
: 'Navigate to Incidents or Reports. Export incident history or response report. Wait for download if available.'
}));
const download = await page.waitForEvent('download', { timeout: 20000 }).catch(() => null);
return download ? await download.path() : null;
};
Best Practices for PagerDuty Automation
- Security: Use least-privilege API tokens and SSO; never log credentials; respect PagerDuty ToS
- On-Call Schedules: Prefer API where available; use browser for one-off overrides or when UI is required
- Escalations: Do not bypass escalation policies; use automation for audit and export, not to skip levels
- Postmortem Sync: Export only necessary fields; redact PII and secrets before syncing to external docs
- Rate Limits: Add delays between actions to stay within PagerDuty rate limits
- Error Handling: Retry on session timeout; handle SSO and 2FA gracefully
- Compliance: Align automation with your org's incident response and security policies
Handling Authentication
PagerDuty supports SSO (SAML, etc.) and 2FA:
const handlePagerDutyAuth = async (page, ai, credentials) => {
await page.goto("https://app.pagerduty.com/login");
await ai.evaluate(JSON.stringify({
prompt: 'Sign in with the provided credentials. If SSO is required, complete org SSO.'
}));
await ai.evaluate(JSON.stringify({
prompt: 'If 2FA is required, enter code from app or device. Wait for PagerDuty home or dashboard to load.'
}));
await page.waitForLoadState('networkidle');
};
Resources
- Anchor Browser Documentation - API reference and guides
- Anchor Browser Playground - Try browser automation in your browser
Conclusion
Browser automation provides a flexible alternative to API access for PagerDuty on-call and incident response workflows. By using intelligent browser agents, you can automate on-call schedule management, escalation operations, and postmortem data sync directly from the PagerDuty web UI. Whether you need to manage schedules and overrides, handle escalations, or export incident data for postmortems, browser automation enables efficient on-call and IR when API access is limited or when teams work in the portal.
Start automating your PagerDuty schedules, escalations, and postmortem sync today.