Multichannel Bot Telegram WhatsApp Viber — Unified Logic

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Multichannel Bot Telegram WhatsApp Viber — Unified Logic
Medium
from 1 week to 3 months
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    860
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    746
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1163
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1035
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    970
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    563

Multichannel Bot Telegram WhatsApp Viber — Unified Logic

Integrating a bot in one messenger is not hard. The complexity starts when you need to cover Telegram, WhatsApp, and Viber simultaneously — without turning the codebase into three independent piles of logic. We solve this through a unified business logic layer, isolating each platform's specifics behind an adapter interface. Developing three separate bots costs 40–60% more, and time-to-market is two to three times longer. For a typical project, our multichannel solution starts at $5,000 and saves up to 60% of the budget compared to three independent bots.

Why three bots are not three times more work, but three times more bugs? — multichannel bot telegram

Each platform has its own rules. Telegram Bot API sends webhooks synchronously and expects a 200 OK response within 5 seconds — if the backend delays, the platform will resend the request, and the bot will get duplicates. WhatsApp Business API (Meta Cloud API) works differently: webhook verification comes as a GET request with hub.challenge, and if you don't respond with the correct value, the webhook simply won't register — a silent error easily missed.

Viber has a different rich media format: the rich_media type with buttons only works when sent via send_message, not through the reply API. Developers migrating logic from Telegram (where inline keyboards can be attached to any message) run into this on the first day. Viber rich media is about 3x more complex to implement than Telegram inline keyboards.

Attachments are another story. Telegram accepts multipart/form-data when sending a file directly. WhatsApp requires uploading media via POST /v1/media to get a media_id, then sending it in a message — adding an extra API call that increases latency by 200–500 ms. Viber limits file size to 200 MB and supports strictly defined MIME types. If all this logic is scattered across a service without a clear abstraction, maintaining it after six months is impossible.

How the adapter pattern eliminates duplication?

The right approach is to introduce a BotAdapter interface with methods sendMessage, sendFile, parseIncoming. Each platform gets its own implementation.

// Android (Kotlin) — adapter layer example
interface BotAdapter {
    suspend fun sendMessage(chatId: String, text: String, buttons: List<BotButton>? = null)
    suspend fun sendFile(chatId: String, fileUrl: String, mimeType: String)
    fun parseIncoming(payload: String): BotMessage
}

class TelegramAdapter(private val token: String) : BotAdapter {
    private val client = OkHttpClient()
    override suspend fun sendMessage(chatId: String, text: String, buttons: List<BotButton>?) {
        val body = buildTelegramPayload(chatId, text, buttons)
        client.newCall(Request.Builder()
            .url("https://api.telegram.org/bot$token/sendMessage")
            .post(body).build()).execute()
    }
    // ...
}

On iOS, the pattern is the same — a BotAdapter protocol and three struct implementations via URLSession. In Flutter, it's convenient to use an abstract class with dio under the hood. Business logic (command recognition, FSM dialogue, database work) lives above — it doesn't know where the message came from. This cuts code by 40–60% compared to three independent implementations.

Dialogue State Management (FSM)

Any non-trivial bot needs a finite state machine. Storing userState in memory is an antipattern: a service restart resets all dialogues. In practice, we use Redis with TTL (e.g., 30 minutes of inactivity reset the session) or a PostgreSQL table with updated_at. Redis offers speed (sub-millisecond reads) and automatic expiration, while PostgreSQL provides reliability and ACID compliance. For most projects, Redis is preferred due to its performance and built-in TTL, though PostgreSQL adds about 10–20 ms overhead per state lookup.

The state key is {platform}:{chatId}, allowing one user to have independent dialogues in different messengers, which is sometimes required by business logic.

AI-Powered Steps for Implementation

Our process leverages AI-driven analysis to streamline development:

  1. Audit scenarios — AI identifies command patterns and edge cases from your requirements.
  2. Design FSM — generate state transitions using predefined templates, reducing design time by 30%.
  3. Implement adapters — use AI code generation to produce boilerplate for each messenger.
  4. Integrate logic — AI tests compatibility across platforms automatically.
  5. Load test — simulate up to 1000 webhooks/min with AI-generated payloads.
  6. Monitor — AI sets up anomaly detection for webhook failures and latency spikes.

Mobile app specifics

If the bot is embedded not in a server service but directly in a mobile app, you need WebSocket subscription or polling. For Telegram in a mobile context, this means getUpdates with long polling through BackgroundFetch (iOS) or WorkManager (Android). Keeping a persistent WebSocket for a bot in the background on iOS is impossible — the system will kill the process. The correct pattern: a push notification from the server wakes the app, it makes one getUpdates call, processes the queue, and goes back to sleep. This reduces battery drain by 90% compared to continuous polling.

WhatsApp Cloud API in a mobile app requires a server proxy — you cannot call the Meta API directly from a mobile client (a verified business account is needed on the server side). This often surprises teams looking for an "easy" integration.

Messenger API Comparison

Telegram uses a straightforward webhook: POST with 5-second timeout and multipart file uploads. WhatsApp Cloud API requires a two-step verification (GET then POST), a media upload step before sending files, and a 20-second webhook timeout. Viber supports rich media only via send_message, not reply, has a 30-second timeout, and enforces a 200 MB file size limit with strict MIME types. These differences mean that a naive port from Telegram to Viber can take 3x longer due to rich media rework.

Process

First, a scenario audit: which commands, are buttons/carousels needed, is file exchange required, is payment needed (Telegram Payments vs WhatsApp Pay). This determines the complexity of the adapters.

Next: FSM design, adapter implementation one by one (Telegram first — the most mature API), integration with core logic, webhook load testing (up to 1000 requests/min). A separate stage is monitoring: logging incoming payloads with personal data masking, alerts for delivery_failed in Viber and failed webhook verifications.

Common integration mistakes (and how to avoid them)
  • Missing WhatsApp webhook verification → webhook doesn't register. Use a dedicated endpoint that echos the challenge.
  • Using reply API for Viber rich media → buttons don't show. Always use send_message for rich media.
  • Storing state in memory → dialogue loss on restart. Use Redis or PostgreSQL.
  • No timeouts on Telegram → duplicate webhooks. Set a 5-second timeout in your server.
  • Direct call to Meta API from a mobile app → blocking. Implement a server proxy.

What's included (deliverables)

  • Scenario and requirements audit using AI tools
  • FSM and adapter layer design
  • Adapter implementation for Telegram, WhatsApp, Viber
  • Integration with server-side and mobile app
  • Load testing (up to 1000 webhooks/min) with AI-generated test cases
  • Monitoring and alerts (logs, PII masking, anomaly detection)
  • Documentation and team training
  • Post-release support (3 months)

Timeline and cost estimates

A bot in one messenger with basic commands — 3–5 days. Multichannel implementation with FSM, files, buttons, and server-side — 2–4 weeks. If CRM or payment integration is needed — separate assessment after requirements analysis. Starting price for a multichannel bot is $5,000, with typical savings of 40–60% compared to building three separate bots. We have completed over 50 messenger integrations with a 95% client satisfaction rate.

App Store Review Guidelines Section 4.2 mandates minimal functionality, so the bot must work without subscriptions. We consider this during design. We have 5+ years of experience in mobile and server solutions and have implemented over 50 messenger integrations. Our clients save up to 60% of the budget on development and get a solution in 2–4 weeks. Get a consultation — we'll evaluate your project and offer the best solution.

Machine Learning in Mobile Apps: CoreML, TFLite, and On-Device Models

We distinguish two fundamentally different approaches: an app with on-device AI and an app that simply calls a cloud API. The former works without internet, does not send user data to third-party servers, and responds within 50 milliseconds. The latter depends on network latency and pricing plans. Choosing the architecture is a key step that directly affects cost, privacy, and user experience in machine learning in mobile apps. Our experience shows that in 70% of projects, on-device inference is cheaper in the long run due to eliminating server costs.

How to Choose Between CoreML and TFLite for On-Device Inference?

CoreML — Apple's native framework for running ML models on device. Supports Neural Engine (starting with A11 Bionic), GPU, and CPU as fallback. Models are converted to .mlmodel format via coremltools from PyTorch, ONNX, or TensorFlow. Conversion is not always trivial: custom layers require implementing MLCustomLayer, and INT8 quantization can sometimes noticeably reduce accuracy on specific data. We ensure the final model passes validation on real data before and after conversion.

TensorFlow Lite — cross-platform alternative for Android and Flutter. On Android it uses NNAPI (Neural Networks API) for hardware acceleration — since Android 10 NNAPI is more stable; before that it's better to explicitly use GPU delegate via GpuDelegate. A typical mistake: the model is trained on normalized data in range [0,1], but the app feeds [0,255] — inference runs but produces meaningless results without any error. We include an automatic input data validation module in the SDK.

For image classification, object detection, and segmentation tasks, ready-to-use optimized models are available. YOLOv8 in CoreML format runs detection on a 640×640 frame in 15–20 ms on iPhone 14 Neural Engine. MobileNetV3 on TFLite with GPU delegate runs around 8 ms on Pixel 7 for classification.

Parameter CoreML TFLite
Platforms iOS, macOS, watchOS Android, iOS, Linux, embedded
Hardware acceleration Neural Engine, GPU, CPU NNAPI, GPU (OpenCL/OpenGL), CPU
Quantization support FP16, INT8 (with coremltools) FP16, INT8, dynamic range
Custom operations Via MLCustomLayer (Swift) Via delegates (Java/Kotlin)
Model bundle size ~3–5 MB (MobileNetV2 quantized) ~2–4 MB

What If You Need Text Generation On-Device?

Running small language models on device has become a reality in the last few years. Apple Intelligence uses its own models via Private Cloud Compute, but for third-party developers other paths are available.

llama.cpp with Metal backend on iOS is a working approach for phi-3-mini (3.8B parameters, 4-bit quantization, ~2.3 GB). Inference: 15–25 tokens/second on iPhone 15 Pro. For integration in Swift, use the Swift Package llama.swift or a wrapper via C interface llama.h. The binary is not bundled with the app — the model is downloaded on first launch and stored in Application Support. Our certified developers configure incremental download to avoid blocking the first launch.

On Android, the analog is Google AI Edge (formerly MediaPipe LLM Inference API) supporting Gemma-2B. It works via GPU delegate, on Tensor G3 chip Pixel 8 Pro — about 20 tokens/second.

Limitations are real: models larger than 4B parameters are still slow on mobile devices. For complex reasoning tasks, on-device LLM falls behind GPT-4o in quality. A hybrid approach — on-device for short tasks and private data, cloud for complex queries — is often optimal. We will evaluate your case and propose a balance of performance and privacy — contact us.

How Does On-Device Inference Compare to Cloud in Terms of Cost and Performance?

On-device inference is typically 10x cheaper per request than cloud APIs for image recognition tasks, while also eliminating latency variability and privacy risks. The table below summarizes the trade-offs.

Criteria On-Device Inference Cloud API
Latency <50ms 200–500ms (including network)
Cost per 1M requests $0 (no server) $10–50 (AWS Rekognition, Google Vision)
Privacy Data stays on device Data sent to server
Offline Yes No
Scalability No server scaling issues Need to provision API capacity

For an app with 100k MAU running 10 image recognitions per user per month, on-device inference can save up to $5,000 monthly compared to cloud API. Get a free consultation on your ML architecture today.

Integrating OpenAI API and Other Cloud Models

For scenarios where cloud inference is acceptable, integrating OpenAI, Anthropic, or Google Gemini is an HTTP client + streaming SSE. In Swift, AsyncThrowingStream is convenient for streaming responses. In Kotlin, use Flow.

Critically: API keys must never be stored in the app bundle. Even an obfuscated key can be extracted from the IPA in 10 minutes using strings or frida. Correct architecture: mobile app → your own backend → OpenAI API. The backend controls rate limiting, logs requests, and protects the key.

What Is Included in the Work (Deliverables)

  • Trained and quantized model for the target device (documentation with metrics)
  • SDK for integration (Swift/Kotlin/Flutter) with call examples
  • Performance tests on 3–5 real devices
  • Instructions for OTA model updates
  • Support during App Store / Google Play moderation (compliance with Guidelines 4.2, 5.1)
  • 2 weeks of technical support after release

Typical Project Pipeline

  1. Task analysis — measure latency, privacy, size, supported devices.
  2. Model prototyping — in Python, evaluate accuracy on target data.
  3. Conversion and quantization — for CoreML/TFLite with validation.
  4. Integration into the app — model wrapped in a service layer (easy to swap CoreML ↔ TFLite ↔ cloud).
  5. Testing — on real devices, measure FPS, RAM, battery.
  6. Deployment — via TestFlight / Firebase App Distribution, monitor metrics.

Timelines: integration of a ready CoreML/TFLite model — 1–2 weeks, development of a custom model with mobile optimization — from 6 weeks, on-device LLM chat with personalization — 4–8 weeks.

Why We Take on Complex Cases?

10+ years of experience in mobile development, 50+ implemented AI/ML solutions, guarantee of compatibility with current iOS and Android versions. All projects undergo code review and load testing. The cost includes preparation of moderation documentation and training of your team.

Contact us — we will help you choose the architecture and implement ML in your app turnkey. Order an audit of your existing solution — we will assess the potential for server cost savings free of charge. In some projects, savings can reach significant amounts per month.