Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

AI search via script

anand9
Tera Expert

How can we trigger AI Search from script against a search profile?

I found "AISASearchUtil" but there is no API document available, and this article says not to use it for production purpose.

1 ACCEPTED SOLUTION

kaushal_snow
Giga Sage

@anand9 ,

 

As of now, there is no officially documented, supported server side API for invoking AI Search in production, while you can use AISASearchUtil in non prod environments or for testing, ServiceNow public documentation and REST API references do not include a production grade AI Search query API for external scripts...

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Technical Consultant/Developer

View solution in original post

2 REPLIES 2

kaushal_snow
Giga Sage

@anand9 ,

 

As of now, there is no officially documented, supported server side API for invoking AI Search in production, while you can use AISASearchUtil in non prod environments or for testing, ServiceNow public documentation and REST API references do not include a production grade AI Search query API for external scripts...

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Technical Consultant/Developer

Peter de Bock1
Mega Guru

@anand9 ,  there are multiple AI search API's to use, and we found out that one particular one worked out very well, which is the  "sn_search.ScriptableSearchAPI" API.

It might be an option for too to have a look at it. See this article I just posted;  https://www.servicenow.com/community/servicenow-otto-for-creator/using-ai-search-from-server-side-sc...

 

The script includeAISASearchUtil mentioned here we did not user because;  

  •  It wraps ScriptableSearchAPI, additionally requires an AI Search Assist record producer configuration (rpSysId from aisa_rp_config), and returns JSON. Read its _generateArgs() and _getResults() and you will see why it did not work for us: it whitelists exactly the seven known properties and forwards exactly seven arguments — so there is no way to pass a locale through it, and its displayValues are resolved in the session language. On top of that it evaluates the AI Search Assist UI actions for every result (extra GlideRecord queries plus a scripted visibility check per result per action) — useful for a search bar, dead weight for retrieval. Fine if you want the exact Employee Center behaviour; one layer too many if you just need the ranked results in the right language.

 

regards, Peter