Skip to content

Commit 343e976

Browse files
authored
Merge pull request #2954 from pipecat-ai/mb/runner-meeting-token-properties
Add support for token properties in Daily util and development runner
2 parents 3585f72 + 653e843 commit 343e976

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
164164
### Changed
165165

166166
- The development runner's `/start` endpoint now supports passing
167-
`dailyRoomProperties` in the request body when `createDailyRoom` is true.
168-
Properties are validated against the `DailyRoomProperties` type and passed to
169-
Daily's room creation API.
167+
`dailyRoomProperties` and `dailyMeetingTokenProperties` in the request body
168+
when `createDailyRoom` is true. Properties are validated against the
169+
`DailyRoomProperties` and `DailyMeetingTokenProperties` types respectively
170+
and passed to Daily's room and token creation APIs.
170171

171172
- `UserImageRawFrame` new fields `append_to_context` and `text`. The
172173
`append_to_context` field indicates if this image and text should be added to

src/pipecat/runner/daily.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
from pydantic import BaseModel
4545

4646
from pipecat.transports.daily.utils import (
47+
DailyMeetingTokenParams,
48+
DailyMeetingTokenProperties,
4749
DailyRESTHelper,
4850
DailyRoomParams,
4951
DailyRoomProperties,
@@ -84,6 +86,7 @@ async def configure(
8486
sip_num_endpoints: Optional[int] = 1,
8587
sip_codecs: Optional[Dict[str, List[str]]] = None,
8688
room_properties: Optional[DailyRoomProperties] = None,
89+
token_properties: Optional["DailyMeetingTokenProperties"] = None,
8790
) -> DailyRoomConfig:
8891
"""Configure Daily room URL and token with optional SIP capabilities.
8992
@@ -106,6 +109,9 @@ async def configure(
106109
individual parameters. When provided, this overrides room_exp_duration and
107110
SIP-related parameters. If not provided, properties are built from the
108111
individual parameters as before.
112+
token_properties: Optional DailyMeetingTokenProperties to customize the meeting
113+
token. When provided, these properties are passed to the token creation API.
114+
Note that room_name, exp, and is_owner will be set automatically.
109115
110116
Returns:
111117
DailyRoomConfig: Object with room_url, token, and optional sip_endpoint.
@@ -179,7 +185,10 @@ async def configure(
179185

180186
# Create token and return standard format
181187
expiry_time: float = token_exp_duration * 60 * 60
182-
token = await daily_rest_helper.get_token(room_url, expiry_time)
188+
token_params = None
189+
if token_properties:
190+
token_params = DailyMeetingTokenParams(properties=token_properties)
191+
token = await daily_rest_helper.get_token(room_url, expiry_time, params=token_params)
183192
return DailyRoomConfig(room_url=room_url, token=token)
184193

185194
# Create a new room
@@ -221,7 +230,12 @@ async def configure(
221230

222231
# Create meeting token
223232
token_expiry_seconds = token_exp_duration * 60 * 60
224-
token = await daily_rest_helper.get_token(room_url, token_expiry_seconds)
233+
token_params = None
234+
if token_properties:
235+
token_params = DailyMeetingTokenParams(properties=token_properties)
236+
token = await daily_rest_helper.get_token(
237+
room_url, token_expiry_seconds, params=token_params
238+
)
225239

226240
if sip_enabled:
227241
# Return SIP configuration object

src/pipecat/runner/run.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ async def start_agent(request: Request):
555555
{
556556
"createDailyRoom": true,
557557
"dailyRoomProperties": { "start_video_off": true },
558+
"dailyMeetingTokenProperties": { "is_owner": true, "user_name": "Bot" },
558559
"body": { "custom_data": "value" }
559560
}
560561
"""
@@ -571,6 +572,7 @@ async def start_agent(request: Request):
571572
create_daily_room = request_data.get("createDailyRoom", False)
572573
body = request_data.get("body", {})
573574
daily_room_properties_dict = request_data.get("dailyRoomProperties", None)
575+
daily_token_properties_dict = request_data.get("dailyMeetingTokenProperties", None)
574576

575577
bot_module = _get_bot_module()
576578

@@ -585,7 +587,10 @@ async def start_agent(request: Request):
585587
import aiohttp
586588

587589
from pipecat.runner.daily import configure
588-
from pipecat.transports.daily.utils import DailyRoomProperties
590+
from pipecat.transports.daily.utils import (
591+
DailyMeetingTokenProperties,
592+
DailyRoomProperties,
593+
)
589594

590595
async with aiohttp.ClientSession() as session:
591596
# Parse dailyRoomProperties if provided
@@ -598,7 +603,21 @@ async def start_agent(request: Request):
598603
logger.error(f"Failed to parse dailyRoomProperties: {e}")
599604
# Continue without custom properties
600605

601-
room_url, token = await configure(session, room_properties=room_properties)
606+
# Parse dailyMeetingTokenProperties if provided
607+
token_properties = None
608+
if daily_token_properties_dict:
609+
try:
610+
token_properties = DailyMeetingTokenProperties(
611+
**daily_token_properties_dict
612+
)
613+
logger.debug(f"Using custom token properties: {token_properties}")
614+
except Exception as e:
615+
logger.error(f"Failed to parse dailyMeetingTokenProperties: {e}")
616+
# Continue without custom properties
617+
618+
room_url, token = await configure(
619+
session, room_properties=room_properties, token_properties=token_properties
620+
)
602621
runner_args = DailyRunnerArguments(room_url=room_url, token=token, body=body)
603622
result = {
604623
"dailyRoom": room_url,

0 commit comments

Comments
 (0)