feat: allow Agents to pass through initial attributes (#852)

* feat: allow Agents to pass through initial attributes

* changeset
This commit is contained in:
David Zhao
2024-10-14 22:15:43 -07:00
committed by GitHub
parent b75479104c
commit 689a0fe629
2 changed files with 12 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"github.com/livekit/protocol": minor
---
allow Agents to pass through initial attributes

View File

@@ -7,7 +7,11 @@ import (
"github.com/livekit/protocol/livekit"
)
func BuildAgentToken(apiKey, secret, roomName, participantIdentity, participantName, participantMetadata string, permissions *livekit.ParticipantPermission) (string, error) {
func BuildAgentToken(
apiKey, secret, roomName, participantIdentity, participantName, participantMetadata string,
participantAttributes map[string]string,
permissions *livekit.ParticipantPermission,
) (string, error) {
grant := &auth.VideoGrant{
RoomJoin: true,
Agent: true,
@@ -26,7 +30,8 @@ func BuildAgentToken(apiKey, secret, roomName, participantIdentity, participantN
SetName(participantName).
SetKind(livekit.ParticipantInfo_AGENT).
SetValidFor(1 * time.Hour).
SetMetadata(participantMetadata)
SetMetadata(participantMetadata).
SetAttributes(participantAttributes)
return at.ToJWT()
}