Get Actual Phone Calls from Home Assistant
Twilio phone calls for critical alerts
Contents
- The Problem with Existing Workarounds
- What is Twilio?
- Setting Up Twilio
- Creating Your Account
- UK Regulatory Bundle
- Purchasing a Number
- Getting Your Credentials
- Testing with Python
- Configuring Home Assistant
- Step 1: Enable the Twilio Integration
- Step 2: Configure the Webhook in Twilio
- Step 3: Add Twilio to configuration.yaml
- Step 4: Restart Home Assistant
- Creating an Automation
- Costs
- Wrap Up
Push notifications are great for most Home Assistant alerts, but what about genuinely critical events? If your intruder alarm trips at 3am, a push notification buried in your notifications isn't going to be enough.
I wanted my Home Assistant setup to actually ring my phone, properly, when something critical happens. The kind of thing that actual alarm monitoring companies do with their automated call-outs.
The Problem with Existing Workarounds
Home Assistant doesn't natively support making phone calls, and the community has come up with some creative (if hacky) workarounds over the years. Some people set a timer or alarm on the target phone via an automation, which then rings, but that's unreliable and awkward to manage. Others use what's essentially a notification bomb approach, where the system fires off push notifications in rapid succession until someone acknowledges the alert. It works, sort of, but it's messy and not exactly the kind of alerting you'd want for a security system.
What actual alarm companies use is an automated telephony service, which is a system that programmatically initiates a real phone call to your number, often with a text-to-speech message explaining what's going on. That's exactly what I wanted to replicate here.
What is Twilio?
Twilio is a cloud communications platform that provides APIs for sending SMS messages, making phone calls, and handling other communication channels programmatically. It's used by thousands of businesses for everything from two-factor authentication codes to customer support call routing. For our purposes, we're interested in its Voice API, as this is the ability to trigger an outbound phone call to any number, with a text-to-speech message of our choosing.
The basic idea is simple, Home Assistant fires an automation, which calls the Twilio API, which initiates a real phone call to your mobile. Your phone rings just like any other incoming call so it's impossible to miss if you're anywhere near it.
Setting Up Twilio
Creating Your Account
Head over to twilio.com and create an account. Twilio offers a trial tier, but, and this is important, trial accounts cannot make outbound phone calls to unverified numbers. I spent a fair amount of time troubleshooting what I thought was a configuration issue in Home Assistant, only to discover that the problem was simply that my trial account didn't have permission to place calls. Home Assistant's error logging wasn't particularly helpful here either, so save yourself the headache, you will need a paid (verified) Twilio account to make this work.
UK Regulatory Bundle
If you're based in the UK, there's an additional step before you can purchase a phone number. UK regulations require telephony providers to verify the identity of anyone provisioning phone numbers. Twilio handles this through what they call a Regulatory Bundle. It's essentially a KYC process where you submit identification and confirm how the number will be used.
This is a legal requirement so that Twilio can comply with Ofcom regulations. You're proving who is behind the phone number and confirming its intended use. The process is straightforward, you fill in some details, upload ID if requested, and wait for approval. In my case, it took around two days for the bundle to be approved.
Purchasing a Number
Once your regulatory bundle is approved, you can purchase a phone number. When browsing available numbers, pay attention to the capabilities listed for each one. Some numbers support voice only, some support SMS only, and some support both. For this use case, you want a number with voice capability at minimum. I went with voice only. SMS is effectively just another push notification, so it doesn't add much value for critical alerting and I don't want to control my Home Assistant instance through texts.
Getting Your Credentials
After purchasing your number, navigate back to the main Twilio console dashboard. You'll need two pieces of information:
- Account SID = your unique account identifier
- Auth Token = your secret API key
Keep both of these safe. You'll need them for the Home Assistant configuration.
Testing with Python
Before configuring Home Assistant, I'd recommend testing your Twilio setup independently to confirm everything works. This eliminates Home Assistant as a variable if something goes wrong. Here's a simple Python script that places a test call:
from twilio.rest import Client
account_sid = "YOUR_ACCOUNT_SID"
auth_token = "YOUR_AUTH_TOKEN"
client = Client(account_sid, auth_token)
call = client.calls.create(
to="+441234567890", # Your mobile number
from_="+44XXXXXXXXXX", # Your Twilio number
twiml="""<Response>
<Say>This is a test call from Home Assistant via Twilio.</Say>
</Response>"""
)
print(f"Call SID: {call.sid}")
Replace the placeholder values with your actual credentials and numbers. If this script successfully places a call to your phone, you know Twilio is working correctly and any issues from this point are on the Home Assistant side.
You'll need the Twilio Python library installed (
apt install python3-twilio) to run this script.
Configuring Home Assistant
Step 1: Enable the Twilio Integration
In Home Assistant, go to Settings → Devices & Services → Add Integration and search for Twilio. Once enabled, the integration will provide you with a webhook URL.
Step 2: Configure the Webhook in Twilio
This step connects your Twilio number back to Home Assistant. It's primarily needed if you want incoming calls to your Twilio number to trigger automations in Home Assistant. For our outbound-call-only use case, it's not strictly required.
- In the Twilio console, navigate to Phone Numbers > Manage > Active Numbers
- Select your purchased number
- Click Configure
- Under "A call comes in", paste the Home Assistant webhook URL
- Set the request type to HTTP POST
- Under "Primary Handler Fails", add the same webhook URL with HTTP POST
Step 3: Add Twilio to configuration.yaml
Add the following to your Home Assistant configuration.yaml file:
twilio:
account_sid: YOUR_ACCOUNT_SID
auth_token: YOUR_AUTH_TOKEN
notify:
- name: twilio_call
platform: twilio_call
from_number: "+44XXXXXXXXXX" # Your Twilio number, no spaces
Replace the credentials with your actual Account SID and Auth Token, and set the from_number to your Twilio phone number in full international format with no spaces.
Step 4: Restart Home Assistant
After saving configuration.yaml, restart Home Assistant for the changes to take effect. Once it's back up, you should have a new notify.twilio_call service available.
Creating an Automation
Now for the fun part. Here's an example automation that places a phone call:
alias: Twilio Test Call
description: "Test phone call via Twilio"
triggers: []
conditions: []
actions:
- action: notify.twilio_call
data:
message: >-
Hello, this is Home Assistant calling. This is a test phone call.
If you are receiving this, your Twilio integration is working correctly.
target: "+44XXXXXXXXXX" # The number you want to call
mode: single
The message field is converted to speech using text-to-speech, so you can write whatever you want here. For a real security automation, you'd want something more useful:
alias: Intruder Alarm Phone Call
description: "Call my phone when the intruder alarm is triggered"
triggers:
- trigger: state
entity_id: alarm_control_panel.home_alarm
to: "triggered"
conditions: []
actions:
- action: notify.twilio_call
data:
message: >-
Alert. Your home intruder alarm has been triggered.
Please check your cameras immediately.
This is an automated call from Home Assistant.
target: "+44XXXXXXXXXX"
mode: single
You can trigger this from any automation condition such as alarm panels, motion sensors, water leak detectors, smoke alarms, whatever you need. The message is entirely customisable, so you can include details about which sensor triggered the alert.
Costs
Twilio operates on a pay-as-you-go model. In the UK, you'll pay a small monthly fee for the phone number itself (usually around £1/month) and then a per-minute rate for outbound calls. The per-minute rates for UK mobile calls are low, only a few pence per minute. For an alerting system that might fire a handful of times per year, the cost is negligible.
Wrap Up
If you're running any kind of security or safety automation in Home Assistant, this is well worth setting up. Push notifications are fine for informational alerts, but for anything that genuinely needs your immediate attention, nothing beats your phone actually ringing.