File uploads in widgets
Let customers attach photos and documents inside a widget with the file-upload component, then pass the files to an action or to your team.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
The file-upload component lets a customer attach files inside a widget. Use it when a request needs evidence or paperwork, such as a photo of a damaged item, a receipt or a signed form. The files are stored with the conversation, and you can pass them to an action.
Add the component
{
"states": { "photos": [] },
"components": [
{
"type": "file-upload",
"name": "photos",
"label": "Photos of the damage",
"accept": ["image/jpeg", "image/png"],
"maxFiles": 3,
"required": true
},
{ "type": "button", "label": "Send claim", "onClick": "submitClaim", "validate": true }
]
}
| Property | Description |
|---|---|
name |
The state that receives the uploaded files. Declare it as an empty list. |
label |
The text shown above the picker. |
accept |
Allowed file types, as a list of media types. Leave it out to accept any type. |
maxFiles |
How many files the customer can attach in this component. |
required |
A button with "validate": true does not run its function until a file is attached. |
onChange |
Optional function that runs when the list of files changes. |
What you get in the state
After a successful upload, states.photos holds one object per file.
[
{
"id": "file_91x",
"name": "damaged-box.jpg",
"type": "image/jpeg",
"url": "https://files.example.com/damaged-box.jpg"
}
]
The url is a temporary address for reading the file. Use the id when you need a stable reference.
Send the files to an action
Pass the state to a callAction step. Your action receives the list in its arguments.
{
"submitClaim": [
{
"step": "callAction",
"action": "act_create_claim",
"args": { "orderNumber": "{{context.orderNumber}}", "photos": "{{states.photos}}" },
"saveTo": "claim"
},
{ "step": "sendMessage", "text": "I have sent my photos." }
]
}
See Functions for the other steps and Custom action for building the action that receives them.
What your team sees
Uploaded files appear in the conversation. When the agent hands the conversation to your team, the files go with it and show as attachments on the ticket in the Helpdesk.
- Open Helpdesk and select the ticket.
- Open the conversation tab.
- Select a file to view it.
You should see each file under the message where the customer sent it.
Privacy
Warning: Customers can attach sensitive files by mistake. Say what you need in the label ("Photos of the damaged item only"), and set up masking and refusal rules under Build > Guardrails. See Guardrails.
For images that customers send in normal messages, see Images and attachments.