Skip to content

API Reference parrot.integrations.whatsapp.utils

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.whatsapp.utils

View source

Utilities for WhatsApp integration.

Provides markdown conversion, message splitting, and phone number sanitization.

Function convert_markdown_to_whatsapp

Convert standard Markdown to WhatsApp-compatible formatting.

WhatsApp supports:

  • bold (not bold)
  • italic (same as standard MD single underscore)
  • strikethrough (not strikethrough)
  • code (same as standard MD)

Standard MD -> WhatsApp:

  • bold -> bold
  • strikethrough -> strikethrough
  • Code blocks (...) are preserved as-is

convert_markdown_to_whatsapp(text: str) -> str

Parameter Type Default Description
text str

Returns: str

Function sanitize_phone_number

Normalize a phone number by stripping non-digit characters.

sanitize_phone_number(number: str) -> str

Parameter Type Default Description
number str Phone number string (may contain +, spaces, dashes).

Returns: str — Cleaned phone number string with only digits.

Function split_message

Split a long message into chunks that fit WhatsApp's message size limit.

Splits at natural boundaries (paragraphs, newlines, sentences) without breaking code blocks.

split_message(text: str, max_length: int = 4096) -> List[str]

Parameter Type Default Description
text str The text to split.
max_length int 4096 Maximum characters per chunk (default 4096).

Returns: List[str] — List of text chunks.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally