Virtual Agent User Input File Picker [Paris]
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Hi there,
A frequently asked question concerning Virtual Agent: How to upload any type of file within a chat with the Virtual Agent. So far, this was limited to using the User Input Image Picker… with the Paris-release, Eureka: A new User Input File Picker has been added which replaces the former Image Picker.
Though, how to use this new User Input File Picker?
User Input File Picker
From the ServiceNow Docs:
"Replaces the former Image Picker control in the Virtual Agent Designer palette. You can specify the type of file that your users can upload, either image files or all file types. An anti-virus scan runs automatically on all files uploaded."
Behavior User Imput File Picker
When simply applying the User Input File Picker, you don't really see anything happening after selecting a file. Though, because we know files attached to records are actually stored as attachments, let's have a look at the Attachments [sys_attachment] table.
Filtering on the most recent attachments, notice that a 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 File Picker.
Relating the File to a (new) record
So the User Input File Picker does work. Though, the file is only added to the Attachments table. So what actually does the vaInputs give us? Might that be useful? When applying gs.info(vaInputs.file_picker.toString()), this provides us with something like:
https://instance-name.service-now.com/api/now/v2/cs/media/axdxPNJDEQomEheiCRdcimWIJdmqAYkbOVdGevPqlo...
Searching the ServiceNow Docs for Virtual Agent Script, there's a useful vaSystem property mentioned: vaSystem.attachToRecord().
vaSystem.attachToRecord(String mediaId, String tableName, String sysId)
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 File Picker looks like:
In this case, we are just creating an Incident. Obviously, attaching the file to an existing record would also work. The Utility Script Action contains:
(function execute() {
vaSystem.attachToRecord(vaInputs.file_picker.getValue(), 'incident', vaInputs.create_incident);
})()
vaInputs.file: file_picker being the Variable Name for User Input File Picker
vaInputs.create_incident: create_incident being the Variable Name for Utility Action
Result
If we open the just created Incident, notice that the file from the User Input File 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 @ Quint Technology
1x ServiceNow Developer MVP
1x ServiceNow Community MVP
---
https://www.servicenow.com/community/virtual-agent-nlu-articles/virtual-agent-user-input-file-picker-paris/ta-p/2306903
