
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2019 10:29 PM
Hello,
Is it possible to use, for example XMLHttpRequest API and GET, to retrieve information from external API and show it as VA response.
Thank you!
Solved! Go to Solution.
- Labels:
-
Virtual Agent

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2019 10:29 AM
Hi there,
Sure this is possible.
I did a real quick test, 10 minutes, gave me already Incident details from an other instance.
Just added a Script Action Utility with below code. Most of it just generated thru the API Explorer within ServiceNow.
(function execute() {
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://some-instance.service-now.com/api/now/table/incident/fb1fb9e44f67f300e7fe0ab18110c74f');
request.setHttpMethod('GET');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'user';
var password = 'password';
request.setBasicAuth(user,password);
request.setRequestHeader("Accept", "application/json");
var response = request.execute();
vaVars.api = response.getBody();
})()
In the Topic, on a Text Utility just added:
(function execute() {
return vaVars.api;
})()
So yes, very well possible.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2019 10:13 AM
While I have not seen an example of this, it should be possible as you can use scripts with VA.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2019 10:29 AM
Hi there,
Sure this is possible.
I did a real quick test, 10 minutes, gave me already Incident details from an other instance.
Just added a Script Action Utility with below code. Most of it just generated thru the API Explorer within ServiceNow.
(function execute() {
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://some-instance.service-now.com/api/now/table/incident/fb1fb9e44f67f300e7fe0ab18110c74f');
request.setHttpMethod('GET');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'user';
var password = 'password';
request.setBasicAuth(user,password);
request.setRequestHeader("Accept", "application/json");
var response = request.execute();
vaVars.api = response.getBody();
})()
In the Topic, on a Text Utility just added:
(function execute() {
return vaVars.api;
})()
So yes, very well possible.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 07:02 AM
Hi Mark,
Do we have option to show response in virtual agent through external api without using any script.
Regards,
Neha Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2024 09:38 AM
I think what you are looking for is 'Actions'
I have set these up with spokes for both internal and external services.