Dialer
Dialer places an outbound call to an agent’s URL, or runs a SWML document, only once
every check passes. Otherwise it raises NotPlaced with the reason and makes no
request. Calling hours are read on the callee’s own clock. Pacing, retries, and
outcomes belong to your scheduler, which calls place().
Parameters
client
A RestClient.
from_number
Keyword-only, as are all the parameters below. The number calls come from.
url
The agent’s URL. The callee’s data is added to it as query parameters. Give exactly
one of url and swml, or ValueError is raised.
swml
A SWML document to run in place of an agent at a URL.
checks
What must pass before a call is placed, in order. The first objection stops the call.
timeout
How long to ring, in seconds. The platform’s default when None.
status_url
Where the platform posts the call’s progress.
status_events
Which progress events to post, such as ["answered", "ended"].
Methods
place
place(callee, now=None) dials callee once every check passes and returns the
result of client.calling.dial(). Raises NotPlaced with the first
objection otherwise, and makes no request.
why_not
why_not(callee, now=None) returns why a call to callee can’t be placed now, or
None when every check passes. Places no call.
For both methods, now is the time to check at, for tests. It must carry a time zone,
or ValueError is raised; it defaults to the current time.
Callee
Callee(number, zone, data={}), a frozen dataclass, is the person to be called.
Callee.number
Their number, in E.164 form.
Callee.zone
Their IANA time zone name, such as "America/Chicago". A name that isn’t a time zone
raises ValueError.
Callee.data
What the call is about, added to the agent’s URL as query parameters.
NotPlaced
NotPlaced(callee, reason) is raised by place() in place of dialing. It has
.callee and .reason.
Checks
A check has the type Check = Callable[[Callee, datetime], str | None]: it returns why
the call can’t be placed now, or None. now is an aware UTC time. Use the built-in
checks or any function of your own with the same type.
consented(lookup):lookup(callee)returnsTruewhen consent is on record,Falsewhen it was withdrawn, orNonewhen there’s none on record. OnlyTruelets the call through.calling_hours(start, end, *, days=None): the callee’s local time must be withinstartandend(datetime.timevalues, inclusive), and on one ofdayswhen given, with Monday as 0 through Sunday as 6.
Example
This places a real call, so it needs SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN,
and SIGNALWIRE_SPACE.
The call is placed to https://agents.example.com/reminders?appointment=a1.