Using dynamic portal urls with Virtual Agent AI Search results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 05:21 AM
Hey all.
As part of our Virtual Agent deflection, we have a requirement to dynamically change the Portal that is used to display a KB article depending on an earlier variable.
In the 'URL Navigation' section within the Conversation Interfaces configuration it seems to be defaulting to using
/{{portal}}?id=kb_article&sys_id={{data.sys_id}}
I want to be able to set that {{portal}} value from within the Virtual Agent topic designer (we are using a cloned version of the AI Search topic) but I can't see any reference to portal anywhere within the topic scripting.
Does anyone have any suggestions?
Thanks very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 09:25 PM
Hey Edward,
- Utilize the Virtual Agent Designer to define a variable for the portal URL early in the conversation flow.
- In the topic designer, add a script action or a decision tree to dynamically set the portal variable based on the earlier variable's value.
- Use a setData or setField script within the topic to assign the portal value to the {{portal}} placeholder.
- Modify the 'URL Navigation' section to use the dynamically set variable: /{{portalVariable}}?id=kb_article&sys_id={{data.sys_id}}.
- Ensure the portal variable is correctly passed and referenced throughout the Virtual Agent topic scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 03:02 AM
Hello Kishan,
Thank you so much for your suggestion - exactly what I was looking for.
Would you be able to provide a quick example of using the setData or setField script? I tried setting a portal variable within the vaInputs but didn't have any luck passing it to the {{portal}} variable. All the rest of the steps I have covered so I'm very nearly there!
Thanks again,
Ed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 11:58 AM - edited 05-16-2024 12:52 PM
Sure, here's an example of how to use setData within the Virtual Agent topic designer to dynamically set the portal variable:
Define the portal variable early in the conversation flow:
In the Virtual Agent Designer, add a script action to your topic.- Script Action to set the portal variable:
// Define the function to set the portal based on an earlier variable value
function setPortal() {
var earlierVariable = vaInputs.earlierVariable;
var portal = '';
// Logic to determine the portal value
if (earlierVariable === 'value1') {
portal = 'portal1';
} else if (earlierVariable === 'value2') {
portal = 'portal2';
} else {
portal = 'default_portal';
}
// Set the portal variable
vaContext.portal = portal;
}
setPortal();
3. Modify the URL Navigation to use the dynamically set variable.
4. Ensure that vaInputs.earlierVariable is populated with the correct value earlier in the conversation.
By using vaContext, you can store the dynamically determined portal value and then refer to it within the URL navigation section. This way, the {{portal}} variable will be set based on the logic defined in your script.
Unfortunately, there aren't any straightforward ServiceNow documentation on this topic. Feel free to reach out to me at "kishan.kumar@work4flow.com" for further help since I've worked on similar implementations before and would be happy to discuss this over a meeting.
Best regards,
Kishan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 05:26 AM
Hi Kishan,
Thanks again for your update. Still not quite there with this - I appreciate your ongoing support with this one!
I think I have a few things needing clarifying.
1) Should I be setting these variables within my main chat topic, or within the AI search topic within Virtual Agent? (Does this matter? I'd have thought within the AI Search as it's where I imagine it populates the URLs but not sure where the URL Navigation variables are pulled from).
2) In the script you have provided we are using 'earlierVariable' to set the portal value, makes complete sense, but then I'm a bit confused why we're setting 'vaContext.portal' to this value if we are then changing the URL Navigation to use the dynamically set variable - wouldn't this nul setting vaContext.portal?
3) It seems when I changed the URL Navigation to anything other than {{portal}} the AI Search fails to return any results - I presume this is due to an invalid URL which therefore stops it showing any results.
4) When I test within the VA Topic Designer and the vaContext.portal is set correctly through the flow it still always returns 'sp-invalid' as the portal when clicking a link. I would have thought in this case it would populate {{portal}} with the vaContext.portal value.
I think in essence everything makes sense to me except which variables can be used within URL navigation and how these are populated. Might help if you provided me with a placeholder to use within the url navigation based on your previous script as an example?
Thanks again for your help!
Ed