Skip to content

Quickstart Guide

In this guide, you will set up your first CodeMeet bot and build a simple Echo bot in under 5 minutes.


1. Prerequisites

  • A CodeMeet user account
  • A bot token generated via @BotFather
  • Python 3.10+ (or Node.js, Go, etc.)

2. Test Connection with getMe

Before coding, verify your token using a simple cURL request:

curl -s "https://botapi.codemeet.chat/bot<YOUR_TOKEN>/getMe"

Expected JSON response:

{
  "ok": true,
  "result": {
    "id": "e9b2a1c0-4411-4fa3-9f88-d4508671b122",
    "is_bot": true,
    "first_name": "My Test Bot",
    "username": "my_test_bot"
  }
}


3. Initializing Direct Chat (/start)

/// important | Dialog Start Requirement In CodeMeet, bots cannot initiate unsolicited private conversations. A user must first start a chat by sending /start or clicking the Start button in the app. Otherwise, API calls will fail with 403 Forbidden: the user must start the bot first. ///

Open the CodeMeet client, search for your bot's @username, and click Start.


4. Building an Echo Bot in Python

Install the requests HTTP library:

pip install requests

Create a file named bot.py:

import requests
import time

TOKEN = "YOUR_BOT_TOKEN_HERE"
API_URL = f"https://botapi.codemeet.chat/bot{TOKEN}"

def get_updates(offset=None):
    params = {"timeout": 20}
    if offset:
        params["offset"] = offset
    response = requests.get(f"{API_URL}/getUpdates", params=params, timeout=25)
    return response.json()

def send_message(chat_id, text):
    payload = {
        "chat_id": chat_id,
        "text": text
    }
    response = requests.post(f"{API_URL}/sendMessage", json=payload, timeout=10)
    return response.json()

def main():
    print("CodeMeet Bot is running...")
    offset = None

    while True:
        try:
            updates = get_updates(offset)
            if not updates.get("ok"):
                time.sleep(1)
                continue

            for update in updates.get("result", []):
                # Acknowledge received update
                offset = update["update_id"] + 1

                message = update.get("message")
                if not message:
                    continue

                chat_id = message["chat"]["id"]
                text = message.get("text", "")
                user_name = message.get("from", {}).get("first_name", "User")

                if text == "/start":
                    send_message(chat_id, f"Hello {user_name}!\nWelcome to my CodeMeet Bot.")
                else:
                    send_message(chat_id, f"Echo: {text}")

        except requests.exceptions.RequestException as e:
            print("Network error:", e)
            time.sleep(3)
        except Exception as e:
            print("Error:", e)
            time.sleep(1)

if __name__ == "__main__":
    main()

Run your bot:

python bot.py

Send a message to your bot in CodeMeet to verify that it replies immediately.