PTENES
MODULE 2.2

๐Ÿ’ฌ Communication Channels

Telegram, WhatsApp, Discord, Slack, IMAP Email, and voice. Learn the BaseChannel contract and implement any channel in minutes.

6
Topics
60
Minutes
Basic
Level
Hands-on
Type
1

๐Ÿ“ฑ Telegram โ€” The Main Channel

Telegram is the default choice for good reasons: stable API, free, file support, inline buttons, groups, and channels. 95% of personal assistant use cases work perfectly on Telegram.

๐Ÿ“ก Polling vs. Webhook

Polling (Recommended for development)

Bot periodically asks Telegram: โ€œAny new messages?โ€ Simple, no infrastructure. Latency of 1โ€“2 seconds.

Webhook (For production)

Telegram sends messages directly to your URL. Requires public HTTPS. Zero additional latency. Ideal for VPS.

๐Ÿ’ก Telegram Security

Set TELEGRAM_ALLOWED_USERS to only your IDs. Anyone can message a Telegram bot โ€” without a whitelist, anyone can control your Jarvis.

2

๐Ÿ”— BaseChannel โ€” The Universal Contract

O BaseChannel is the abstraction that lets the Agent be channel-agnostic. It doesnโ€™t matter whether you use Telegram or Discord โ€” the Agent just calls send(), and the implementation takes care of the rest.

๐Ÿงฉ BaseChannel Interface

class BaseChannel(ABC):

@abstractmethod
async def start(self) -> None:
"""Initializes the connection and starts listening for messages"""

@abstractmethod
async def send(self, user_id: str, message: str) -> None:
"""Sends a response to the user"""

@abstractmethod
async def stop(self) -> None:
"""Closes the connection gracefully"""
3

๐Ÿ’š WhatsApp via Business API

In Brazil, WhatsApp is irreplaceable. The Meta Business API enables official integration โ€” with no risk of a ban, and with support for approved media and templates.

๐Ÿ“‹ WhatsApp Integration Flow

1

Create a Meta Business account and app

2

Enable the WhatsApp Business API and generate a token

3

Configure a webhook with token verification

4

Implement WhatsAppChannel by extending BaseChannel

4

๐Ÿ’ฌ Discord and Slack

For teams, Discord and Slack are the natural channels. A Jarvis inside the team workspace eliminates the need to leave the platform to ask the assistant questions.

๐ŸŽฎ Discord

  • โ€ข discord.py with on_message events
  • โ€ข Slash commands for structured interaction
  • โ€ข One thread per conversation for organization
  • โ€ข Reactions for approval/rejection

๐Ÿ’ผ Slack

  • โ€ข Bolt SDK with OAuth 2.0
  • โ€ข Events API for listening to messages
  • โ€ข Mention handler (@atlas)
  • โ€ข Block Kit for rich responses
5

๐Ÿ“ง IMAP Email Channel

Email is the channel with the highest ROI for automation. Triage, categorization, and automatic replies to routine emails saves hours every week without requiring you to change your habits โ€” Jarvis works in your existing inbox.

๐Ÿ“ฌ Email Flow

# Flow Diagram
IMAP mailbox โ”€โ”€โ†’ IMAP poll (30s) โ”€โ”€โ†’ New email?
โ”‚
โ–ผ
Parse MIME + extract text
โ”‚
โ–ผ
Agent.process(email)
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Auto-reply Draft for review
6

๐ŸŽค Voice Wake Word

The voice channel turns Jarvis into a truly hands-free assistant. With Whisper for transcription and a configurable wake word, you speak naturally and Jarvis responds by voice.

๐Ÿ’ก Latency Tip

For real-time voice responses, use Whisper tiny (speed) for transcription and a local TTS model for synthesis. Total latency under 1 second is possible with mid-range hardware.

๐ŸŽ™ Voice Pipeline

Microphone โ†’ VAD (detects speech) โ†’ Audio buffer
โ†’ Wake word check ("Atlas"?)
โ†’ Whisper STT โ†’ transcribed text
โ†’ Agent.process(text)
โ†’ TTS (text-to-speech)
โ†’ Speaker (voice response)

โœ… Module 2.2 Summary

โœ“
Telegram โ€” Default channel: free, robust, polling or webhook
โœ“
BaseChannel โ€” 3-method contract: start(), send(), stop()
โœ“
WhatsApp โ€” Meta Business API, HTTPS webhook, high ROI in Brazil
โœ“
Discord/Slack โ€” Team channels with slash commands and events
โœ“
IMAP email โ€” Triage and automatic response, with the highest ROI in hours saved
โœ“
Voice โ€” Whisper STT + wake word + TTS for hands-free interaction

Next Module:

2.3 โ€” Memory and Knowledge: SQLite FTS5, BM25, 2 layers, and automatic compaction