How to send a message to a Viber Community using Python and the Viber REST API (/pa/post)?

1 day ago 2
ARTICLE AD BOX

I'm building a scheduled automation in Python that reads rows from
Google Sheets and sends formatted messages to specific Viber
communities based on a branch name column. The script runs 24/7
on a local Windows machine.

What I'm trying to do

- Read rows from Google Sheets using gspread
- For each row that is "due" (3 days since last sent), build a
formatted message
- Send that message to the correct Viber community based on a
branch name mapped to a community ID
- Also send a file attachment (PDF or image) if a link is present

What I've tried

Based on the Viber REST API docs, I'm using the /pa/post endpoint
since I need proactive/outbound sends — not a reply to a user
message. Here is my current implementation:

import requests def send_text(community_id: str, text: str, token: str, bot_name: str) -\> bool: payload = { "auth_token": token, "to": community_id, "type": "text", "text": text, "sender": {"name": bot_name} } r = requests.post( "https://chatapi.viber.com/pa/post", json=payload, headers={"Content-Type": "application/json"}, timeout=10 ) result = r.json() return result.get("status") == 0

My questions

1. Is /pa/post the correct endpoint for sending to a Viber
Community proactively (without a user messaging the bot first)?

2. Does the bot need to be set as Admin of the community, or is
being a regular member enough?

3. When sending a file attachment (PDF), is this the correct
payload structure?

file_payload = { "auth_token": token, "to": community_id, "type": "file", "media": "https://drive.google.com/file/...", "file_name": "document.pdf", "size": 0, "sender": {"name": bot_name} }

4. Are there any known regional restrictions for the Viber Bot API
in the Philippines?

Environment

- Python 3.11
- requests 2.31
- Windows 11
- Viber Bot created at partners.viber.com

Any help is appreciated. Thanks!

Read Entire Article