Skip to content

feat: add voice session bootstrap request - #174

Merged
nozokada merged 7 commits into
adobe:feature/voicefrom
nozokada:feat/voice-bootstrap
Nov 24, 2026
Merged

nozokada merged 7 commits into
adobe:feature/voicefrom
nozokada:feat/voice-bootstrap

Conversation

@nozokada

@nozokada nozokada commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Bottom of a stack: #174 → #189 → #191, merged in that order.
Base: feature/voice, cut from main at 5.10.3. Voice lands there, not in dev, so releases during the restricted change period don't pick it up. The pilot will use a prerelease tag on that branch, and the branch goes to dev once a public release is approved.

Important

Waiting on a service change. The bootstrap now uses the request shape from a Concierge Conversation Service change that isn't merged yet: query.conversation.voice = {"action": "start"}. Stage still accepts only the old shape, so don't merge this into feature/voice until that change is on Stage. Until then, #189 and #191 stay on the previous head of this branch, and they still show the old shape.

Description

Adds the client side of the voice session bootstrap handshake. It has no voice transport and no UI; those come in follow-up PRs.

  • An internal VoicePayload (type, livekitUrl, token) that mirrors the service's wire format, and an internal, optional ConversationResponse.voice field. The public API is unchanged.
  • ConciergeChatService.bootstrapVoiceSession(token:xdmFields:sessionID:onBootstrap:onComplete:) posts a conversation event to the regional conversations route, /brand-concierge/{region}/conversations, the same route chat uses. conversation.voice = {"action": "start"} replaces message and marks the request as a voice bootstrap. The service rejects voice together with message. It reports the first livekit_session credentials on the stream exactly once, as a transport-neutral VoiceSessionBootstrap(url:token:).
  • The auth token goes in conversation.data, as in a chat turn ({"type": "auth", "payload": {"token": …}}), and is left out when it's nil or blank. The caller resolves it, as for streamChat. token has no default, so the caller has to pass it explicitly. The service accepts the token but doesn't pass it to the agent during voice yet.
  • When the service rejects voice during an agent hand-off, it sends an error chunk (VOICE_NOT_SUPPORTED_DURING_HANDOFF). The stream then closes without credentials, so the caller treats it like any other failed bootstrap. A region where voice isn't enabled answers with HTTP 400, which is reported as a network error.
  • Chat and bootstrap payloads now share one event envelope builder, so the bootstrap carries the same identity map and consent state. Chat payloads are unchanged.
  • The bootstrap also carries the held XDM context (updateXDMContext) passed in xdmFields, merged into xdm as in a chat turn. The SDK's identityMap wins on a collision. The SDK doesn't set xdm.eventType, so an eventType in the held context passes through as in a chat turn. The service drops it from the xdm it stores. The service keeps this xdm for the voice session and sends it with every voice turn. The request uses the passed sessionID, so the caller resolves the context for the same session.

bootstrapVoiceSession shares the service's streaming state with streamChat, so callers must not run the two at the same time.

How has this been tested?

New unit tests cover:

  • The bootstrap payload: the voice start marker, no xdm.eventType, no message, surfaces, identity map, and consent. The auth token is attached as the data part next to the marker, and left out when blank. Chat payloads don't carry voice. The held XDM context is merged in, it can't replace the SDK's identityMap, and its eventType passes through.
  • The request path through a stubbed URLProtocol: the request goes to /brand-concierge/va7/conversations with the given session ID as an event stream, and the token is in the body, not a header. Also: credentials delivered, fires once, the hand-off error chunk completes without credentials, ignores non-session payloads, network error, and an unbuildable URL.
  • Decoding of VoicePayload.

The full UnitTests suite passes locally, except nine snapshot mismatches (PrivacyNoticeSnapshotTests ×6, ProductCardCarouselSnapshotTests ×3). They fail the same way on the base branch, come from the local Xcode and simulator (iOS 26.4), and this PR doesn't touch any views.

Against the unmerged service change, run locally: bodies built by createVoiceBootstrapPayload, with and without a token, were posted to its conversations route. The service answers with livekit_session credentials, keeps the held context in the session's xdm without eventType, and doesn't store the token. It rejects the same body with message added and with data: {"type": "livekit-bootstrap"}.

Not tested on device with this shape, because Stage doesn't accept it yet. The earlier device test (iPhone 17 Pro, demo app from #191, Stage, region va7) used the old shape.

Types of changes

  • New feature (non-breaking change which adds functionality)

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.75281% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...cierge/Sources/Services/ConciergeChatService.swift 97.75% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Adds the client side of the voice bootstrap handshake, without any voice
transport:

- VoicePayload and the optional ConversationResponse.voice field.
- ConciergeChatService.bootstrapVoiceSession, which posts a
  livekit-bootstrap conversation event to /brand-concierge-voice and
  reports the first livekit_session credentials on the stream.
- The voice path has no region segment, matching the Web SDK.
- Chat and bootstrap requests share one event envelope builder, so the
  bootstrap forwards the same identity map and consent state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- VoicePayload and ConversationResponse.voice are internal. VoicePayload
  mirrors the service's wire format, like the other network models.
- Callers receive a transport-neutral VoiceSessionBootstrap(url:token:)
  instead of LiveKitSessionBootstrap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada
nozokada force-pushed the feat/voice-bootstrap branch from 37e6fa4 to 2c7d954 Compare October 19, 2026 22:17
The bootstrap tests waited at most 3 seconds for the stubbed request to
complete. A stalled shared runner exceeded that, so the network error
test failed although the error was delivered. The wait returns as soon
as its condition holds, so a 10 second default only matters on failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	AEPBrandConcierge/Tests/UnitTests/ConciergeChatServiceTests.swift
@nozokada
nozokada changed the base branch from main to dev November 9, 2026 23:07
@nozokada
nozokada marked this pull request as ready for review November 9, 2026 23:15
@nozokada
nozokada changed the base branch from dev to feature/voice November 10, 2026 02:29
Voice used /brand-concierge-voice/conversations without the region, so EU
customers' bootstraps did not reach their region. The service now serves the
bootstrap from the regular /brand-concierge/{region}/conversations route when
the request carries xdm.eventType "conversation.voice" together with
conversation.data.type "livekit-bootstrap".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@cdhoffmann cdhoffmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align the voice bootstrap's auth and held XDM context with chat turns before merging; customers may require both for voice.

/// slot holds the bootstrap discriminator, and the service identifies the user through the identity map.
/// - Returns: JSON data for the request body.
/// - Note: Internal visibility for testing.
func createVoiceBootstrapPayload() throws -> Data {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the app's auth token and held XDM context when starting voice. Chat turns resolve setAuthTokenProvider and send its token in conversation.data, but this bootstrap uses that slot for livekit-bootstrap and sends neither the token nor updateXDMContext(_:) fields. Some customers require both for voice. Can we agree on a service contract that preserves the auth token's existing location, then update iOS and Android together? The service currently requires both bootstrap markers, so removing livekit-bootstrap needs a coordinated change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cdhoffmann. We discussed this with the BC team and agreed on a direction:

  • The bootstrap marker moves out of data into its own object, query.conversation.voice. That frees data for {type: "auth", payload: {token}}, the same place chat turns send it. iOS and Android will both move to the new shape.
  • The service will accept the new shape alongside the current data: {type: "livekit-bootstrap"}, so mobile doesn't have to wait for the web client. Moving web over is a separate effort.
  • The bootstrap will also include the held updateXDMContext snapshot, merged the same way as on chat turns.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Ping me when the change is in and i can approve.

nozokada and others added 2 commits November 19, 2026 17:45
The service keeps the bootstrap's xdm for the whole voice session and
replays it on every voice turn. bootstrapVoiceSession now takes the held
context snapshot and the session ID it was resolved for, merges the
snapshot into xdm like a chat turn (identityMap and eventType stay
SDK-owned), and sends the same session ID in the URL.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…th token

The voice bootstrap now marks the request with
query.conversation.voice = {"action": "start"} instead of
data = {"type": "livekit-bootstrap"} plus xdm.eventType = "conversation.voice".
The data slot now carries the auth token, as in a chat turn, and the SDK
no longer sets xdm.eventType.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nozokada

Copy link
Copy Markdown
Member Author

@cdhoffmann The change is in: the bootstrap now sends voice: {"action": "start"}, with the auth token in data where chat sends it, and the held XDM context. It depends on a service change that isn't merged yet, so I won't merge this into feature/voice until that change is on Stage. The description has the details.

@nozokada
nozokada merged commit 246ad54 into adobe:feature/voice Nov 24, 2026
28 of 30 checks passed
@nozokada
nozokada deleted the feat/voice-bootstrap branch November 24, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants