How to set the value for the catalog item variable using virtual agent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 03:22 AM - edited 10-13-2023 03:23 AM
We have a requirement where two virtual agent flows will be running on. one is add users to mailbox and remove users from mailbox. So the query here is whenever the user selects remove users from mailbox topic, in the catalog item the access_type variable should set to remove_user choice value. We are using OOB request a catalog topic block and to enhance this requirement we have leveraged it. But not sure how to achieve this requirement. Please need help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 03:31 AM
Hey @sadiq ,
Please find below information to achieve your outcome,
You can use virtual agent conversation flows to collect information from the user and then populate catalog item variables based on their responses.
1. **Create a Virtual Agent Topic**:
- In your ServiceNow instance, go to the Virtual Agent Studio.
- Create or edit a topic that corresponds to the catalog item you want to trigger.
- Define the conversation flow, including any questions or prompts that collect the required information to set the catalog item variable.
2. **Set Catalog Item Variables**:
- In your conversation flow, when you reach a point where you need to set a catalog item variable, you can use JavaScript to set the values.
- For example, if you want to set a variable called `short_description`, you can use JavaScript code like this:
// Assuming 'response' is the variable where the user's response is stored
var userResponse = response;
// Set the catalog item variable
var catalogItemVar = 'short_description'; // Replace with your actual variable name
gs.info('Setting ' + catalogItemVar + ' to: ' + userResponse);
current.variables[catalogItemVar] = userResponse;
- You can adapt the above JavaScript code to the specific variables and logic you need.
3. **Complete the Conversation Flow**:
- Continue your conversation flow to gather any additional information or confirmations from the user.
4. **Trigger the Catalog Item**:
- Once you have collected all the necessary data, you can trigger the catalog item from your virtual agent topic using a "Catalog Task" or "Order Guide" action.
5. **Test the Virtual Agent Topic**:
- Before deploying your virtual agent topic, thoroughly test it to ensure it sets the catalog item variables correctly based on user responses.
6. **Publish and Deploy**:
Regards,
Kamlesh