Agentic AI Automation via Sheet Assistant API

Modified on Fri, 11 Sep at 4:59 PM

This page describes how to automate an agentic AI workflow in Gigasheet. We'll use Gigasheet's API to control Sheet Assistant, Gigasheet's native agentic AI.


For using Sheet Assistant interactively instead of via API, see this page on the AI Spreadsheet.


Prerequisites:

  • Get started with the Gigasheet API (docs page for LLMs here: https://gigasheet.readme.io/llms.txt )
  • Have the sheet handle for the Gigasheet data you will use in your agentic Sheet Assistant workflow, you will use this handle as a parameter in the API calls.


Step 1: Clear the Sheet Assistant chat log


Use this Sheet Assistant API call to clear messages on the sheet:

https://gigasheet.readme.io/reference/delete_ai-handle-logs


This helps avoid the Sheet Assistant mistakenly incorporating context from previous workflows. If you wish to reuse previous context, you can skip this step.


Step 2: Begin an agentic workflow


Use this Sheet Assistant message sending API call to post an initial message on the sheet:

https://gigasheet.readme.io/reference/post_ai-handle-chat


This message should contains all of the context, tips, instructions, requirements, etc. needed for the agentic workflow to succeed. You can use markdown formatting. Make sure the message specifies a clear goal, and also make sure you instruct it how to format the output when the agentic workflow is finished so that you can use it in whatever your next step is.


For example, your message might look like this:

Find the median rate for 99214 office visit for each payer where state code is DC. Major payers only, exclude niche participants. Output requirements (strict): your last message should consist only of a pretty-printed json of results that is a list of objects, each object having keys "payer" and "median_rate". Do not include any other text in your final message.


Step 3: Poll until results available


Use this Sheet Assistant message history API call to poll for new messages from Sheet Assistant:

https://gigasheet.readme.io/reference/get_ai-handle-logs


While the agentic workflow is proceeding, Sheet Assistant may make many tool calls. Keep polling until you receive a message that has MessageType "assistant-response" containing your specified output.


Example output message with a result:

[
  {
    "Role": "assistant",
    "Content": "```json\n[\n  {\"payer\": \"UnitedHealthcare\", \"median_rate\": 177.720},\n  {\"payer\": \"Cigna\", \"median_rate\": 153.645},\n  {\"payer\": \"Aetna\", \"median_rate\": 108.280},\n  {\"payer\": \"Blue Cross Blue Shield - All Entities\", \"median_rate\": 87.810}\n]\n```",
    "MessageType": "assistant-response",
    "Timestamp": "2026-09-11T20:21:47.084863Z",
    "ClientStateId": ""
  },
  {
... previous messages, including tool call messages with MessageType "assistant-tool-output"
  }
]


It's recommended to poll approximately once every 15 seconds.


Conditions that are likely an error that you should escalate within your process:

  • you have received an "assistant-response" message that does not conform to your output requirements, with no followup messages in the last 60 seconds (likely that Sheet Assistant is saying it failed and is no longer attempting your workflow)
  • the total number of messages of type "assistant-tool-output" has exceeded 20 (likely that Sheet Assistant was unable to complete the workflow, consider revising your initial message or breaking the workflow into separate steps and running one step at a time)
  • the most recent message is of type "assistant-tool-use" but with no new messages for over 180 seconds (query tool calls time out at 120 seconds, so anything significantly longer than 120 seconds after a tool call means something has failed and is not being retried)


Step 4: Extract the output


Extract the output from the final message use it in the next step of your process. For example, this is a Bash command with the jq utility to extract the answer from a file "response.json" that is the output of the API call in the previous step.

cat response.json | jq -r '.[0].Content' | sed '/^```/d' | jq .


On the above output, the command would produce this:

[
  {
    "payer": "UnitedHealthcare",
    "median_rate": 177.72
  },
  {
    "payer": "Cigna",
    "median_rate": 153.645
  },
  {
    "payer": "Aetna",
    "median_rate": 108.28
  },
  {
    "payer": "Blue Cross Blue Shield - All Entities",
    "median_rate": 87.81
  }
]


Make sure your instructions and your extraction code are aligned so that you can obtain the results. The jq extraction is just for illustration. Sheet Assistant is powered by a large language model, so it's recommended to implement a more robust extraction function to handle any formatting variations that may be generated in response to your initial instructions.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article