Skip to content

Chapter 3: The agent and its tools

Now you’ll build the agent: it receives the message and the user’s data, decides what to do in the Products table and replies on Telegram.

The finished flow: Telegram Webhook, the three Parse Data components and the users table on the left; the Prompt, the agent with Gemini and four Airtable tools, and Telegram Message on the right

1. Gather the data in a Prompt

Add a Prompt. In Template, write:

Write permission: {permission}
Username: {user}
Message: {message}

Each word in braces creates an input on the component. Connect them:

FromOutputToInput
write permissionTextPromptpermission
usernameTextPromptuser
Telegram WebhookMessagePromptmessage

2. The agent

Add an Agent and a Gemini.

FromOutputToInput
PromptPrompt MessageAgentInput
GeminiModelAgentModel

In Gemini, choose your credential and a model. In the agent’s System Prompt, write:

You are an assistant that manages a products table in Airtable from natural language messages.
Each message tells you the user's name and whether they have write permission.
- If write permission is true, you can read, create, update and delete products.
- If it is false, you can only read products. If they ask for anything else, explain that they don't have permission.
Address the user by name and always confirm what you have done.

3. The Airtable tools

Add four Airtable components, one per operation, and rename them so you can recognise them: read, create, update and delete.

In all four:

  • Credential: your Airtable credential.
  • Base Name: your base.
  • Table Name: Products.
  • Connect their Tool output to the agent’s Tools input.

And in each one:

ComponentOperationWhat to leave to the agent (Defined by AI)
readReadWith Mode set to Advanced, the Filter by Formula field, so it looks up the products the user asks for.
createCreateThe table’s fields that appear in the component, such as the product name and the stock.
updateUpdateRecord ID and the fields it has to change.
deleteDeleteRecord ID.

To leave a field to the agent, click the sparkles button on its right.

4. The reply on Telegram

Add a Telegram Message:

  • Connect the agent’s Response output to its Text input.
  • Credential: your bot credential.
  • Action: Send Text.
  • Mode: Basic. It replies in the same chat the message came from.

5. Publish it and connect the bot

Telegram messages reach the published version of the flow, so to test the bot you have to publish it:

  1. Create a version and deploy it. See Publish and follow a flow.
  2. Open API Access and follow the instructions in the Telegram tab to connect the bot.
  3. Write to the bot from a Telegram account registered in the Users table, for example How much stock of T-shirts is left?

Check in Executions Logs what data the agent received and which tool it used for each message. See Executions log.