Pass values from Virtual Agent topic to a Catalog item variable

Luci40
Tera Contributor

I want Virtual Agent to raise a request based on the chat with user.

What I could think right now is to pass values (data that Virtual Agent collected from user) to catalog item variable and then create a request for that item.

Is it possible to send data from Virtual Agent chat to the catalog item variable and then raise a request? 

If so then how can we pass values to catalog item from Virtual agent chat?

6 REPLIES 6

The catalog item id is output form search, you have to use it as input to request. 

find_real_file.png

Finally you have to add a card with details 

find_real_file.png

 

Chris D
Mega Sage
Mega Sage

Murali explained the simple ootb way to order catalog items via VA using the Request Item topic block, but that may not work in all cases - you can see the limitations (i.e. question limit, certain variable types...) towards the bottom of this article: Service Catalog topic blocks in Virtual Agent | ServiceNow Docs

As another option, you can use the Cart/CartJS* API to order a catalog item via a script in VA. If you do this though, keep in mind you'll need to manually create inputs and map any variables needed to those inputs - and then you'll need to update the topic if those variables ever change.

*I have in the example below used the Cart API, but I don't see any reference to it on the Docs site so I think it may be deprecated in favor of the CartJS API which seems like it can do the same thing. Check here for the complete details: CartJS - Scoped | ServiceNow Docs

Here's a simple Cart API example:

    //create new cart to populate and submit the request
    var cart = new Cart();
    //add catalog item to cart by sys_id
    var item = cart.addItem(catalog_item);

    //set variables for your cart item
    cart.setVariable(item, 'name', vaInputs.user);
    cart.setVariable(item, 'requested_for', vaInputs.user);
    cart.setVariable(item, 'why_is_is_needed_vs', vaInputs.business_justification_for_approval);

    //place order and get REQ sys_id
    var req = cart.placeOrder();
    vaVars.request = req.sys_id;