Calling a REST Message in Virtual Agent and using using users input to give response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 05:41 AM
Ask Your Questions using Virtual Agent.
Step1: Create a new Topic in Virtual Agent Designer.
All>Conversational Interfaces>Designer >Create
Create a new NLU Model or if you already have one used that and create a new Intent for this particular Topic.
Now add some Keywords
Keywords: Words or phrases that users enter to initiate a conversation about the topic. The Virtual Agent Designer automatically adds the Name of the topic as a keyword. Resume topic flow: Toggle to allow a conversation to resume when Natural Language Understanding (NLU) is enabled.
Step 2: Create Flow
In this flow first it will ask if you want to ask something.
If Yes:
It will ask you what do you want to ask.
Then we have used Bot Response Script.
Here we called a Rest Message which I had created Earlier.
Script :
(function execute() {
try {
var body = JSON.stringify({
"contents": [{
"parts": [{
"text": vaInputs.ask_gemini.getValue()
}]
}]
});
gs.log("Hii23"+body);
var r = new sn_ws.RESTMessageV2('Gemini Integratiion', 'POST');
r.setRequestBody(body);
var response = r.execute();
var responseBody = response.getBody();
var res=JSON.parse(responseBody);
var httpStatus = response.getStatusCode();
return res.candidates[0].content.parts[0].text;
} catch (ex) {
var message = ex.message;
}
})()
#NOTE: To use the value of input (from Ask Gemini Node): We have used Inputs variables.
To get the value: vaInputs.ask_gemini.getValue()
For more details visit: Click Here.
Here we get the response:
It will ask if you want to ask further more questions or not.
- If No:
It will end the conversation.
THANKYOU
Abhijeet Singh
ServiceNow Developer
Linked In: www.linkedin.com/in/abhijeet0610

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 12:54 PM
Hi there,
I don't really see the question you are having. What do you exactly need help with?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field