Overview#
This guide walks through how to upload documents into a specific chat thread and have your agent respond using those document as context. The uploaded files are stored in an attachment corpus that is connected to a single chat thread, so the agent's response draws on the documents you uploaded — and that context stays scoped to that one thread rather than being shared across the entire agent.A common use case is uploading a sample document (for example, a template or reference file) and asking the agent queries related to those documents or to produce a new document (in case of DeepAgent) that follows the same format.Two corpus types. Ejento supports two kinds of corpus: a document corpus and an attachment corpus. For the chat-thread use case described here, you must use an attachment corpus — this is what allows the corpus to be linked to a chat thread so anything uploaded into it becomes context for that thread only.
Prerequisites#
Before you start, make sure the following are in place:An agent and its Agent ID. You'll reference the agent when creating the chat thread and when requesting a response.
The Attachment tool is enabled on the agent. The agent must have the Attachment tool linked/enabled for it to use uploaded attachments as context. You can enable it from the agent's tool settings in the Ejento platform.
Workflow at a glance#
Step 1 — Create a chat thread#
Keep the chat thread ID — you'll reuse it in Steps 3, 4, and 6, and again for any follow-up uploads in the same thread.
Step 2 — Create an attachment corpus#
Create a corpus using Create a Corpus, and set the corpus type to attachment. Choosing attachment is what makes the corpus connectable to a chat thread.Keep the corpus ID from the response for the next step.
Step 3 — Connect the corpus to the chat thread#
This establishes the association between the specific chat thread and the specific corpus, which is what enables the agent to retrieve the uploaded documents later.
Step 4 — Upload your document to the corpus#
The response returns a document ID, which you'll use in the next step to confirm indexing has finished.
Step 5 — Confirm indexing is complete#
After uploading, the document is indexed asynchronously. Before requesting an agent response, verify that indexing has finished — otherwise the agent may respond before your document is available as context.Call Get a Document with the document ID from Step 4 and confirm that step is completedA step value of completed means indexing has finished and the document is ready to be used as context.Don't skip this check. If you call the response endpoint while indexing is still in progress, the agent won't have the document's content available yet and the response will not reflect the uploaded file. Poll Get a Document until step is completed before continuing.
Step 6 — Request the agent response#
Because the corpus is connected to that chat thread and the document has finished indexing, the agent uses your uploaded document as context and responds accordingly.The chat_thread_id in the request body is essential — it's how the agent knows which thread (and therefore which connected corpus and uploaded documents) to draw context from.
Reusing the same chat thread#
For follow-up queries in a thread you've already set up, you do not need to create another corpus or store the corpus ID yourself.2.
Upload the new document into that same corpus, exactly as in Step 4.
3.
Confirm indexing is complete (Step 5), then request the agent response (Step 6).
The context stays scoped to that specific chat thread, not the entire agent, so each thread keeps its own set of uploaded documents.
Need help?#
If you run into issues at any step, reach out to the Ejento Support Team.