- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2022 11:31 PM
Hi Adam,
thank you for your input.
I understand your point about building a new Context Variable inside the POST, but I do not understand how to check it inside a Topic workflow, in a script. Could you show me one example of how you get this variable inside the Workflow script ?
For now, we found one good solution: we check the "sys_cs_channel" of the current conversation.
Inside the workflow, we build a variable to check the source of the request.
@Adam Chapman wrote:
@Am_d_e Potier wrote:...How can I add a condition inside my Topic script to test this condition ? (I want to behave differently depending if I am called from "inside" (VA Widget) or "outside" (API) service now...
Are you looking to limit a topic to only inside or outside initiated conversations? Or are you conditionally showing topic nodes within a single topic based on this?
In either case, you should be able to create a new context variable and populate that context variable in the POST. Once that context variable has the value, you can use it as a condition for either the topic level condition or node level condition.
(function execute() { vaVars.isKbotRequest= false; var convId = vaSystem.getConversationId(); var gr = new GlideRecord('sys_cs_conversation'); gr.addQuery('sys_id' , convId); gr.query(); if(!gr.next()){ gs.error("Can not find conversation: " + convId); }else{ gs.error("Got a Session of type: " + gr.device_type); if (gr.device_type == 'kbot') { vaVars.isKbotRequest = true; } } })() The trick there is that conversation.device_type == sys_cs_channel.name This seems a very reliable way to know what is the invoker channel inside a Topic. I wish all these relation were documented, that would certainly make our integration easiers |