Home Assistant
WhatsApp + Home Assistant
Home Assistant’s built-in REST command can send WhatsApp messages. Add a few lines of YAML and call it from any automation or script.
Setup
- 1
Link a number and copy a session token
Sign in at /start and link the WhatsApp number that should send the alerts. A spare number works well. Copy the session token (ch_live_...).
- 2
Store the token in secrets.yaml
Add whatsapp_auth: "Bearer ch_live_YOUR_SESSION_TOKEN" to secrets.yaml so it stays out of your configuration file.
- 3
Add the REST command and restart
Paste the rest_command block into configuration.yaml and restart Home Assistant. It then appears as the action rest_command.whatsapp_send.
- 4
Call it from an automation
Pass to (phone number with country code, digits only, or a group ID ending in @g.us) and message. Templates work in both.
configuration.yaml
rest_command:
whatsapp_send:
url: https://wp-rapidapi.retentionstack.agency/v1/sendText
method: POST
content_type: application/json
headers:
Authorization: !secret whatsapp_auth
payload: '{"session": "default", "chatId": "{{ to }}", "text": {{ message | to_json }}}'Example automation
automation:
- alias: Front door opened
triggers:
- trigger: state
entity_id: binary_sensor.front_door
to: "on"
actions:
- action: rest_command.whatsapp_send
data:
to: "14155550123"
message: "Front door opened at {{ now().strftime('%H:%M') }}"What people build with it
- Door or motion sensor triggered while away → message
- Washing machine finished → message to the household group
- Water leak sensor wet → alert to everyone in the family
- Battery low on a device → weekly reminder
Links
Get your API key
Free tier, no credit card. Link a number by QR code, then copy a session token from the console.
Get started free