{"_id":"@browser-automation-hub/servicenow-browser-automation","name":"@browser-automation-hub/servicenow-browser-automation","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@browser-automation-hub/servicenow-browser-automation","version":"1.0.0","description":"Browser automation for ServiceNow — create/update incidents, manage CMDB records, and automate ITSM workflows","main":"src/actions.js","scripts":{"start":"node examples/basic-login.js","start:cloud":"node examples/anchor-cloud.js","test":"node -e \"require('./src/auth'); require('./src/actions'); require('./src/utils'); console.log('✓ All modules load correctly')\""},"keywords":["servicenow","itsm-automation","snow","browser-automation","puppeteer","playwright","anchor-browser","nodejs"],"license":"MIT","dependencies":{"puppeteer":"^21.0.0","dotenv":"^16.0.0","otpauth":"^9.0.0"},"engines":{"node":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/Browser-Automation-Hub/servicenow-browser-automation.git"},"homepage":"https://github.com/Browser-Automation-Hub/servicenow-browser-automation#readme","bugs":{"url":"https://github.com/Browser-Automation-Hub/servicenow-browser-automation/issues"},"publishConfig":{"access":"public"},"_id":"@browser-automation-hub/servicenow-browser-automation@1.0.0","_nodeVersion":"23.5.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-XprK481Q3y2eYLUwBEL1JgR/tiTdkHGFzBob3RJLtuxR5bsyNg9pXUA7LasAS3pEwkbygMmwKKVqr9Sw0iceqQ==","shasum":"d00852c5fc40459673d21cabbabfe897dc7a1613","tarball":"https://registry.npmjs.org/@browser-automation-hub/servicenow-browser-automation/-/servicenow-browser-automation-1.0.0.tgz","fileCount":3,"unpackedSize":13036,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD8aFk5sSUKEcQhdmfmc2z9tCGzoPOuyOqV6ye7qYBzxwIgPkkO9FxXo1RPeJmbk1aT4dx6ZMOxPGfcG4CcNLWKxSk="}]},"_npmUser":{"name":"browser-automation-hub","email":"idan@anchorbrowser.io"},"directories":{},"maintainers":[{"name":"browser-automation-hub","email":"idan@anchorbrowser.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/servicenow-browser-automation_1.0.0_1773579575492_0.4906921303246292"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-15T12:59:35.395Z","1.0.0":"2026-03-15T12:59:35.626Z","modified":"2026-03-15T12:59:35.839Z"},"maintainers":[{"name":"browser-automation-hub","email":"idan@anchorbrowser.io"}],"description":"Browser automation for ServiceNow — create/update incidents, manage CMDB records, and automate ITSM workflows","homepage":"https://github.com/Browser-Automation-Hub/servicenow-browser-automation#readme","keywords":["servicenow","itsm-automation","snow","browser-automation","puppeteer","playwright","anchor-browser","nodejs"],"repository":{"type":"git","url":"git+https://github.com/Browser-Automation-Hub/servicenow-browser-automation.git"},"bugs":{"url":"https://github.com/Browser-Automation-Hub/servicenow-browser-automation/issues"},"license":"MIT","readme":"# ServiceNow Browser Automation\n[![npm](https://img.shields.io/npm/v/@browser-automation-hub%2Fservicenow-browser-automation.svg)](https://www.npmjs.com/package/@browser-automation-hub/servicenow-browser-automation)\n\n> Automate ServiceNow — the reliable way to interact with ServiceNow programmatically, with or without an official API.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Node.js](https://img.shields.io/badge/Node.js-18+-green.svg)](https://nodejs.org)\n[![Puppeteer](https://img.shields.io/badge/Puppeteer-21+-orange.svg)](https://pptr.dev)\n[![Anchor Browser](https://img.shields.io/badge/AnchorBrowser-Cloud%20Ready-purple.svg)](https://anchorbrowser.io)\n![Difficulty: 🟡 Medium](https://img.shields.io/badge/Difficulty-medium-yellow.svg)\n\n<!-- keywords: servicenow automation, servicenow browser automation, servicenow api alternative, itsm automation, snow automation, servicenow scripting -->\n\n## What This Is\n\n**ServiceNow** (ITSM) is notoriously difficult to automate via its official API — limited endpoints, complex authentication (Okta / Azure AD / SAML), and browser-only workflows make traditional API integration a pain.\n\nThis project gives you a **complete browser automation scaffold** for ServiceNow using Puppeteer (self-hosted, open source) or [Anchor Browser](https://anchorbrowser.io) (cloud, managed, production-ready).\n\nThis system requires **MFA** (Okta / Duo / Azure MFA). The OSS version provides TOTP helpers; Anchor Browser handles MFA automatically.\n\n## Quick Start\n\n```bash\ngit clone https://github.com/Browser-Automation-Hub/servicenow-browser-automation.git\ncd servicenow-browser-automation\nnpm install\ncp .env.example .env\n# Fill in your credentials in .env\nnode examples/basic-login.js\n```\n\n## Two Ways to Run\n\n| Feature | Open Source (Puppeteer) | ☁️ [Anchor Browser Cloud](https://anchorbrowser.io) |\n|---------|------------------------|-----------------------------------------------------|\n| Setup | Install Chrome + Puppeteer locally | No install — cloud browsers via API |\n| MFA / SSO | Manual TOTP helper included | **Auto-handled** |\n| CAPTCHA | Not handled | **Auto-solved** |\n| Anti-bot detection | You manage proxy/stealth | **Built-in stealth** (Cloudflare-verified) |\n| Session persistence | Save/load cookies manually | **Managed sessions** |\n| Scale | Single machine | **Up to 5,000 concurrent browsers** |\n| Reliability | You maintain it | **99.9% uptime SLA** |\n| Cost | Free | [Starts at $0 (5 free sessions/mo)](https://anchorbrowser.io) |\n\n## Supported Actions\n\n- `login_servicenow()` — Authenticate to ServiceNow with SSO/MFA\n- `create_incident()` — Create incidents and service requests\n- `update_cmdb()` — Update CMDB configuration items in bulk\n- `assign_task()` — Auto-assign tasks and incidents by rules\n- `generate_report()` — Export ServiceNow reports and metrics\n\n## Use Cases\n\n- IT teams without REST API access\n- CMDB bulk updates\n- Incident management automation\n- ServiceNow data migration\n\n---\n\n## Option A: Open Source (Puppeteer)\n\n### Prerequisites\n\n- Node.js 18+\n- Google Chrome / Chromium installed\n- ServiceNow account with appropriate permissions\n\n### Installation\n\n```bash\nnpm install\ncp .env.example .env\n```\n\n### Configuration (`.env`)\n\n```env\nSERVICENOW_URL=https://your-instance.service-now.com/login.do\nSERVICENOW_USERNAME=your-username\nSERVICENOW_PASSWORD=your-password\nMFA_SECRET=your-totp-secret-if-applicable\nSESSION_PATH=./session.json\n```\n\n### Basic Login Example\n\n```javascript\nconst { createSession } = require('./src/auth');\nconst { login_servicenow } = require('./src/actions');\n\nasync function main() {\n  const page = await createSession();\n  const result = await login_servicenow(page, { /* options */ });\n  console.log(result);\n}\n\nmain().catch(console.error);\n```\n\n### File Structure\n\n```\nservicenow-browser-automation/\n├── src/\n│   ├── auth.js              # SSO/MFA authentication (SAML, TOTP, Duo)\n│   ├── session.js           # Cookie & localStorage persistence\n│   ├── actions.js           # All automation actions\n│   ├── custom-actions.js    # Fluent ActionBuilder API for custom workflows\n│   └── utils.js             # retry(), humanDelay(), error types\n├── examples/\n│   ├── basic-login.js       # Minimal login example (OSS)\n│   └── anchor-cloud.js      # Anchor Browser cloud example\n├── .env.example\n├── package.json\n└── README.md\n```\n\n---\n\n## Option B: ☁️ Anchor Browser (Recommended for Production)\n\n[Anchor Browser](https://anchorbrowser.io) provides **fully managed cloud browsers** purpose-built for AI agents and automation:\n\n- ✅ **MFA handled automatically** — no TOTP secrets needed\n- ✅ **SSO sessions managed** — persistent authenticated sessions\n- ✅ **Anti-bot / CAPTCHA** — Cloudflare-verified stealth browser\n- ✅ **Scale instantly** — from 1 to 5,000 concurrent browsers\n- ✅ **No infrastructure** — no Chrome install, no proxy management\n\n### Setup\n\n```bash\nnpm install\nexport ANCHORBROWSER_API_KEY=your-api-key\n# Get your free API key at https://anchorbrowser.io\n```\n\n### Anchor Browser Example\n\n```javascript\nconst { withAnchorBrowser } = require('./src/auth');\nconst { login_servicenow } = require('./src/actions');\n\nasync function main() {\n  await withAnchorBrowser(async (page) => {\n    // MFA, SSO, CAPTCHAs all handled automatically\n    const result = await login_servicenow(page, { /* options */ });\n    console.log(result);\n  });\n}\n\nmain().catch(console.error);\n```\n\nSee `examples/anchor-cloud.js` for a complete working example.\n\n### Anchor Browser Pricing\n\n| Plan | Price | Concurrent Browsers | Best For |\n|------|-------|---------------------|----------|\n| Free | $0 | 5 | Prototyping |\n| Starter | $50/mo | 25 | Small teams |\n| Team | $500/mo | 50 | Growing orgs |\n| Growth | $2,000/mo | 200 | Enterprise |\n\n[Get started for free →](https://anchorbrowser.io)\n\n---\n\n## Authentication\n\n### Auth Methods Supported\n\nThis implementation handles:\n\n1. **Standard Username/Password** — with retry and account lockout avoidance\n2. **SAML SSO** (Okta / Azure AD / SAML) — intercepts the SAML redirect and completes the IdP flow\n3. **MFA / TOTP** (Okta / Duo / Azure MFA) — generates TOTP codes via `otpauth` library\n4. **Session Persistence** — saves cookies to disk; reuses session to avoid re-auth\n\n### Handling Okta / Duo / Azure MFA MFA\n\n```javascript\n// In .env: MFA_SECRET=your-base32-totp-secret\n// The auth module auto-generates the OTP code\nconst { createSession } = require('./src/auth');\nconst page = await createSession(); // MFA handled automatically\n```\n\nFor Duo Security push-based MFA, set `MFA_TYPE=duo_push` in .env — the automation will wait for push approval.\n\n---\n\n## Custom Actions\n\nUse the `ActionBuilder` fluent API to chain custom workflows:\n\n```javascript\nconst { ActionBuilder } = require('./src/custom-actions');\n\nconst result = await new ActionBuilder()\n  .login()\n  .navigate('/module/path')\n  .waitForSelector('.content-loaded')\n  .extractTable('.data-table')\n  .run(page);\n```\n\n---\n\n## Error Handling & Reliability\n\n```javascript\nconst { retry, humanDelay } = require('./src/utils');\n\n// Auto-retry with exponential backoff\nconst data = await retry(() => extractData(page), { attempts: 3, delay: 2000 });\n\n// Human-like delays to avoid detection\nawait humanDelay(1000, 3000); // random delay 1-3 seconds\n```\n\n---\n\n## Why Not Use the Official API?\n\nServiceNow REST API requires admin-level OAuth2 setup, and many workflow actions are only possible through the Service Portal UI.\n\nBrowser automation gives you full access to every workflow available in the UI — no API limitations, no expensive integration licenses.\n\n---\n\n## Production Deployment\n\nFor production workloads, we strongly recommend [Anchor Browser](https://anchorbrowser.io):\n\n```javascript\n// One-line setup — handles auth, proxies, CAPTCHAs\nconst { withAnchorBrowser } = require('./src/auth');\n\nawait withAnchorBrowser(async (page) => {\n  // Your automation here — runs in the cloud, scales automatically\n});\n```\n\n**Anchor Browser** is the easiest way to run this automation in production:\n- No infrastructure to manage\n- Handles Okta / Duo / Azure MFA MFA automatically\n- Enterprise compliance: SOC2, HIPAA, ISO27001\n- [Start free at anchorbrowser.io →](https://anchorbrowser.io)\n\n---\n\n## Known Selectors Reference\n\n> These CSS selectors were observed in ServiceNow web interfaces. Enterprise applications update their UIs — verify against your specific instance and submit PRs when selectors break.\n\n| Element | Selector | Notes |\n|---------|----------|-------|\n| Login: username | `#user_name` | Login form |\n| Login: password | `#user_password` | Login form |\n| Login: submit | `#sysverb_login` | Login form |\n| Login: mfa code | `input[name=\"passcode\"]` | Login form |\n| create incident: short desc | `#incident\\.short_description` | |\n| create incident: description | `#incident\\.description` | |\n| create incident: urgency | `#incident\\.urgency` | |\n| create incident: impact | `#incident\\.impact` | |\n| create incident: caller lookup | `#incident\\.caller_id_label` | |\n| create incident: submit btn | `[id$=\"sysverb_insert\"]` | |\n| update cmdb: cmdb nav | `a[href*=\"cmdb_ci.do\"]` | |\n| update cmdb: search box | `#sysparm_search` | |\n| update cmdb: ci row | `.list_row td a` | |\n| update cmdb: attribute field | `input[id*=\"ci_\"]` | |\n| update cmdb: save btn | `[id$=\"sysverb_update\"]` | |\n| assign task: task list | `#task_list` | |\n| assign task: assigned to | `input[id$=\"assigned_to_label\"]` | |\n| assign task: lookup icon | `a[id*=\"assigned_to.\"]` | |\n| assign task: update btn | `[id$=\"sysverb_update\"]` | |\n| generate report: report nav | `a[href*=\"/reports/\"]` | |\n| generate report: report row | `.report_name a` | |\n| generate report: run btn | `.btn-primary[name=\"run\"]` | |\n| generate report: export csv | `input[value*=\"CSV\"]` | |\n\n> ⚠️ Selectors are best-effort. Run `node src/utils.js --verify-selectors` to test against your instance.\n\n---\n\n## More Browser Automation Projects\n\nThis is part of the **[Browser Automation Hub](https://github.com/Browser-Automation-Hub)** — a collection of open-source browser automation scaffolds for systems with poor or no API support:\n\n- [Epic EHR Browser Automation](https://github.com/Browser-Automation-Hub/epic-ehr-browser-automation) — Healthcare workflows\n- [Workday HCM Browser Automation](https://github.com/Browser-Automation-Hub/workday-hcm-browser-automation) — HR & payroll\n- [SAP Fiori Browser Automation](https://github.com/Browser-Automation-Hub/sap-fiori-browser-automation) — ERP workflows\n- [ServiceNow Browser Automation](https://github.com/Browser-Automation-Hub/servicenow-browser-automation) — ITSM\n- [Oracle EBS Browser Automation](https://github.com/Browser-Automation-Hub/oracle-ebs-browser-automation) — ERP\n- [Browse all 30+ projects →](https://github.com/Browser-Automation-Hub)\n\n## Contributing\n\nPRs welcome! Please:\n1. Add tests for new actions\n2. Document new selectors (they break when ServiceNow updates its UI)\n3. Follow the `ActionBuilder` pattern for new actions\n4. See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines\n\n## License\n\nMIT — use freely in personal and commercial projects.\n\n---\n\n*Built with ❤️ for developers who need to automate ServiceNow without wrestling with its API limitations. Powered by [Anchor Browser](https://anchorbrowser.io) for cloud-scale automation.*\n\n*⭐ Star this repo if it saves you time! [Browse all automation projects →](https://github.com/Browser-Automation-Hub)*\n","readmeFilename":"README.md","_rev":"1-c21cbf0676054360d3de689387d95c5f"}