Quick action to execute a Flow Designer Action? Possible?

KB1
ServiceNow Employee
ServiceNow Employee

Can anyone provide a simple script in Agent Chat - Quick Actions to execute a Flow Designer action and to pass a simple response back to the chat screen?

 

Is there an example of how to do this that I may have missed, is this even possible?

 

Thanks

1 ACCEPTED SOLUTION

KB1
ServiceNow Employee
ServiceNow Employee

Worked out that you can simply use the Create code snippet, server code NOT client code.

 

For example, you can use the following code in the Script field of the [quickactions_action] record.

var message = "";
var inputs = {};
inputs['prompt'] = params[0]; // String 
var result = sn_fd.FlowAPI.getRunner().action('global.MY_CUSTOM_ACTION').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();

var my_response = outputs['answer']; // String
message = my_response;
		
sn_connect.Conversation.get(record.channel_metadata_document, record.channel_metadata_table)
	.sendMessage({
		body: message,
		system: false
	});

answer = {
	success: true,
	message: message,
};

 

View solution in original post

1 REPLY 1

KB1
ServiceNow Employee
ServiceNow Employee

Worked out that you can simply use the Create code snippet, server code NOT client code.

 

For example, you can use the following code in the Script field of the [quickactions_action] record.

var message = "";
var inputs = {};
inputs['prompt'] = params[0]; // String 
var result = sn_fd.FlowAPI.getRunner().action('global.MY_CUSTOM_ACTION').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();

var my_response = outputs['answer']; // String
message = my_response;
		
sn_connect.Conversation.get(record.channel_metadata_document, record.channel_metadata_table)
	.sendMessage({
		body: message,
		system: false
	});

answer = {
	success: true,
	message: message,
};