Bridge a Matterbridge chat stream into WordPress. Every chat message that starts with a título: line becomes one scheduled WordPress post, with media attachments, an auto-generated card image, and author metadata.
There are two interchangeable entry points:
| Script | Delivery | Auth |
|---|---|---|
zapost.py |
WordPress REST API (/wp-json/wp/v2/posts, /media) |
WP Application Password (Basic auth) |
zapost-wpwh.py |
WP Webhooks Pro (create_post / create_media) |
WP Webhooks API key |
Both connect to Matterbridge's HTTP streaming endpoint (/api/stream), transform each matching message, and keep reconnecting automatically if the stream drops.
- Subscribe to
{MATTERBRIDGE_API_URL}/api/streamand read one JSON message per line. - Keep only
msg/messageevents whose text starts withtítulo:(Portuguese, lowercase, accented). When the text is empty, the caption of the first attached file is used instead. - If the message has no media, render a 1080×1080 card JPG (background, stamp overlay, wrapped text) with ImageMagick and upload it as the featured image.
- Build the post: title from the
título:line, author block with avatar, embedded images/attachments, text body, tags from the gateway/account, and_matterbridge_*metadata. - Publish 12 hours in the future (scheduled), using
WP_POST_STATUS(futurein the sample.env,draftby default).
A small health endpoint answers GET /health on http://127.0.0.1:8423/health.
- Python 3.13
- ImageMagick (
convert) with theDejaVu-Sans-Boldfont available - A running Matterbridge with the API enabled and an API token
- A WordPress site with either an Application Password (REST variant) or WP Webhooks Pro configured (webhook variant)
python -m venv .venv
.venv/bin/pip install -r requirements.txt
cp env.example .env
$EDITOR .envConfiguration is read from .env next to the script. The variables each script actually reads:
| Variable | Used by | Purpose |
|---|---|---|
MATTERBRIDGE_API_URL |
both | Matterbridge base URL (default http://127.0.0.1:8424) |
MATTERBRIDGE_API_TOKEN |
both | Matterbridge API token (sent as Bearer header and ?token=) |
MEDIA_BASE_URL |
both | Public base URL for matterbridge media files |
WP_BASE_URL, WP_USERNAME, WP_APP_PASSWORD |
zapost.py |
WordPress REST API credentials |
WP_WEBHOOK_URL, WPWHPRO_API_KEY |
zapost-wpwh.py |
WP Webhooks Pro endpoint and key |
WP_POST_AUTHOR, WP_POST_STATUS, WP_POST_TYPE, WP_POST_CATEGORY, WP_COMMENT_STATUS, WP_TAGS_INPUT |
both | Post defaults |
STAMP_PATH, CARDS_DIR, CARD_BG_COLOR, CARD_TEXT_COLOR, CARD_STAMP_OPACITY |
both | Card image generation |
Notes:
env.exampleis a template and is out of date in places. The scripts readMATTERBRIDGE_API_URL(HTTP streaming), notMATTERBRIDGE_WS_URL, and ignoreSHARED_SECRET,DATE_PREFIX, andLISTEN_PORT.- In
zapost-wpwh.py,WPWHPRO_API_KEY,STAMP_PATH,CARDS_DIR, andCARD_*are read before.envis loaded, so their.envvalues currently have no effect; set them in the process environment or fix the load order. - The REST API variant expects category and tag term IDs; tag names are passed as-is and may be ignored by WordPress.
.venv/bin/python zapost.py # REST API variant
.venv/bin/python zapost-wpwh.py # WP Webhooks Pro variantBoth are long-running foreground processes with auto-reconnect and a rotating middleware.log (5 MB × 3 backups) beside the script. Run only one of them at a time: they share the log file and both bind port 8423.
Send through your connected chat:
título: Reunião do comitê
Pauta da semana: ...
This creates a post titled "Reunião do comitê" scheduled 12 hours ahead, with the remaining text as its body.