You can connect your AI assistant to this service so it can send SMS/WhatsApp/Telegram/email/notifications from natural language. The recommended design is: AI decides, your backend sends the HTTPS request.
Typical ways users use ChatPhoneApp Server:
With AI, the same becomes:
POST /api/v1/messages.Step 1: have the AI return a JSON object (not free text) like:
{
"action": "send_message",
"channel": "sms",
"to": "+15551234567",
"text": "Build finished successfully.",
"subject": null
}
Step 2: your backend validates and sends:
POST /api/v1/messages
Authorization: Bearer CLIENT_API_KEY
Content-Type: application/json
{
"phone_id": "PHONE_ID",
"channel": "sms",
"to": "+15551234567",
"text": "Build finished successfully.",
"source": "ai-assistant",
"idempotency_key": "your-unique-id"
}
import uuid
import requests
BASE_URL = "https://YOUR_RELAY_HOST"
CLIENT_API_KEY = "..."
PHONE_ID = "..."
ALLOWED_CHANNELS = {"sms", "wa", "tg", "email", "notify", "tg_bot", "pchat"}
ALLOWED_TO = {"+15551234567", "@your_username", "me@example.com"} # example allowlist
def ai_send(req: dict) -> dict:
if req.get("action") != "send_message":
return {"ok": False, "error": "unsupported action"}
ch = (req.get("channel") or "").strip()
to = (req.get("to") or "").strip()
text = (req.get("text") or "").strip()
subject = req.get("subject")
if ch not in ALLOWED_CHANNELS:
return {"ok": False, "error": "channel not allowed"}
if ch != "notify" and to not in ALLOWED_TO:
return {"ok": False, "error": "recipient not allowed"}
if not text:
return {"ok": False, "error": "text required"}
payload = {
"phone_id": PHONE_ID,
"channel": ch,
"to": to if ch != "notify" else "",
"text": text,
"source": "ai-assistant",
"idempotency_key": str(uuid.uuid4()),
}
if subject:
payload["subject"] = subject
r = requests.post(
f"{BASE_URL}/api/v1/messages",
headers={"Authorization": f"Bearer {CLIENT_API_KEY}", "Content-Type": "application/json"},
json=payload,
timeout=10,
)
return {"ok": r.ok, "status": r.status_code, "body": r.json()}
More send examples: HTTPS API Examples