An AI-powered Telegram coding agent connected to Google Cloud Vertex AI (Gemini) for automating iOS development with Swift and SwiftUI directly through GitHub pull requests.
The agent is designed to help iOS developers turn natural-language instructions, screenshots, and UI references into production-ready code changes. It can inspect an existing iOS codebase, update or create Swift files, and open a pull request for review—all from Telegram.
This project is focused primarily on iOS development. Backend repository support remains available when configured, but the main workflow and examples are intended for Swift and SwiftUI projects.
The agent follows a structured workflow from receiving an iOS instruction to creating a pull request:
[Telegram User]
│
├─► Send a development request, screenshot, or UI reference
│
[Debouncer: 2.5 seconds]
└─► Combines consecutive text messages and multiple images
│
[execute_task: per-user lock]
└─► Prevents conflicting tasks from running at the same time
│
[Workspace Sync]
└─► Clones or updates the configured repository and creates a task branch
│
[iOS Codebase Scan & Cache]
└─► Scans relevant Swift and SwiftUI files and caches the session snapshot
│
[Vertex AI: Gemini 2.5 Flash]
└─► Processes the instruction, codebase snapshot, and screenshots
│
[Streaming Telegram Status]
└─► Sends AI progress and implementation details in real time
│
[Code Parser & Writer]
└─► Creates or updates files in the local workspace
│
[Git Push & Pull Request]
└─► Commits changes, pushes the task branch, and creates a GitHub PR
│
[User Review & Merge]
└─► Review and merge the iOS pull request from Telegram
│
[Reset]
└─► Clears the session cache when the task is complete or reset
Message Debouncing and Media Handling
When text and screenshots are sent as separate messages, the bot waits 2.5 seconds before processing them. This allows multiple messages and images to be combined into one complete iOS development request.
Session Lock and Repository Synchronization
Each user has an execution lock to prevent concurrent tasks from modifying the same workspace. The bot synchronizes the configured repository from the main branch and creates a dedicated task branch such as ai-task-<message_id>.
Swift/SwiftUI Codebase Snapshot
On the first request, the bot scans relevant files in the iOS project, such as Swift source files, SwiftUI views, models, services, and configuration files. The scan runs in a separate thread so the bot remains responsive. The snapshot is cached for the active session and reused by subsequent requests.
AI Analysis and Code Generation
Vertex AI receives the user’s instruction, the cached codebase snapshot, and any attached screenshots. Gemini analyzes the existing implementation before generating changes that fit the project’s architecture and style.
Code Writing and Pull Request Creation
The agent parses the generated response, writes the requested changes to the workspace, commits the changes, pushes the task branch, and creates a GitHub pull request when code changes are detected.
Review and Merge
The user can review the generated iOS changes in GitHub and use the Telegram action button to merge the pull request. After merging, the session cache can be cleared to start with a fresh codebase snapshot.
/newbot and follow the instructions to create a bot..env file.The bot needs GitHub access to clone repositories, create branches, push commits, open pull requests, and merge pull requests.
repo for private repository access, commits, pull requests, and merges.workflow only if the repository workflows need to be updated or triggered through the token.GITHUB_TOKEN in .env.Never commit your token to the repository.
This project uses the google-genai SDK with Vertex AI to process text instructions and screenshots.
telegram-ios-ai-agent.roles/aiplatform.user.gcp-key.json.Never commit the JSON key to GitHub.
You can authenticate using either of these methods.
Option 1: Use a service account JSON key
GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/to/gcp-key.json"
Option 2: Use the Google Cloud CLI
gcloud auth application-default login
The Google SDK will automatically use the application default credentials.
Copy the example environment file:
cp .env.example .env
Then configure the required values:
# Telegram Configuration
TELEGRAM_BOT_TOKEN="your_telegram_bot_token"
ALLOWED_TELEGRAM_USER_ID=123456789
# GitHub Configuration
GITHUB_TOKEN="your_github_personal_access_token"
IOS_REPO="your-username-or-org/your-ios-repository"
# Optional backend repository support
BACKEND_REPO="your-username-or-org/your-backend-repository"
# Workspace and Google Cloud Configuration
WORKSPACE_DIR="./workspace"
GCP_PROJECT_ID="your-gcp-project-id"
# Optional: service account credentials
GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/to/gcp-key.json"
For an iOS-only setup, IOS_REPO is the primary repository setting. Leave BACKEND_REPO empty if backend support is not needed.
Create and activate a Python 3.10+ virtual environment:
python3 -m venv venv
source venv/bin/activate
# Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Start the bot:
python bot.py
Make sure Docker and Docker Compose are installed, then run:
docker-compose up -d --build
View the logs:
docker-compose logs -f
Send these commands directly to the bot:
/start — Start interacting with the bot and verify user authorization./reset or /new — Clear the active conversation and remove the cached iOS codebase snapshot. Use this before starting a new task that should be based on a fresh main branch.You can send requests such as:
The agent will inspect the existing project before making changes and will provide the implementation through a GitHub pull request for review.
.env or a secure secret manager..env, service account JSON files, or access tokens.ALLOWED_TELEGRAM_USER_ID.