Webhook handlers for WhatsApp (Meta Cloud API), Telegram (Bot API), and Email (inbound/outbound)
Project description
ulfblk-channels
Webhook handlers para WhatsApp (Meta Cloud API), Telegram (Bot API), y Email (inbound webhook + SMTP outbound).
Instalacion
uv add ulfblk-channels
Para email outbound (SMTP):
uv add ulfblk-channels[email]
from fastapi import FastAPI
from bloque_channels.whatsapp import WhatsAppRouter, WhatsAppSettings
app = FastAPI()
settings = WhatsAppSettings(
api_token="tu-token",
verify_token="mi-token-verificacion",
phone_number_id="123456789",
)
whatsapp = WhatsAppRouter(
verify_token=settings.verify_token,
on_message=lambda msg: print(f"Mensaje: {msg.text}"),
settings=settings,
)
app.include_router(whatsapp.router, prefix="/webhook")
Telegram
from bloque_channels.telegram import TelegramRouter, TelegramSettings
settings = TelegramSettings(
bot_token="123:ABC",
secret_token="mi-secret",
)
telegram = TelegramRouter(
on_message=lambda msg: print(f"Mensaje: {msg.text}"),
settings=settings,
secret_token=settings.secret_token,
)
app.include_router(telegram.router, prefix="/telegram")
from bloque_channels.email import EmailRouter, EmailClient, EmailSettings
# Inbound (webhook)
email_router = EmailRouter(
on_message=lambda msg: print(f"Email de: {msg.sender}"),
webhook_secret="secret",
)
app.include_router(email_router.router, prefix="/email")
# Outbound (SMTP, requiere ulfblk-channels[email])
email_settings = EmailSettings(
smtp_host="smtp.gmail.com",
smtp_port=587,
smtp_username="user@gmail.com",
smtp_password="app-password",
from_address="user@gmail.com",
)
client = EmailClient(email_settings)
await client.send_text("dest@example.com", "Asunto", "Cuerpo del email")
Health Check
from bloque_channels.health import channels_health_check
from bloque_channels.whatsapp import WhatsAppClient
from bloque_channels.telegram import TelegramClient
channels = {
"whatsapp": whatsapp_client,
"telegram": telegram_client,
}
status = await channels_health_check(channels)
# {"whatsapp": True, "telegram": False}
Dependencias
ulfblk-core(obligatorio)httpx>=0.27(obligatorio)aiosmtplib>=3.0(opcional, para email outbound)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ulfblk_channels-0.1.0.tar.gz
(11.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ulfblk_channels-0.1.0.tar.gz.
File metadata
- Download URL: ulfblk_channels-0.1.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4171b587b96c346e5ac8edd055776e8188777653db0a5cd676df65cdee3ea3
|
|
| MD5 |
feb9755d31728095987d4f5f8559494d
|
|
| BLAKE2b-256 |
d6ad8bcf76be4a7ca7bf032d1762721d89eaeef6c7ced4b43370d645209e4f50
|
File details
Details for the file ulfblk_channels-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ulfblk_channels-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baec5c694f6ad31d17cefa6f882f918028b89d71dca0bfadffda497452d706ab
|
|
| MD5 |
451bec908934730ddcf6ff274436e5f0
|
|
| BLAKE2b-256 |
629024f48c5bdf08728a86912e5e474b25d423e273d9007e130edbd6eb8a5f87
|