Repository navigation
feat: add voice session bootstrap request - #174
Conversation
Codecov Report❌ Patch coverage is
📢 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>
ee9d052 to
fccd8b7
Compare
- 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>
37e6fa4 to
2c7d954
Compare
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
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
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 freesdatafor{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
updateXDMContextsnapshot, merged the same way as on chat turns.
There was a problem hiding this comment.
Awesome. Ping me when the change is in and i can approve.
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>
|
@cdhoffmann The change is in: the bootstrap now sends |
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 intofeature/voiceuntil 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.
VoicePayload(type,livekitUrl,token) that mirrors the service's wire format, and an internal, optionalConversationResponse.voicefield. 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"}replacesmessageand marks the request as a voice bootstrap. The service rejectsvoicetogether withmessage. It reports the firstlivekit_sessioncredentials on the stream exactly once, as a transport-neutralVoiceSessionBootstrap(url:token:).conversation.data, as in a chat turn ({"type": "auth", "payload": {"token": …}}), and is left out when it'snilor blank. The caller resolves it, as forstreamChat.tokenhas 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.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.updateXDMContext) passed inxdmFields, merged intoxdmas in a chat turn. The SDK'sidentityMapwins on a collision. The SDK doesn't setxdm.eventType, so aneventTypein the held context passes through as in a chat turn. The service drops it from thexdmit stores. The service keeps thisxdmfor the voice session and sends it with every voice turn. The request uses the passedsessionID, so the caller resolves the context for the same session.bootstrapVoiceSessionshares the service's streaming state withstreamChat, so callers must not run the two at the same time.How has this been tested?
New unit tests cover:
voicestart marker, noxdm.eventType, no message, surfaces, identity map, and consent. The auth token is attached as thedatapart next to the marker, and left out when blank. Chat payloads don't carryvoice. The held XDM context is merged in, it can't replace the SDK'sidentityMap, and itseventTypepasses through.URLProtocol: the request goes to/brand-concierge/va7/conversationswith 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.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 withlivekit_sessioncredentials, keeps the held context in the session'sxdmwithouteventType, and doesn't store the token. It rejects the same body withmessageadded and withdata: {"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