Lesson 6. Practice: Connect an External Service#
Goal: connect one external service to your agent and test the integration.
Task: Send a Telegram Notification When a Client Is Added to Google Sheets#
Tools: Google Sheets + Telegram Bot + Zapier (or Make, or n8n).
Step 1. Create a Bot in Telegram#
- Message @BotFather
- Send
/newbot - Enter the bot name (e.g., "My Notifications Bot")
- Enter the username (e.g.,
my_notifications_bot) - Copy the API Token (e.g.,
1234567890:ABCdefGHIjklMNOpqrsTUVwxyz) - Send your bot
/start(so the bot can message you)
Step 2. Get Your Chat ID#
- Send your bot any message
- Open in a browser:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
(replace <YOUR_TOKEN> with the token from step 1)
- Find
"chat":{"id":123456789}in the response — that's your Chat ID - Save the Chat ID
Step 3. Create a Spreadsheet in Google Sheets#
Create a "Clients" spreadsheet with columns:
| Name | Phone | |
|---|---|---|
| John Smith | john@example.com | +1234567890 |
Step 4. Create an Automation in Zapier#
Trigger:
- app: Google Sheets
- event: New Spreadsheet Row
- authorization: grant access to Google Sheets
- select spreadsheet and sheet
- test (Zapier will find the last row)
Action:
- app: Webhooks by Zapier
- action: POST
- URL:
https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage
- Method: POST
- Data (JSON):
{
"chat_id": "<YOUR_CHAT_ID>",
"text": "New client: {{Name}} ({{Email}})"
}
(replace <YOUR_CHAT_ID> with your Chat ID from step 2)
- test (you'll receive a message in Telegram)
Turn on the Zap:
- click "Publish"
Step 5. Test#
- Add a new row to the Google Sheets spreadsheet:
| Name | Phone | |
|---|---|---|
| Jane Doe | jane@example.com | +0987654321 |
- Wait 1–2 minutes (Zapier checks the spreadsheet every 1–15 minutes depending on plan)
- You'll receive a message in Telegram:
New client: Jane Doe (jane@example.com)
Done! The integration works.
Integration Verification Checklist#
- Trigger works (Zapier finds the new row)
- Action runs (message is sent to Telegram)
- Data is passed correctly (name and email from the spreadsheet appear in the message)
- No errors in Zapier log
- Delay is acceptable (1–15 minutes)
Module Practice#
Practice Task 1: Read API Documentation#
Task: read the Telegram Bot API documentation and find how to send an image.
Steps:
- Open core.telegram.org/bots/api
- Find the method for sending an image (hint:
sendPhoto) - Read what parameters are required
- Find the request example
Answer these questions:
- What method is used to send an image?
- What parameters are required?
- Can you send an image by URL (without uploading the file)?
- Method:
sendPhoto - Required parameters:
chat_id,photo - By URL: Yes, you can pass the image URL in the
photoparameter
Practice Task 2: Get an API Key#
Task: get an API key for one of these services (your choice).
Options:
- Telegram Bot API — create a bot via @BotFather
- OpenAI API — sign up at platform.openai.com and create an API key
- Google Sheets API — create a project in Google Cloud Console (harder, but useful)
Checklist:
- API key obtained
- Key stored securely (not in code, not in chat)
- Tested (made a test request)
Practice Task 3: Connect an External Service via Connector#
Task: repeat the example from Lesson 6 (Google Sheets + Telegram Bot + Zapier).
Requirements:
- trigger: new row in Google Sheets
- action: send message to Telegram
- testing: add a row → receive a message
Checklist:
- Bot created, token obtained
- Chat ID obtained
- Spreadsheet created
- Zap created and enabled
- Testing passed (message received)
Practice Task 4: Zapier Practice — Connect an External API#
Task:
Create a chatbot/agent in Zapier that fetches up-to-date information via an external API (e.g., cryptocurrency rate, weather, exchange rates) when the user asks.
What to do:
-
Choose an API to connect (simple, free):
- CoinGecko API (cryptocurrency rates):
https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd - OpenWeather API (weather):
https://api.openweathermap.org/data/2.5/weather?q=Moscow&appid=YOUR_KEY - ExchangeRate API (exchange rates):
https://api.exchangerate-api.com/v4/latest/USD
- CoinGecko API (cryptocurrency rates):
-
Create a chatbot/agent in Zapier:
- Name: "Info Agent" or "Crypto Rates"
-
Write the prompt:
You are an information assistant.
Your task: when the user asks, fetch up-to-date information via API and respond.
What you can do:
- Show the current Bitcoin rate (use CoinGecko API)
- [Other features if you add them]
Rules:
- When the user asks for the Bitcoin rate, use HTTP Request to the API
- Extract the price from the response
- Reply: "Current Bitcoin rate: $[price] USD"
Format:
- Short answer
- Always include update time: "As of [time]"
-
Connect Webhooks / HTTP Request in Zapier:
- Skills → Add Skill → HTTP Request (or equivalent)
- Configure the request:
- Method: GET
- URL:
https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd
- Test: Execute → you should get JSON with the price
-
Process the response:
- If Zapier supports JSON processing in the prompt, extract the value
bitcoin.usd - If not — use the built-in data processing tool (if available)
- If Zapier supports JSON processing in the prompt, extract the value
-
Test the agent:
- Write: "What's the Bitcoin rate?"
- The agent should reply: "Current Bitcoin rate: $45000 USD (as of 10:30)"
Checklist:
- API chosen (CoinGecko or other)
- Chatbot/agent created in Zapier
- Prompt written (with instructions for using HTTP Request)
- HTTP Request configured (URL, GET method)
- Testing passed (agent returns current rate)
What you'll get:
Experience connecting an external API to an agent/chatbot in Zapier. Understanding of how an agent can fetch real-time data from the internet.
Time: 30–40 minutes
Note:
If Zapier doesn't have a direct HTTP Request (or it's hard to set up), use ready-made plugins (e.g., weather or exchange rate plugin if available). The main thing is to understand how external APIs work.
Practice Task 5: Calculate API Usage Cost#
Task: estimate how much using the OpenAI API will cost for your agent.
Given:
- you're planning a support agent for a website
- ~500 conversations per month
- each conversation: user writes ~200 characters (~50 tokens), agent replies ~800 characters (~200 tokens)
- model: GPT-4o mini
- cost (2026): $0.00015 per 1000 input tokens, $0.0006 per 1000 output tokens
Calculation:
- Input tokens per conversation: 50
- Output tokens per conversation: 200
- Cost per conversation:
- Input: (50 / 1000) × $0.00015 = $0.0000075
- Output: (200 / 1000) × $0.0006 = $0.00012
- Total: $0.0001275 (~$0.00013)
- Cost for 500 conversations: 500 × $0.00013 = $0.065 (~$0.07)
Answer: ~$0.07/month (or ~6 rubles/month at 90 ₽/$).
Your task:
Calculate the cost for:
- 2000 conversations per month
- model GPT-5.2 ($0.01 per 1000 input tokens, $0.03 per 1000 output tokens)
- each conversation: 100 input tokens, 300 output tokens
- Input: (100 / 1000) × $0.01 = $0.001
- Output: (300 / 1000) × $0.03 = $0.009
- Total per conversation: $0.01
- Total for 2000 conversations: 2000 × $0.01 = $20/month
Bonus: what if you use DeepSeek-R1?
- Input: (100 / 1000) × $0.003 = $0.0003
- Output: (300 / 1000) × $0.003 = $0.0009
- Total per conversation: $0.0012
- Total for 2000 conversations: 2000 × $0.0012 = $2.40/month (8x cheaper!)
Artifacts#
After completing the module you'll have:
1. Working Integration#
- Google Sheets + Telegram Bot + Zapier (or equivalent)
- trigger: new row → action: Telegram notification
2. "How to Read API Documentation" Checklist#
- list of steps to find the right endpoint and parameters
- usable for any API
3. "Integration Verification Before Launch" Checklist#
- Trigger works (event is detected)
- Action runs (request is sent)
- Authorization configured (key works)
- Data passed correctly (fields are filled)
- Errors handled (agent doesn't crash on failure)
- Limits considered (not exceeding Rate Limits)
- Cost calculated (we know what we pay)
- Logging enabled (we see what's happening)
4. API Cost Calculator#
Template for calculating API usage cost:
| Parameter | Value |
|---|---|
| Requests/month | 1000 |
| Cost per request | $0.001 |
| Total per month | $1 |