Module 09Lesson 6

Lesson 6. Practice: Connect an External Service

Hands-on: Zapier

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#

  1. Message @BotFather
  2. Send /newbot
  3. Enter the bot name (e.g., "My Notifications Bot")
  4. Enter the username (e.g., my_notifications_bot)
  5. Copy the API Token (e.g., 1234567890:ABCdefGHIjklMNOpqrsTUVwxyz)
  6. Send your bot /start (so the bot can message you)

Step 2. Get Your Chat ID#

  1. Send your bot any message
  2. Open in a browser:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates

(replace <YOUR_TOKEN> with the token from step 1)

  1. Find "chat":{"id":123456789} in the response — that's your Chat ID
  2. Save the Chat ID

Step 3. Create a Spreadsheet in Google Sheets#

Create a "Clients" spreadsheet with columns:

NameEmailPhone
John Smithjohn@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#

  1. Add a new row to the Google Sheets spreadsheet:
NameEmailPhone
Jane Doejane@example.com+0987654321
  1. Wait 1–2 minutes (Zapier checks the spreadsheet every 1–15 minutes depending on plan)
  2. 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:

  1. Open core.telegram.org/bots/api
  2. Find the method for sending an image (hint: sendPhoto)
  3. Read what parameters are required
  4. 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 photo parameter

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:

  1. 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
  2. Create a chatbot/agent in Zapier:

    • Name: "Info Agent" or "Crypto Rates"
  3. 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]"
  1. 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
  2. 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)
  3. 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:

  1. Input tokens per conversation: 50
  2. Output tokens per conversation: 200
  3. Cost per conversation:
    • Input: (50 / 1000) × $0.00015 = $0.0000075
    • Output: (200 / 1000) × $0.0006 = $0.00012
    • Total: $0.0001275 (~$0.00013)
  4. 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:

ParameterValue
Requests/month1000
Cost per request$0.001
Total per month$1

Materials for the Site#

Flashcards#

Flashcards: APIs and Integrations1 / 8
Known: 0 (0%)
Question

API (Application Programming Interface)

👆 Click to flip

Answer

An interface for programs to interact with each other. Lets one program call another and exchange data (usually in JSON format).

👆 Click to flip back

Test Yourself

Check

1. What is an API in plain terms?
2. Which HTTP method is used to read data via REST API?
3. What is an API Key?
4. What is a Rate Limit?
5. Where should you NOT store API keys?
6. What is a connector?
7. Your agent makes 2000 requests to OpenAI GPT-4o mini per month. Each request: 50 input tokens, 200 output tokens. Cost: $0.00015 per 1000 input tokens, $0.0006 per 1000 output tokens. How much will this cost per month?