Skip to main content

VoiFlow for Python

Run your voice agents from your own backend: create businesses, set up agents, start calls, read transcripts and get webhooks.

pip install voiflow

Python 3.9 or newer, no other packages needed. The client is synchronous and returns plain dicts.

Get your API key

The SDK signs in with an API key, not a username and password.

  1. Sign in to the Partner Portal at https://partners.voiflow.ai with your partner account.
  2. Open Developers, then API keys, then New key. Choose test or live, which businesses it covers and what it may do.
  3. Copy the key when it is shown. It is displayed once; if you lose it, rotate it in the same screen.
  4. Keep it on your server, for example in an environment variable called VOIFLOW_API_KEY, and pass it in as shown below. Never put it in browser code or a public repository.

Don't have a partner account yet? Request API access at https://voiflow.ai and VoiFlow will set you up.

Quickstart

import os
from voiflow import VoiFlowClient

client = VoiFlowClient(api_key=os.environ["VOIFLOW_API_KEY"])

for business in client.businesses.list():
    print(business["id"], business["name"])

call = client.calls.create(
    {"agent_id": "agent_id", "contact_id": "contact_id", "mission": "Confirm tomorrow's visit"},
    business_id="business_id",  # only needed if your key covers more than one business
)
print(call["call_id"], call["status"])  # "starting": the call is accepted, not yet connected

Keys

Create keys in the Partner Portal under Developers. A vf_test_ key works on test data and never places a real call or touches a live business. A vf_live_ key acts on real businesses and real customers. Both are secret: keep them on your server and give browsers a short-lived token from client.sessions.create instead.

A key is either tied to one business or can manage all of yours. With a management key, pass business_id on each call (or create the business first with businesses.create).

Lists

List methods return an iterator and fetch the next page for you.

for call in client.calls.list(days="7"):
    print(call["call_id"])

Choose the page size with limit (at most 100); the iterator still walks every page:

for call in client.calls.list(limit=25):
    print(call["call_id"])

Types

Responses and request bodies are typed dictionaries, so your editor and type checker know every field:

from voiflow.models import Agent, CallCreate

agent: Agent = client.agents.retrieve("agent_id")
body: CallCreate = {"agent_id": agent["id"], "contact_id": "contact_id"}

Errors and retries

Failures raise VoiFlowError with status, code, message, request_id and details. A network failure or an HTTP 202 means the result is not known yet (VoiFlowConnectionError, VoiFlowOperationPending): do not start the action again under a new key. Every method that changes something takes idempotency_key; if you leave it out, one is generated and reused on automatic retries, and it is on the error as err.idempotency_key so you can retry the same action safely.

Webhooks

Create an endpoint with client.webhook_endpoints.create({"url": ..., "event_types": [...]}). The secret is shown once. Events today: call.started, call.completed, agent.published. Check every delivery before you trust it, using the raw body bytes:

from voiflow import verify_webhook_signature, parse_webhook_event

verify_webhook_signature(raw_body, request.headers["VoiFlow-Signature"], secret)  # raises if wrong or older than 5 minutes
event = parse_webhook_event(raw_body)  # event["id"] stays the same on retries: use it to skip duplicates

Before you place calls

Phone calls and browser voice sessions work once VoiFlow has connected a phone line to the business, which VoiFlow does for you during onboarding. Until then calls.create and sessions.create raise a clear error saying so. Webhook endpoints must be public https addresses.

What is in the client

Group Methods
businesses list, create, retrieve, update, readiness, settings, update_settings
agents list, create, retrieve, update, delete, publish, voice_options
journeys list, create, retrieve, update, draft, draft_from_guide, create_version, retrieve_version, publish, impact
calls list, create, retrieve, end, steer, transcript, recording, stream
conversations list, create, retrieve, list_messages, send_message, takeover, resume_ai
contacts list, create, retrieve, update, set_dnc
enquiries list, retrieve
appointments, calendar appointments.list / create; calendar.availability / resources
knowledge, files knowledge.list / create / update / publish; files.list / upload / retrieve / download
projects, campaigns, runs projects.list / create; campaigns.list / create / retrieve / update / set_status / stats; runs.create / retrieve / stats
connections, integrations, channel_accounts, lines connections.list / create / retrieve / update / readiness; integrations.list; channel_accounts.list / create; lines.list / update
ai_work list, retrieve, cancel, requeue
webhook_endpoints, events webhook_endpoints.list / create / retrieve / update / delete / rotate_secret / list_deliveries; events.list / replay
sessions, usage, limits, operations sessions.create; usage.get; limits.get; operations.retrieve

Upload a document: client.files.upload(pdf_bytes, filename="policy.pdf", content_type="application/pdf").

Field names are the same as in the API reference (agent_id, contact_id).

MIT licence.

Metadata

Release files for voiflow 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for voiflow 0.3.1
File Size Uploaded
voiflow-0.3.1.tar.gz 19.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for voiflow 0.3.1
File Interpreter ABI Platform
voiflow-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.4 kB

Release files / voiflow-0.3.1.tar.gz

Download URL voiflow-0.3.1.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2a8c2339411a580f3a964e4d919b6e3b0394afed52bd71bbe6b9408cf146844a
BLAKE2b-256 checksum
How to use checksums
9091135968cb6e866d910372445489080781a1e55dbdffbb7f3e32528c6eb02b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / voiflow-0.3.1-py3-none-any.whl

Download URL voiflow-0.3.1-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5330747c3c8ce62188e77e8a848b359f32b03d62da63e7f6075ff1b260dad4a6
BLAKE2b-256 checksum
How to use checksums
c3f1ccded32133f013533b33876c772181b275ed8b3044bf773a171c0237e8ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page