
Most of the numbers your campaigns call already live somewhere else: a CRM, a scheduling system, an ERP, or a simple database that your team keeps up to date. Exporting a CSV file from that system and uploading it to SIP Caller every day works, but it's one more manual task, and one more chance to forget it.
In this two-part series, we build a small integration that connects SIP Caller with an external database, end to end:
To keep things concrete, we'll use a common scenario: a clinic that wants to call every patient the day before their appointment. The patient hears a personalized reminder, such as:
Hello John, this is Northside Clinic reminding you of your appointment tomorrow, Wednesday, November 4, at 10:30 AM. Press 1 to confirm, or press 2 to talk to our team and reschedule.
The same approach works for any other use case: overdue invoices, policy renewals, deliveries, or new leads. Only the table and the variables change.
Here is the table that holds the appointments:
CREATE TABLE appointments (
id SERIAL PRIMARY KEY,
phone_number VARCHAR(30) NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
appointment_at TIMESTAMP NOT NULL,
reminder_campaign_id UUID
);The first five columns are the data we need to make the call. The last one, reminder_campaign_id, is filled in by the script with the ID of the campaign that called the patient. It prevents the same appointment from being loaded twice if the script runs more than once on the same day, and it tells you exactly which campaign to check if a patient says they never got the call.
Let's add some sample data:
INSERT INTO appointments (phone_number, first_name, last_name, appointment_at) VALUES
('+18005551234', 'John', 'Carter', '2026-11-04 10:30'),
('+18005551235', 'Jane', 'Miller', '2026-11-04 11:15'),
('+18005551236', 'Peter', 'Wilson', '2026-11-04 16:00');Phone numbers can be stored with or without separators: SIP Caller removes spaces, dashes, dots and parentheses, so +1 (800) 555-1234 works too. See Add numbers for all the accepted formats.
In the Web Console, go to Settings > API Keys and create a new API key for the script, as explained in API Keys. Grant it the Campaign Admin role, since the script needs to create and activate campaigns, not only add numbers to them. Copy the token: it's only shown once.
The Authentication page explains how the token is sent with each request, and lists all the available roles.
The script needs a campaign to load the numbers into. Here's an important detail: a campaign can only be activated once, from Draft to Active. When it finishes, it can't be activated again. Since our script runs every day, it needs a new campaign every day.
The simplest way to do this is to create a template campaign in the Web Console, with all the settings you want: the phone system and extension, the working times, the retry policy, and the call flow that plays the reminder. Then, every day, the script duplicates it into a new campaign, adds the numbers, and activates the copy. The template itself stays in Draft state and never makes any calls.
For the call flow, the Appointment Reminder template does exactly what we need: it plays the reminder, lets the patient press a digit to confirm, and transfers the call to your team to reschedule. Use variables in square brackets in the prompt, matching the names the script sends:
Hello [FirstName], this is Northside Clinic reminding you of your appointment tomorrow, [AppointmentDate], at [AppointmentTime]. Press 1 to confirm, or press 2 to talk to our team and reschedule.
When creating the template campaign, select Static number provisioning, so each daily campaign finishes automatically once all its numbers have been called. See Create a Campaign for a description of every setting.
Finally, copy the campaign ID of the template and your account ID, as shown in the API introduction.
The script uses two well-known Python libraries: requests to call the REST API, and psycopg to connect to PostgreSQL. Create a folder for the project, with a virtual environment to install them:
mkdir -p /opt/appointment-reminders
cd /opt/appointment-reminders
python3 -m venv .venv
.venv/bin/pip install requests "psycopg[binary]"Then save the following code as send_reminders.py:
"""Loads tomorrow's appointments into a new SIP Caller campaign, and activates it."""
import json
import os
import sys
from datetime import date, timedelta
import psycopg
import requests
API_URL = f"https://api.sipcaller.com/v1/accounts/{os.environ['SIPCALLER_ACCOUNT_ID']}"
TEMPLATE_CAMPAIGN_ID = os.environ["SIPCALLER_TEMPLATE_CAMPAIGN_ID"]
DATABASE_URL = os.environ["DATABASE_URL"]
# Names of the variables used in the call flow prompts, in the same order as the values
VAR_NAMES = ["FirstName", "LastName", "AppointmentDate", "AppointmentTime", "AppointmentId"]
BATCH_SIZE = 500
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['SIPCALLER_API_KEY']}"
def call_api(method, path, **kwargs):
response = session.request(method, API_URL + path, **kwargs)
if not response.ok:
sys.exit(f"{method} {path} failed with status {response.status_code}: {response.text}")
return response.json()
def get_appointments(conn, day):
with conn.cursor() as cur:
cur.execute(
"""
SELECT id, phone_number, first_name, last_name, appointment_at
FROM appointments
WHERE appointment_at >= %s AND appointment_at < %s
AND reminder_campaign_id IS NULL
ORDER BY appointment_at
""",
(day, day + timedelta(days=1)),
)
return cur.fetchall()
def create_campaign(name):
campaign = call_api(
"POST",
f"/campaigns/{TEMPLATE_CAMPAIGN_ID}/duplicate",
params={"newCampaignName": name, "includeNumbers": "false"},
)
return campaign["id"]
def add_numbers(campaign_id, appointments):
numbers = [
{
"number": phone_number,
"varValues": [
first_name,
last_name,
f"{appointment_at:%A, %B} {appointment_at.day}", # Wednesday, November 4
appointment_at.strftime("%I:%M %p").lstrip("0"), # 10:30 AM
str(appointment_id),
],
}
for appointment_id, phone_number, first_name, last_name, appointment_at in appointments
]
for start in range(0, len(numbers), BATCH_SIZE):
call_api(
"POST",
f"/campaigns/{campaign_id}/numbers",
params={"varNames": json.dumps(VAR_NAMES)},
json=numbers[start:start + BATCH_SIZE],
)
def activate_campaign(campaign_id):
call_api("PUT", f"/campaigns/{campaign_id}/state", json="Active")
def mark_as_loaded(conn, appointments, campaign_id):
with conn.cursor() as cur:
cur.execute(
"UPDATE appointments SET reminder_campaign_id = %s WHERE id = ANY(%s)",
(campaign_id, [appointment[0] for appointment in appointments]),
)
conn.commit()
def main():
tomorrow = date.today() + timedelta(days=1)
with psycopg.connect(DATABASE_URL) as conn:
appointments = get_appointments(conn, tomorrow)
if not appointments:
print(f"No appointments to remind on {tomorrow}")
return
campaign_id = create_campaign(f"Appointment Reminders {tomorrow}")
add_numbers(campaign_id, appointments)
activate_campaign(campaign_id)
mark_as_loaded(conn, appointments, campaign_id)
print(f"Campaign {campaign_id} activated with {len(appointments)} numbers")
if __name__ == "__main__":
main()Let's go through what it does.
get_appointments selects tomorrow's appointments that haven't been loaded into a campaign yet. If there are none, for example on a Sunday, the script stops there, without creating an empty campaign.
create_campaign calls Duplicate a campaign on the template, with includeNumbers=false, since the template has no numbers anyway. The new campaign is named after the appointments date, such as Appointment Reminders 2026-11-04, so it's easy to find in the Web Console and in the reports.
If the start date of the template is in the past, the copy starts today, and its end date is moved forward by the same number of days. So a template with a one-day duration produces a new one-day campaign every day.
The response is the new campaign object, from which the script takes the id.
add_numbers sends the appointments to the Add numbers endpoint. Each number goes with its variable values, in the same order as the variable names given in the varNames query parameter. These are the values that replace [FirstName], [AppointmentDate] and [AppointmentTime] in the prompts, so each patient hears their own name, date and time. The request body looks like this:
[
{
"number": "+18005551234",
"varValues": ["John", "Carter", "Wednesday, November 4", "10:30 AM", "1"]
},
{
"number": "+18005551235",
"varValues": ["Jane", "Miller", "Wednesday, November 4", "11:15 AM", "2"]
}
]Two details are worth pointing out:
AppointmentId isn't used in any prompt, but SIP Caller keeps it with the number and includes it in the call results. In Part 2, we'll use it to find the exact database row to update when each call ends.activate_campaign calls Change campaign state with "Active" as the body. SIP Caller validates all the settings at this point, including that every variable used in the call flow has a value, and the campaign starts calling within seconds, during its working times.
The same endpoint can also pause ("Paused"), resume ("Active") or cancel ("Canceled") a campaign, for example to stop the calls if the clinic closes unexpectedly.
Finally, mark_as_loaded saves the campaign ID in each appointment. This is done last on purpose: if any request fails, the script stops with an error message describing the problem (see Errors), the appointments stay unmarked, and they'll be picked up again on the next run.
The script reads its settings from environment variables, so no secret is written in the code. Create a file named .env in the project folder, with your own values:
SIPCALLER_API_KEY=API_KEY_TOKEN
SIPCALLER_ACCOUNT_ID=ACCOUNT_ID
SIPCALLER_TEMPLATE_CAMPAIGN_ID=TEMPLATE_CAMPAIGN_ID
DATABASE_URL=postgresql://reminders:DB_PASSWORD@localhost/clinicMake it readable only by your user, since it contains the API key token:
chmod 600 .envThen create a small wrapper, run.sh, which loads the variables and runs the script:
#!/bin/sh
cd "$(dirname "$0")"
set -a
. ./.env
set +a
exec .venv/bin/python send_reminders.pyMake it executable, and give it a try:
chmod +x run.sh
./run.shIf everything is set up correctly, you'll see something like:
Campaign 01a0f2c7-3e1b-7a4d-9c58-2b6e8d1f0a93 activated with 3 numbersAnd the new campaign, with its three numbers, will show up as active in the Web Console.
On Linux, cron runs commands on a schedule. Open your crontab:
crontab -eAnd add this line to run the script every day at 9:00 AM:
0 9 * * * /opt/appointment-reminders/run.sh >> /opt/appointment-reminders/reminders.log 2>&1The five fields at the beginning are the minute, hour, day of the month, month, and day of the week. A few variations:
| Schedule | Expression |
|---|---|
| Every day at 9:00 AM | 0 9 * * * |
| Monday to Friday at 9:00 AM | 0 9 * * 1-5 |
| Every day at 9:00 AM and 2:00 PM | 0 9,14 * * * |
Keep in mind that cron uses the time zone of the server, which may not be the time zone of your campaigns. And the time the script runs doesn't need to match the time the calls are made: the campaign only calls during the working times defined in its settings, in its own time zone. Running the script early in the morning is a good choice, so the campaign is ready to go as soon as the working times begin.
The output of each run is appended to reminders.log, so you can check what happened on any given day.
On Windows, the same can be done with the Task Scheduler, running the script with the environment variables defined in the task.
Only get_appointments and mark_as_loaded touch the database. To use MySQL or MariaDB, replace psycopg with a driver such as PyMySQL, and use IN (...) instead of ANY(%s) in the update. With SQL Server, pyodbc does the same job. Everything else stays the same.
Duplicating a template keeps the script short, and lets anyone on your team change the campaign settings from the Web Console without touching the code. But if your integration needs full control, for example a different call flow or working times depending on the data, you can create the campaign with every setting from the API, using Create a campaign. See our post on creating and updating campaigns through the API for more details.
Instead of a new campaign every day, another option is a single campaign with Dynamic number provisioning, activated once from the Web Console. Dynamic campaigns keep accepting numbers while they're active, so the script only needs to add the numbers, and skip the duplicate and activation steps. This is a great fit when numbers arrive continuously, such as new leads from a web form. Daily campaigns, on the other hand, make it easier to follow each day's results separately.
| Step | Endpoint |
|---|---|
| Create the daily campaign | POST /campaigns/{id}/duplicate |
| Add the numbers | POST /campaigns/{id}/numbers |
| Activate the campaign | PUT /campaigns/{id}/state |
All paths are relative to https://api.sipcaller.com/v1/accounts/ACCOUNT_ID. Every endpoint in the API documentation includes ready-to-use examples in cURL, Python, Java, Node.js and .NET.
The campaign now runs every day without anyone touching it. But the clinic still doesn't know, from its own system, which patients confirmed their appointment, which ones asked to reschedule, and which ones couldn't be reached.
In Part 2, we'll close the loop: a small web service will receive the Call Ended webhook that SIP Caller sends when each call ends, and use the AppointmentId variable to save the result in the appointments table.
👉 Need help building your integration? Contact our team and we'll be happy to assist you.

Manual dialing has a real cost, even if it never shows up as a single line item: wasted dialing time, wrong numbers, follow-ups that fall through the cracks, and the opportunities lost in between. We break down each of these cost drivers and walk through ROI calculation examples to show what automated dialing can actually save your team.

Government agencies are under constant pressure to communicate quickly, clearly, and efficiently with large populations. Whether it’s notifying citizens about road closures, coordinating emergency responses, reminding residents about appointments, or improving tax collection efforts, timely communication is critical. Traditional communication methods such as manual phone calls or printed notices are often too slow and resource-intensive. This is why many public organizations are adopting automated outbound dialing solutions like SIP Caller to streamline citizen outreach and improve response times. In this article, we explore how government agencies can use predictive and power dialers to improve public communication and citizen engagement.

Missed appointments are a major challenge for healthcare providers. No-shows lead to underutilized resources, lost revenue, and delays in patient care. In high-demand environments, even a small percentage of missed appointments can significantly impact operations. Fortunately, automated call campaigns offer a powerful solution. With platforms like SIP Caller, healthcare organizations can proactively communicate with patients, reduce no-show rates, and ensure continuity of care—all while minimizing administrative workload.