how to make a button url dynamic based on instance url in virtual agnet

bala_1312
Tera Contributor

In Bot response a button i need and on click of it it will open a catalog item and it is  based on instance url that link should be dynamic . How to achieve this ?  

5 REPLIES 5

Amit Verma
Kilo Patron
Kilo Patron

Hi @bala_1312 

 

You can refer below post for your requirement :

https://www.servicenow.com/community/virtual-agent-nlu-forum/virtual-agent-links-to-catalog-items-op...

 It has the logic to get the instance URL dynamically via reading the system property and then rendering the catalog item dynamically.

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Hi @Amit Verma ,

 

I need a  response button,

how can i call a script variable from html code , if i store dynamic url in that script variable

@bala_1312 

 

You can try below approach :

 

1. Create the URL using Script Action utility as shown below -

 

AmitVerma_0-1726817502211.png

(function execute() {
    var baseURL = gs.getProperty('glide.servlet.uri');
    vaVars.url = baseURL + 'sp?id=sc_cat_item&sys_id=50ce6609ec778e00c3ed192aba465fed';
})()

 

Create a Script Variable with the name url to store the url created above -

 

AmitVerma_2-1726817759521.png

 

2. Make use of Link Response to render the link via Virtual Agent -

 

AmitVerma_1-1726817661632.png

 

Map your Script Variable created in Step 1 to Link.

 

Output :

 

You will get a hyperlink to the catalog item.

 

AmitVerma_3-1726817846991.png

 


Please mark this response as correct and helpful if it assisted you with your question.