# Jitbit Auto-Triage — Type Field + BookStack + Tech Note

## Overview

<table id="bkmrk-fieldvalue-workflow-"><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td>Workflow ID</td><td>llP1pezJvYAGKjYA</td></tr><tr><td>n8n URL</td><td>[https://n8n.pbr.org.au/workflow/llP1pezJvYAGKjYA](https://n8n.pbr.org.au/workflow/llP1pezJvYAGKjYA)</td></tr><tr><td>Status</td><td>Active</td></tr><tr><td>Trigger</td><td>Webhook — called by a Jitbit automation rule on every new ticket</td></tr><tr><td>Webhook URL</td><td>`https://n8n.pbr.org.au/webhook/jitbit-ticket-triage`</td></tr><tr><td>Systems</td><td>Jitbit Helpdesk (caller), Anthropic Claude API (classifier), BookStack (documentation search), Jitbit API (write-back)</td></tr><tr><td>AI Model</td><td>claude-haiku-4-5-20251001</td></tr></tbody></table>

---

## Purpose

This workflow automatically triages every new Jitbit helpdesk ticket. When a ticket is created, Jitbit fires an automation rule that POSTs the ticket details to this n8n webhook. The workflow then:

1. Uses Claude Haiku (Anthropic API) to classify the ticket as an ITIL type and extract a triage summary and BookStack search keywords.
2. Sets the ticket's **Type** custom field in Jitbit to the classified value.
3. Searches BookStack for relevant internal documentation using the AI-extracted keywords.
4. Posts a private tech-only comment to the ticket containing the ITIL type, a triage summary, and links to relevant BookStack pages.

This gives attending technicians an immediate structured summary and relevant documentation links before they even open the ticket.

---

## Jitbit Automation Rule

The workflow is triggered by a Jitbit automation rule (not a Jitbit AI External Tool — the trigger is a direct HTTP call, not routed through the Jitbit AI assistant). The rule is configured as:

<table id="bkmrk-settingvalue-trigger"><thead><tr><th>Setting</th><th>Value</th></tr></thead><tbody><tr><td>Trigger</td><td>Ticket is created</td></tr><tr><td>Action</td><td>Send HTTP request</td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>URL</td><td>`https://n8n.pbr.org.au/webhook/jitbit-ticket-triage`</td></tr><tr><td>Post Data</td><td>`ticket_id=#ticketId#&subject=#subject#&body=#body#&category=#category#&tags=#tags#`</td></tr></tbody></table>

Jitbit substitutes the `#ticketId#`, `#subject#`, `#body#`, `#category#`, and `#tags#` tokens with the actual ticket values before sending the POST request.

---

## How It Works

### Step 1 — Receive webhook from Jitbit

The webhook node receives the POST body from Jitbit containing `ticket_id`, `subject`, `body`, `category`, and `tags`.

### Step 2 — Classify with Claude

The workflow POSTs to the Anthropic Messages API (`https://api.anthropic.com/v1/messages`) using the `claude-haiku-4-5-20251001` model. The system prompt instructs Claude to act as an ITIL-aligned IT helpdesk triage assistant for PBR and respond with raw JSON only (no markdown). The user message contains the ticket subject, category, tags, and body.

Claude returns a JSON object with three fields:

<table id="bkmrk-fielddescription-typ"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td>`type`</td><td>ITIL classification — one of: Incident, Problem, Service Request, Change Request, Event</td></tr><tr><td>`bookstack_query`</td><td>3-6 keyword search terms for finding relevant internal documentation</td></tr><tr><td>`triage_summary`</td><td>2-3 sentence plain-English summary of the issue for the attending technician</td></tr></tbody></table>

The Parse Classification node strips any markdown code fences from the response (Claude Haiku occasionally wraps JSON in backticks despite instructions) before parsing the JSON.

### Step 3 — Parallel branches

After parsing, two branches run in parallel:

- **Branch A — Set Type Custom Field:** POSTs to `https://helpdesk.pbr.org.au/api/SetCustomField` with `ticketId`, `fieldId=1` (the Type field), and the option ID corresponding to the classified type.
- **Branch B — Search BookStack:** Calls `https://bookstack.pbr.org.au/api/search` with the AI-extracted keywords, returning up to 5 results.

Both branches feed into a Merge node that waits for both to complete before continuing.

### Step 4 — Build and post tech note

The Build Tech Note node constructs a private comment body combining the ITIL type, triage summary, and formatted BookStack links with content previews. The `ticket_id` and triage fields are read directly from the Parse Classification node output (not from the merge) to ensure they are never overwritten by the empty response body from the SetCustomField API call.

The comment is posted to Jitbit via `POST /api/comment` with `forTechsOnly=true`, making it visible only to technicians.

### Step 5 — Respond

The workflow returns a JSON confirmation to Jitbit: `{ "result": "Triage complete. Type set to: X. Tech note posted to ticket." }`.

---

## ITIL Type to Custom Field Option ID Mapping

The Jitbit Type custom field (Field ID: 1) uses dropdown option IDs. The mapping is hardcoded in the Parse Classification node:

<table id="bkmrk-itil-typeoption-idde"><thead><tr><th>ITIL Type</th><th>Option ID</th><th>Definition</th></tr></thead><tbody><tr><td>Incident</td><td>1</td><td>Unplanned interruption to service (e.g. outage, crash, failure, offline, broken)</td></tr><tr><td>Problem</td><td>28</td><td>Underlying root cause investigation of one or more recurring incidents</td></tr><tr><td>Service Request</td><td>3</td><td>Routine pre-approved request (e.g. password reset, new laptop, software install)</td></tr><tr><td>Change Request</td><td>4</td><td>Planned alteration, addition, or removal of IT systems</td></tr><tr><td>Event</td><td>29</td><td>Automated monitoring alert (e.g. server monitoring trigger)</td></tr></tbody></table>

If Claude returns an unrecognised type value, the option ID defaults to 1 (Incident).

---

## Example Tech Note Output

```
🤖 AI Triage

Type: Incident

Summary: The network printer at Belgrave station has been offline since 8am, preventing 
staff from printing boarding passes. Immediate investigation of printer connectivity 
and network status is required.

📚 Relevant Documentation:
• Fault Finding - Belgrave Ticket Printers (page)
  https://bookstack.pbr.org.au/books/printers/page/fault-finding-belgrave-ticket-printers
  Issues with any of the Zebra ZD421 Belgrave Ticket printers where it is not possible to ge...

• Printer Setup Guide (page)
  https://bookstack.pbr.org.au/books/endpoint-devices/page/printer-setup
  Steps to configure network printers at PBR sites...
```

---

## Nodes

<table id="bkmrk-nodetypepurpose-rece"><thead><tr><th>Node</th><th>Type</th><th>Purpose</th></tr></thead><tbody><tr><td>Receive from Jitbit AI</td><td>Webhook (POST, responseMode: responseNode)</td><td>Receives ticket data from Jitbit automation rule</td></tr><tr><td>Classify with Claude</td><td>HTTP Request (POST)</td><td>Calls Anthropic API with ticket content; returns ITIL type, triage summary, and search query</td></tr><tr><td>Parse Classification</td><td>Set</td><td>Strips markdown fences; parses JSON; maps type string to option ID; extracts ticket\_id and subject from webhook input</td></tr><tr><td>Set Type Custom Field</td><td>HTTP Request (POST)</td><td>Calls Jitbit `/api/SetCustomField` to set Field ID 1 to the classified type option ID</td></tr><tr><td>Search BookStack</td><td>HTTP Request (GET)</td><td>Searches BookStack with AI-extracted keywords; returns up to 5 results</td></tr><tr><td>Combine Triage + Docs</td><td>Merge (combineByPosition)</td><td>Waits for both parallel branches to complete</td></tr><tr><td>Build Tech Note</td><td>Set</td><td>Assembles the private comment body; reads triage fields from Parse Classification node directly to avoid merge overwrite</td></tr><tr><td>Post Tech Note to Jitbit</td><td>HTTP Request (POST)</td><td>Posts private tech-only comment to the ticket via Jitbit `/api/comment`</td></tr><tr><td>Respond to Jitbit</td><td>Respond to Webhook</td><td>Returns confirmation JSON to Jitbit</td></tr></tbody></table>

---

## Credentials

<table id="bkmrk-credentialtypeused-f"><thead><tr><th>Credential</th><th>Type</th><th>Used For</th></tr></thead><tbody><tr><td>Anthropic API Key</td><td>HTTP Header Auth (`x-api-key`)</td><td>Claude Haiku API calls</td></tr><tr><td>Jitbit API Token</td><td>HTTP Bearer Auth</td><td>SetCustomField and comment POST calls to Jitbit</td></tr><tr><td>BookStack Token</td><td>HTTP Header Auth (`Authorization: Token id:secret`)</td><td>BookStack search API</td></tr></tbody></table>

---

## Known Quirks

- **Claude Haiku and markdown fences:** Despite the system prompt instructing raw JSON output, Claude Haiku 4.5 occasionally wraps its response in markdown code fences (``). The Parse Classification node strips these defensively before parsing.
- **Merge node field overwrite:** The SetCustomField API returns an empty response body (`{}`), which causes a `combineByPosition` merge to overwrite the triage fields from the other branch. This is worked around by having the Build Tech Note node reference the Parse Classification node directly via `.item.json.*` rather than relying on `` from the merge output.
- **UpdateTicket does not support custom fields:** The Jitbit `/api/UpdateTicket` endpoint does not accept custom field parameters. The dedicated `/api/SetCustomField` endpoint must be used instead.

---

## Maintenance Notes

- **AI model:** The workflow uses `claude-haiku-4-5-20251001`. Check Anthropic's model deprecation schedule periodically. To update the model, edit the `jsonBody` parameter in the Classify with Claude node.
- **Type option IDs:** If the Jitbit Type custom field options are changed (added, renamed, or reordered), update the option ID mapping object in the Parse Classification node. Current IDs can be verified via `GET https://helpdesk.pbr.org.au/api/customfields`.
- **Jitbit API token:** The token is stored as an HTTP Bearer Auth credential. Regenerate at `https://helpdesk.pbr.org.au/User/Token` if the token expires or is revoked.
- **Anthropic API key:** Stored as HTTP Header Auth with name `x-api-key`. Update in n8n credentials if the key is rotated.
- **BookStack credential:** Uses a `Token id:secret` format. Regenerate under the Claude\_AI user in BookStack admin if access is revoked.