I’m building an application with these components:
FastAPI server that handles file uploads and generates a document_id when files are uploaded successfully
Vapi assistant configured to use files as knowledge sources
React client that communicates with the assistant
Problem I’m facing:
My React app can upload files just fine and my FastAPI server gives back a document_id. But I can’t figure out how to pass this document_id from my React frontend to my Vapi assistant.
I’ve looked through the docs but haven’t found a clear way to do this. Has anyone dealt with this before? What’s the right approach to send the file identifier to the assistant so it can access the uploaded document as part of its knowledge base?
I encountered a similar issue while developing a project. Unfortunately, Vapi assistants cannot accept document_id references directly mid-conversation; this must be handled at the configuration level. My solution involved maintaining a mapping between document_ids and assistant instances. Once the React app retrieves the document_id from FastAPI, the next step is to call the API to update the Vapi assistant’s knowledge base with that file. This can involve either creating a new assistant dedicated to the specific document or updating the knowledge sources of an existing assistant. For dynamic file access during interactions, consider implementing function calling, allowing your assistant to request documents by ID via the FastAPI backend. Though this may require additional setup, it offers significantly more flexibility. Based on my experience, the configuration update method tends to perform better in production environments.
had the same headache last month! i used vapi’s metadata field when starting conversations - just pass the document_id there and your assistant can reference it later. not pretty, but it works without rebuilding everything.
Interesting challenge! Have you tried VAPI’s function calling feature? When your React app gets the document_id back, you could store it in session state. Then create a custom function for your assistant to call and fetch that specific document. What’s your current VAPI assistant setup look like?