Skip to content

Conversation

@BEASTSHRIRAM
Copy link
Contributor

PR Description:

shows how to integrate external ML model APIs with ServiceNow to get AI predictions.

What's Included

  • Script Include to call ML prediction APIs
  • RESTMessageV2 integration example
  • Error handling and logging

Use Cases

  • Predict incident resolution time
  • Auto-classify tickets
  • Get risk scores
  • Smart assignment recommendations
  • Thank you for the opportunity to contribute

Pull Request Checklist

Overview

  • Put an x inside of the square brackets to check each item.
  • I have read and understood the CONTRIBUTING.md guidelines
  • My pull request has a descriptive title that accurately reflects the changes and the description has been filled in above.
  • I've included only files relevant to the changes described in the PR title and description
  • I've created a new branch in my forked repository for this contribution

Code Quality

  • My code is relevant to ServiceNow developers
  • My code snippets expand meaningfully on official ServiceNow documentation (if applicable)
  • I've disclosed use of ES2021 features (if applicable)
  • I've tested my code snippets in a ServiceNow environment (where possible)

Repository Structure Compliance

  • I've placed my code snippet(s) in one of the required top-level categories:
    • Core ServiceNow APIs/
    • Server-Side Components/
    • Client-Side Components/
    • Modern Development/
    • Integration/
    • Specialized Areas/
  • I've used appropriate sub-categories within the top-level categories
  • Each code snippet has its own folder with a descriptive name

Documentation

  • I've included a README.md file for each code snippet
  • The README.md includes:
    • Description of the code snippet functionality
    • Usage instructions or examples
    • Any prerequisites or dependencies
    • (Optional) Screenshots or diagrams if helpful

Restrictions

  • My PR does not include XML exports of ServiceNow records
  • My PR does not contain sensitive information (passwords, API keys, tokens)
  • My PR does not include changes that fall outside the described scope

- Created Script Include to call external ML prediction APIs
- Includes concise documentation with real-world use cases
- Shows how to send incident data and receive predictions
- Production-ready with error handling and logging
@snamjosh snamjosh self-assigned this Oct 27, 2025
@snamjosh snamjosh removed their assignment Oct 27, 2025
@BEASTSHRIRAM
Copy link
Contributor Author

Why ServiceNow devs need this: It's the pattern for any real-time AI integration - from chatbot responses to risk scoring to auto-categorization.

@BEASTSHRIRAM
Copy link
Contributor Author

BEASTSHRIRAM commented Oct 27, 2025

Hey @ravichandra1998g please review
Use Cases of this snippet

  • Predict incident resolution time
  • Auto-classify tickets
  • Get risk scores
  • Smart assignment recommendations
    -The MLPredictionClient integrates ServiceNow with an external ML API to predict incident outcomes like category and resolution time.
    It enables intelligent automation by sending incident data and receiving AI-driven predictions.
    The key line here is:
    var response = request.execute();
  • Thank you for the opportunity to contribute

@BEASTSHRIRAM BEASTSHRIRAM changed the title feature: Add ML Model API Integration snippet useful for servicenow devs feature: Added ML Model API Integration snippet useful for servicenow devs Oct 27, 2025
@ravichandra1998g ravichandra1998g self-assigned this Oct 27, 2025
Copy link
Contributor

@ravichandra1998g ravichandra1998g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, How do you configure the ML to return estimated hours, predicted category and confidence as response?

@BEASTSHRIRAM
Copy link
Contributor Author

BEASTSHRIRAM commented Oct 28, 2025

Appreciate your curiosity here is the code :
var response = request.execute(); var result = JSON.parse(response.getBody()); return { estimated_hours: result.estimated_hours, predicted_category: result.category, confidence: result.confidence };

Explaination=The MLPredictionClient submits incident data to an outside ML API for smart predictions.
The model (externally hosted) is trained to respond with estimated_hours, predicted_category, and confidence in a JSON return.
These values are pulled using JSON.parse(response.getBody()) so as to render ML insights accessible within ServiceNow.
Like for a hackathon i did similar sort of thing but in python we used a Model from huggigface which was pre trained the project was agriculture related for kerala farmers we trained that model on our college servers and loaded more dataset and made it extremely powerfull still that is going onn its not related to this but just said....

Copy link
Contributor

@ravichandra1998g ravichandra1998g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please move this file under RestMessageV2 under Integration as we already have that folder.

This ensures the Repo folder structure is clean.

@BEASTSHRIRAM
Copy link
Contributor Author

Done @ravichandra1998g

Copy link
Contributor

@ravichandra1998g ravichandra1998g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@ravichandra1998g ravichandra1998g merged commit fc46b6a into ServiceNowDevProgram:main Oct 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants