The CreatorCon Call for Content is officially open! Get started here.

How to get Topic sys_id and activity flow sys_id in virtual agent

jacque3
Kilo Guru

Hi guys,

I was trying to build a POC for a custom message in our Virtual agent, and that I need the Topic sys_id/name and the conversation activity Id (I was referring to the screenshot below, and I actually don't know the specific term for the 4 boxes below, please correct me if I get it wrong and I also want to know how to get their IDs) as parameters within the flow,

find_real_file.png

I tried using vaVars._current_topic but it is showing as undefined.

 

10 REPLIES 10

Mark Roethof
Tera Patron
Tera Patron

Hi there,

There is no out-of-the-box vaSystem etc property to get the current topic sys_id. Though you could apply:

(function execute() {

    return JSON.parse(vaVars._topic_current).sys_id;

})()

This would result in:
79ce168ddb4a88d0b9f39026db9619cc

A small note on getting our hands on the current Virtual Agent topic sys_id. The script example mentioned, will NOT work when using vaSystem.switchTopic(). Then the sys_id of the topic started will still be shown.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

If your after for example the Interaction associated, if I apply vaVars._topic_current, the output will for example be:

{"sys_id":"20708a612f425010b0c2d5ea2799b6e7","task":"577ceaf12f0e9010b0c2d5ea2799b697","entities":null,"modelId":null,"name":"test test","prediction":null,"title":"test test","type":"normal","utterance":""}

You could use JSON.parse(vaVars._topic_current).task to parse the task.

This would give something like "task":"577ceaf12f0e9010b0c2d5ea2799b697". This sys_id matches the document_id field of a the record in table interaction_log. The interaction_log has a reference to the actual interaction.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,
Thank you for the prompt response! I tried checking vaVars._topic_current and it is undefined.

find_real_file.png

Can you test this by testing the actual topic? And not using the preview. If I use the preview, indeed, this does not work. If I open the actual topic within the Virtual Agent web client, it does work fine.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn