Virtual Agent User Input 'Image Picker'
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Hi there,
While browsing Community questions, I noticed some topics about how to apply the User Input 'Image Picker' within the Virtual Agent Designer. Specifically, how to add an image to a (new) record. Not having applied this one myself yet I thought, let's give it a go! Unfortunately, this is the only User Input not being used in the out-of-the-box Topics. Also, the Docs don't mention the full path for using this User Input… as with most in ServiceNow, once having this up-and-running, it actually looks like fairly easy
.
Just sharing knowledge gained on how to apply the User Input 'Image Picker'.
Behavior User Input 'Image Picker'
When simply applying the User Input 'Image Picker', you don't really see anything happening after selecting an image. Though, because we know images attached to records are actually stored as attachments, I just had a look at the Attachments [sys_attachment] table.
Filtering on the most recent attachments, notice that a Content type 'image/png' record has been created on the Table name 'sys_cs_conversation_task' and the File name exactly is the file which you just selected with the User Input 'Image Picker'!
Relating the Image to a (new) record
So the User Input 'Image Picker' does work. Though, the image is only added to the Attachments table. So what actually does the vaInput give us? Might that be useful? When applying gs.info(vaInputs.image.toString()), this provides us with something like:
https://instance-name.service-now.com/api/now/v1/cs/media/7ve9KNPje94K14077hEC123WhNjto3c8F68wPW3X8T...
Brainstorming for ideas, moving/duplicating the image, searching the Docs for Virtual Agent Script, I stumbled on vaSystem methods.
The vaSystem methods mentions:vaSystem.attachToRecord(String mediaId, String tableName, String sysId)
This method attaches an image to a record.
String tableName, String sysId, both look logical. mediaId, would that be what we just wrote to the System Log? Indeed it is
.
Solution
Out basic test Topic for the User Input 'Image Picker' looks like:
In this case, we are just creating an Incident. Obviously, attaching the image to an existing record would also work. The Utility 'Script Action' contains :
(function execute() {
vaSystem.attachToRecord(vaInputs.image.getValue(), 'incident', vaInputs.create_incident);
})()
vaInputs.image: image being the Variable Name for User Input 'Image Picker'
vaInputs.create_incident: create_incident being the Variable Name for Utility 'Action'
Result
If we open the just created Incident, notice that the Image from the User Input 'Image Picker' indeed has been attached to the Incident:
---
And that's it actually. Hope you like it. If any questions or remarks, let me know!
Kind regards,
Mark Roethof
ServiceNow Technical Consultant @ Paphos Group---
https://www.servicenow.com/community/virtual-agent-nlu-articles/virtual-agent-user-input-image-picker/ta-p/2311308
