Lesson format
Reading lesson with structured written material and clear navigation inside the course flow.
Reading lesson with structured written material and clear navigation inside the course flow.
This lesson is free and open to all visitors.
This is the lesson that bridges the gap between "I understand the concept" and "I can actually build this." If you've never worked with APIs before, don't worry — by the end of this lesson, you'll understand exactly what they are and how they connect your AI to messenger platforms.
API stands for Application Programming Interface. Think of it as a translator between two systems. When your AI sales manager needs to read a message from Telegram and send a response, it doesn't go into the Telegram app and type — it uses Telegram's API to exchange messages programmatically.
Analogy: imagine a restaurant. You (the client) don't go into the kitchen to cook your food. Instead, you tell the waiter (API) what you want, the waiter tells the kitchen, and brings you the result. APIs work the same way — they take your request, pass it to the service, and return the result.
An API key (or token) is like a password that identifies your application. Every API requires one. When your AI sends a message through Telegram, Telegram needs to know: "Who is sending this? Are they authorized?"
The API key answers that question. It's a long string of characters:
sk-ant-api03-abc123xyz789... ← Anthropic API key (for Claude)
7891234567:AAH_some_long_token ← Telegram Bot token
EAAGm0PX4ZC... ← Instagram/Meta API token
Critical rule: API keys are like passwords. Never share them publicly, never commit them to Git, never paste them in public chats. Store them in a .env file that stays on your machine only.
A webhook is the opposite of an API call. Instead of YOUR app asking "any new messages?" every 5 seconds (polling), the messenger platform tells YOUR app "hey, a new message just arrived!" (push notification).
How it works:
https://your-server.com/webhook/telegramClient sends message to your Telegram bot
↓
Telegram calls YOUR webhook URL with the message data
↓
Your server receives the message
↓
Your server sends message + context + skill to Claude API
↓
Claude generates a response
↓
Your server sends the response back via Telegram API
↓
Client sees the response in Telegram
For each integration, you'll need:
| Platform | What you need | Where to get it |
|---|---|---|
| Claude AI | API key | console.anthropic.com → API Keys |
| Telegram | Bot token | @BotFather in Telegram |
| Page token + App ID | developers.facebook.com | |
| Business API token | developers.facebook.com (Meta Business Suite) |
All your keys go in one file:
# /config/.env
# Claude AI
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
# Telegram
TELEGRAM_BOT_TOKEN=7891234567:AAH_your_token_here
# Instagram / Meta
META_PAGE_TOKEN=EAAGm0PX4ZC_your_token_here
META_APP_SECRET=your_app_secret_here
# WhatsApp
WHATSAPP_TOKEN=your_whatsapp_token_here
WHATSAPP_PHONE_ID=your_phone_id_here
# Server
WEBHOOK_URL=https://your-server.com
Tell Claude Code to create this structure:
Create a /config/.env file with placeholders for all API keys I'll need:
Anthropic, Telegram, Instagram, WhatsApp.
Also create a /config/.env.example with the same structure but without real values.
Add .env to .gitignore so it's never committed.
Here's the key insight: you don't need to write the API integration code yourself. You'll tell Claude Code what you want, and it will write the code that connects everything. Your job is to:
APIs, tokens, and webhooks sound technical, but they're really just three concepts: an API is how apps talk to each other, a token is your ID badge, and a webhook is a notification bell. You don't need to memorize HTTP methods or JSON formats — Claude Code handles that. You just need to know what these things are and where to get the keys.