breezy
breezy2mo ago

Adding Metadata to Files in Agent KB

Is there a way to add metadata to a file when uploading to the knowledgebase in the agent settings instead of going to the docs and making a curl request?
1 Reply
Tico | Voiceflow Assistant
At the moment the Creator UI (Agent > Knowledge Base) only lets you drag-and-drop or select a file/URL – it doesn’t expose the metadata field.
If you want the document’s chunks to carry metadata (so you can filter them later in a KB Query) you need to upload the file through one of the external options: • REST API – POST /v1/knowledge-base/docs/upload with a multipart part named metadata.
curl -X POST \
'https://api.voiceflow.com/v1/knowledge-base/docs/upload?overwrite=true' \
-H 'Authorization: <YOUR_DM_API_KEY>' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@/path/to/file.pdf' \
-F 'metadata={"category":"pricing","tags":["faq","public"]}'
curl -X POST \
'https://api.voiceflow.com/v1/knowledge-base/docs/upload?overwrite=true' \
-H 'Authorization: <YOUR_DM_API_KEY>' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@/path/to/file.pdf' \
-F 'metadata={"category":"pricing","tags":["faq","public"]}'
• voiceflow-cli – the voiceflow kb upload command accepts a --metadata flag so you can script it in CI. Once the file is re-uploaded with metadata, those key–value pairs are stored on every resulting chunk and can be used in the filters object of a KB Query. Docs for reference: https://developer.voiceflow.com/v2.0/docs/advanced-knowledge-base#inserting-metadata-to-data-sources https://developer.voiceflow.com/reference/post_v1-knowledge-base-docs-upload

Did you find this page helpful?