ServiceNow Integration
Connect ServiceNow ITSM to TR-AI: integration user or OAuth client credentials, the incident Business Rule, triage group, and how replies, work notes and resolution work.
What TR-AI does on an incident
| Situation | What TR-AI does in ServiceNow |
|---|---|
| Confident answer (auto mode) | Posts the answer as an Additional comment (customer visible), then sets State = Resolved with a close code and close notes |
| Draft (assisted mode or medium confidence) | Posts the draft as a Work note and queues it in your TR-AI dashboard for one-click approval |
| Can't answer | Posts a Work note with what it found, optionally an acknowledgement comment, and assigns the incident to your triage group |
| Caller replies | Answers the new Additional comment in context — unless the incident is assigned to someone or an agent has commented |
| Work notes, TR-AI's own comments | Ignored |
Step 1 — Create the integration user
- 1Create a userSystem Security → Users → New. User ID e.g.
tr_ai.integration, tick Web service access only, set a password. - 2Grant rolesAdd the
itilrole (read/write incidents). The user must also be able to readsys_journal_field(comments/work notes),sys_user,sys_user_groupandsys_choice— grant read ACLs or a custom role if your instance restricts them. - 3Optional: create a Triage groupUser Administration → Groups → New, name
Triage. Incidents TR-AI can't answer are assigned there (you can choose another group name in TR-AI).
Alternative: OAuth client credentials
On Washington DC or later you can use OAuth instead of a password: System OAuth → Application Registry → New → Create an OAuth API endpoint for external clients. Enable the client_credentials grant (system property glide.oauth.inbound.client.credential.grant_type.enabled = true) and set the OAuth Application User to the integration user above. Enter the client ID and secret in TR-AI.
Step 2 — Enter the credentials in TR-AI
Choose ServiceNow at sign-up (or use Update credentials on the dashboard's ServiceNow setup card) and enter the instance URL (e.g. https://acme.service-now.com) and the username/password or OAuth client. TR-AI reads one incident to verify access — nothing is saved if that fails.
Step 3 — Add the Business Rule
- 1Create the ruleSystem Definition → Business Rules → New. Name
TicketResolve AI webhook, Table Incident [incident], tick Advanced. - 2When to runWhen = after, tick Insert and Update. No filter conditions — the script decides.
- 3Paste the scriptCopy the script from your dashboard's ServiceNow setup card — it already contains your webhook URL with its secret
keyand your integration user — into the Advanced tab, and save.
(function executeRule(current, previous /*null when async*/) {
// TicketResolve AI — send new incidents and caller comments to TR-AI.
var isNew = current.operation() == 'insert';
var commented = !isNew && current.comments.changes();
if (!isNew && !commented) return;
// Never send TR-AI's own comments back.
if (gs.getUserName() == 'tr_ai.integration') return;
var body = {
event: isNew ? 'created' : 'comment',
sys_id: current.getUniqueValue(),
number: current.getValue('number'),
short_description: current.getValue('short_description') || '',
description: current.getValue('description') || '',
caller_name: current.caller_id.getDisplayValue(),
caller_email: current.caller_id.email.toString(),
caller_user: current.caller_id.user_name.toString(),
comment: isNew ? '' : current.comments.getJournalEntry(1),
comment_author: gs.getUserName()
};
var r = new sn_ws.RESTMessageV2();
r.setEndpoint('https://ticketresolve.ai/api/integrations/servicenow/webhook/<trial-id>?key=<your-key>');
r.setHttpMethod('POST');
r.setRequestHeader('Content-Type', 'application/json');
r.setRequestBody(JSON.stringify(body));
r.setHttpTimeout(10000);
r.executeAsync();
})(current, previous);?key= part of the URL. Requests without the right key are rejected. If the key ever leaks, contact support to rotate it and paste the new URL.Step 4 — Import history and go live
- TR-AI imports resolved and closed incidents from the selected window. The answer is the last agent Additional comment (or the close notes); work notes are stored as internal context only and never quoted to callers.
- New accounts start in assisted mode: drafts appear as work notes and in the dashboard for approval. Switch assisted mode off when you trust the answers.
- Test it: create an incident as a test caller with a question your knowledge base answers, then check the work note / comment.
Resolution details
- State is set to
6(Resolved). TR-AI reads your active close codes and uses Solution provided (or Solved (Permanently) on older releases). Close notes contain the reply. - Approving a draft from the dashboard posts it as an Additional comment and resolves the incident the same way; rejecting assigns it to the triage group.
- Delivery failures (for example an expired password) show on the dashboard's integration health, are sent to Slack if configured, and leave a work note with the unsent reply.
Troubleshooting
| Symptom | Check |
|---|---|
| Credential check returns 401 | Password, "Web service access only" user, or the OAuth Application User |
| Credential check returns 403 | The integration user needs the itil role |
| Follow-ups never answered | Read access to sys_journal_field, and that the incident is not assigned to an agent |
| Nothing arrives at TR-AI | Business Rule active, After + Insert/Update, Advanced ticked; outbound HTTP allowed from the instance (System Logs → Outbound HTTP Requests) |
| Incident not resolved | Data policies requiring extra fields on Resolved — TR-AI still posts the comment; check the work note |