Quick Start¶
REST API Client¶
List your phone numbers, carriers, and applications:
import asyncio
from jambonz import AsyncJambonzClient
async def main():
async with AsyncJambonzClient() as client:
# Phone numbers
numbers = await client.phone_numbers.list()
for n in numbers:
print(f"{n.number} → app: {n.application_sid}")
# Carriers
carriers = await client.carriers.list()
for c in carriers:
print(f"{c.name} ({c.voip_carrier_sid})")
# Gateways for a carrier
gateways = await client.gateways.list(
voip_carrier_sid=carriers[0].voip_carrier_sid
)
for gw in gateways:
print(f" {gw.ipv4}:{gw.port}")
# Recent calls
calls = await client.calls.list(days=7, page=1, count=10)
for call in calls:
print(f"{call.from_} → {call.to} ({call.duration}s)")
asyncio.run(main())
Note
You can also use the synchronous JambonzClient if you don't need async.
Webhook Response¶
Build call flow instructions to respond to jambonz webhooks:
from fastapi import FastAPI
from jambonz import JambonzResponse, Say, Gather, Hangup, Input, Synthesizer
app = FastAPI()
@app.post("/incoming-call")
def handle_call() -> JambonzResponse:
return [
Say(
text="Welcome! Please say something after the beep.",
synthesizer=Synthesizer(vendor="google", language="en-US"),
),
Gather(
input=[Input.SPEECH],
action_hook="/handle-speech",
timeout=15,
),
]
@app.post("/handle-speech")
def handle_speech(request: Request) -> JambonzResponse:
# Process speech result and respond
return [
Say(text="Thanks for calling! Goodbye."),
Hangup(),
]
Using with LLM¶
Connect to ElevenLabs or OpenAI for conversational AI: