Messages
Messages is a task pack that takes a message for someone, reads it back, and passes
it on once the caller agrees. Add it to an Operations or a
ServiceAgent with add_to().
When the caller gives no number, the pack offers the number they’re calling from, read back for them to agree to. A second message for the same recipient while the first waits for a yes takes its place.
Parameters
All parameters are keyword-only.
save
save(call, message) passes the Message on once the caller says yes. Raise
WriteFailed when it can’t. May be async.
recipients
Who a message can be for, by name, each with a few words on who they are. None when
there’s only one place messages go.
ask_for
What’s asked for when the caller hasn’t said it: "name", "number", or both. Any
other value raises ValueError. The message itself is always asked for, and who it’s
for whenever there are recipients.
caller_id
True to offer the number the caller is calling from when they haven’t given one.
tool
The tool’s name.
wording
Replacements keyed like MESSAGES_WORDING. See wording.
before_identity
False to take messages only from identified callers.
Methods
add_to(target) registers the pack’s operation on an Operations or a
ServiceAgent, and returns target.
Message
A frozen dataclass that save receives.
Message.text
The message, in the caller’s words.
Message.name
Who it’s from, as they said it, or "".
Message.number
A number to reach them on, as they gave it or agreed to, or "".
Message.to
Who it’s for (one of recipients), or "".
Message.call_id
The platform’s id for the call.
Message.account_id
The account identified, or "".
Example
FrontDeskAgent and PersonalAssistantAgent take
a Messages pack as messages= and offer it when a call can’t be put through.