Display phone number in WebRTC call
This commit is contained in:
@@ -45,11 +45,13 @@ async def handle_call(request: Request):
|
|||||||
if not call_sid:
|
if not call_sid:
|
||||||
raise HTTPException(status_code=400, detail="Missing CallSid in request")
|
raise HTTPException(status_code=400, detail="Missing CallSid in request")
|
||||||
|
|
||||||
print(f"Processing call with ID: {call_sid}")
|
# Extract the caller's phone number
|
||||||
|
caller_phone = str(data.get("From", "unknown-caller"))
|
||||||
|
print(f"Processing call with ID: {call_sid} from {caller_phone}")
|
||||||
|
|
||||||
# Create a Daily room with SIP capabilities
|
# Create a Daily room with SIP capabilities
|
||||||
try:
|
try:
|
||||||
room_details = await create_sip_room(request.app.session)
|
room_details = await create_sip_room(request.app.session, caller_phone)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error creating Daily room: {e}")
|
print(f"Error creating Daily room: {e}")
|
||||||
raise HTTPException(status_code=500, detail=f"Failed to create Daily room: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"Failed to create Daily room: {str(e)}")
|
||||||
|
|||||||
@@ -29,13 +29,23 @@ async def get_daily_helper(session: Optional[aiohttp.ClientSession] = None) -> D
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def create_sip_room(session: Optional[aiohttp.ClientSession] = None) -> Dict[str, str]:
|
async def create_sip_room(
|
||||||
"""Create a Daily room with SIP capabilities for phone calls."""
|
session: Optional[aiohttp.ClientSession] = None, caller_phone: str = "unknown-caller"
|
||||||
|
) -> Dict[str, str]:
|
||||||
|
"""Create a Daily room with SIP capabilities for phone calls.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
session: Optional aiohttp session to use for API calls
|
||||||
|
caller_phone: The phone number of the caller to use in display name
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dictionary with room URL, token, and SIP endpoint
|
||||||
|
"""
|
||||||
daily_helper = await get_daily_helper(session)
|
daily_helper = await get_daily_helper(session)
|
||||||
|
|
||||||
# Configure SIP parameters
|
# Configure SIP parameters
|
||||||
sip_params = DailyRoomSipParams(
|
sip_params = DailyRoomSipParams(
|
||||||
display_name="phone-user",
|
display_name=caller_phone,
|
||||||
video=False,
|
video=False,
|
||||||
sip_mode="dial-in",
|
sip_mode="dial-in",
|
||||||
num_endpoints=1,
|
num_endpoints=1,
|
||||||
|
|||||||
Reference in New Issue
Block a user