Skip to main content
You’ll build an Amazon Bedrock agent that, when you ask for a spreadsheet, creates a real Excel file and gives you the link to download it. The model decides when to call Doconda; you only wire up the tools.

What you need

  • An AWS account with a Bedrock model enabled and its id in BEDROCK_MODEL_ID.
  • AWS credentials in your environment (AWS_REGION, AWS_ACCESS_KEY_ID…), like the rest of your code.
  • A Doconda API key in DOCONDA_API_KEY. Create it in the dashboard, under API keys.
  • Python 3.9+ or Node 20+.

1. Install the dependencies

2. Connect the tools and ask for the Excel file

tools() returns Doconda’s tools (create, upload, review, edit, look up…) with their name, description and JSON Schema. Bedrock takes them as toolSpec. The agent calls create_document with format: "xlsx", waits until the file is ready and replies with the links.
The Python loop is the Converse API one: while the model asks for a tool (stopReason == "tool_use"), you run it and send the result back. In TypeScript, the AI SDK runs that loop for you.

Result

The tool returns something like this to the model, and the model passes it on to the user in its reply:
You get the Excel file (.xlsx) and a PDF version. The links expire after 5 minutes; if the user asks for them later, the agent calls get_document and gets new ones.

Next steps