Give your agent files
Add a file with business information for the agent to consult when answering. The example uses your opening hours. Once processed, you can connect the same file to another agent or pause its use.
Before you start
You need an agent (create one) with its id in AGENT_ID.
In the platform: Knowledge.
Create the file, connected to the agent
Create the file in the workspace and connect it to the agent in the same call. It can be text, a web page or a document.
curl https://api.platic.ai/v1/files \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "text", "title": "Opening hours", "text": "We are open Monday to Friday from 9:00 to 18:00 and on Saturdays from 10:00 to 14:00.", "attachment": { "agentId": "'$AGENT_ID'" } }'import { Platic } from "platic-sdk"; const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! }); const agentId = process.env.AGENT_ID!; // For a web page use createUrl; for a document (up to 50 MiB), createFile. const file = await platic.files.createText({ title: "Opening hours", text: "We are open Monday to Friday from 9:00 to 18:00 and on Saturdays from 10:00 to 14:00.", attachment: { agentId }, });Give the Sales agent a file with our opening hours: Monday to Friday from 9:00 to 18:00 and Saturdays from 10:00 to 14:00.
Tool:
create_file.The response has
fileIdanduploadId: keep them inFILE_IDandUPLOAD_ID. For a web page or a document, see Create a file.Wait until it is ready
Check the processing status. When it finishes, the connection to the agent activates automatically.
curl https://api.platic.ai/v1/agents/$AGENT_ID/files/$FILE_ID/jobs/$UPLOAD_ID \ -H "Authorization: Bearer $PLATIC_API_KEY"Repeat it every few seconds until
terminalistrue.const job = await platic.agents.files.waitForJob(agentId, file.fileId, file.uploadId); if (job.status === "failed") { throw new Error(job.error?.message ?? "The file could not be processed"); }Is the Sales opening-hours file ready yet?
Tool:
get_agent_file_job.The file is available to the agent when
status: "ready". If it ends asfailed, read the reason inerror.Share it with another agent
The file is already in your workspace: connect it, don't upload it again. (Connect a file)
curl -X PUT https://api.platic.ai/v1/agents/$SUPPORT_AGENT_ID/files/$FILE_ID \ -H "Authorization: Bearer $PLATIC_API_KEY"const supportAgentId = process.env.SUPPORT_AGENT_ID!; await platic.agents.files.connect(supportAgentId, file.fileId);Connect the opening-hours file to the Support agent too.
Tool:
connect_agent_file.If you update the file later, it changes for every agent that uses it.
Pause it when it no longer applies
Pause the file to stop this agent from using it. The connection and file remain; other agents are unaffected.
curl -X PATCH https://api.platic.ai/v1/agents/$AGENT_ID/files/$FILE_ID \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "state": "paused" }'await platic.agents.files.setState(agentId, file.fileId, "paused");Pause the opening-hours file on Sales.
Tool:
set_agent_file_state.To turn it back on, use
active. You can also schedule both changes with a date: see Pause or schedule a file.
Check it worked
Call List the agent's files and check the file's state. Ask the agent about opening hours and compare its reply with the content. Connecting, pausing and disconnecting apply immediately, without publishing the agent.
To take it away from one agent, disconnect it: the file stays in your workspace. To delete it for everyone, delete it.
Next steps
- Connect an API to look up information or perform actions in your system.
- Test it before you publish: check that it answers with what its files say.
- Files: file types, limits and pages that update themselves.