Skip to content

Commit

Permalink
feat: allow Agents to pass through initial attributes (#852)
Browse files Browse the repository at this point in the history
* feat: allow Agents to pass through initial attributes

* changeset
  • Loading branch information
davidzhao authored Oct 15, 2024
1 parent b754791 commit 689a0fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-fans-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"github.com/livekit/protocol": minor
---

allow Agents to pass through initial attributes
9 changes: 7 additions & 2 deletions agent/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
}

0 comments on commit 689a0fe

Please sign in to comment.