Repository navigation
feat: hold voice conversations through an app-provided transport - #205
Conversation
Add a public VoiceTransport interface that an app implements to carry voice conversation audio and data, so Brand Concierge has no real-time media dependency. A transport also reports audio interruptions, and the session mutes the microphone until they end. Add the internal voice session: it validates the credentials, checks the microphone permission, claims the shared transport while connected and releases it before disconnecting, drops callbacks it no longer owns, and turns the voice agent's data messages into transcript updates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a voice button to the composer when the app passes a VoiceTransport to ConciergeChat or sets it on ConciergeChatView. The view model fetches the voice credentials, starts a voice session over the transport, renders the live transcript, and holds off typed turns, dictation and data handoffs while the conversation runs. A transport cleared mid- conversation keeps the running conversation stoppable; a new transport applies to the next one. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…docs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
connect(url, token) becomes connect(connection: VoiceConnection), a class Brand Concierge creates, so connection details can be added later without breaking app transports. VoiceTransportState gains Reconnecting. The conversation stays open with the connecting indicator, the microphone is left as it was, and the session fails if the transport does not report Connected again within 30 seconds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…conds The transport is app code, so a connect that never reports back used to leave the conversation connecting forever. The connect and reconnect timeouts now share one timer; on expiry the session fails, which disconnects the transport and shows the usual error message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The agent's session_ended notice used to end the session normally whatever its reason. Only the agent's timeouts end it normally now; an error, a worker shutdown, or an unknown or missing reason fails it, so the chat shows the error message and tracks it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Chats have their own view models and usually share one transport, so a second chat could start voice while another chat's conversation was still running, take the transport, and hang up each other's call. A chat now claims voice before requesting credentials and releases it once its conversation ends; other chats' voice buttons are disabled meanwhile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…hile connecting Track the interruption apart from the session state, so a Connected that arrives during it mutes the microphone right away, and document that a transport reports Failed when the audio will not come back. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Android doesn't tell other apps about a ringing call without READ_PHONE_STATE, and answering opens the call screen, which moves the app to the background. Audio interruptions cover other apps taking the audio for a while. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Without -Xjvm-default, Kotlin puts an interface member's body in a DefaultImpls class, so a Java class implementing a public interface such as VoiceTransport must still implement every member, and adding one with a default breaks it. all-compatibility also generates Java default methods while keeping the DefaultImpls classes, so apps compiled against an earlier release still link. The @JvmDefaultWithCompatibility and @JvmDefaultWithoutCompatibility annotations only take effect with the flag set, and the deprecated @JvmDefault needs a deprecated mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ansport opts in Add VoiceTransport.continuesInBackground, false by default, documenting what the app must provide for it: a microphone foreground service started from connect, its manifest permissions and the Play Console declaration. The session reads it when it calls connect. Moving the app to the background now stops a conversation only when its transport has not opted in or the session has not connected it yet, because Android does not let an app start the microphone from the background. A phone call answered during an opted-in conversation mutes the microphone instead of ending it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A forgotten conversation, especially one running in the background, could otherwise hold the room indefinitely: the voice agent's inactivity timeout is reset by nearby voices or a TV, not only by the user. The limit starts when the conversation first reports Connected, is not restarted by a reconnect, applies with or without background conversations, and ends the conversation normally, disconnecting the transport, as when the user stops it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Describe continuesInBackground, the microphone foreground service and manifest entries the app provides, the notification and its End action, ending the conversation in onTaskRemoved, the Play Console declaration, and the 60-minute limit on every conversation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The list reserved space only for an assistant reply right after the latest user message, and scrolled to each user message once. In voice the user's bubble arrives alone, so the scroll to it stopped near the bottom, and the reply that followed grew below the screen. Keep a voice scroll anchor (the latest user bubble, or the agent's first bubble when it speaks first), reserve space below it while only agent bubbles follow it, and scroll to it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A voice session failure now carries a typed reason with a fixed message. Errors from the app's transport and the bootstrap call can include URLs, tokens or server responses, so their text only goes to the debug log and never to Edge or the warning and error logs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When the final transcript for a turn has no text, the open bubble is removed instead of being left empty, and the next bubble becomes the scroll anchor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A voice bubble has no interactionId and its text changes on every transcript update, so its content-based list key changed too. Compose then treated each update as a new item, resetting its remembered state and losing key-based scroll anchoring. Voice bubbles now get a localId when created, and the message list keys by interactionId, then localId, then the existing content fallback. Typed chat messages are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
If the transport threw while muting or unmuting, the session only logged it, though it had already recorded the interruption. The microphone could then stay live during an interruption, or stay muted while the chat shows Listening, and nothing retried. The session now fails with TransportFailed, which disconnects the transport. VoiceTransport now also says that a transport whose microphone change fails after setMicrophoneEnabled returns reports Failed, since that failure never reaches the session as an exception. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Recreating the activity for a configuration change (e.g. rotation) disposed ConciergeChat and stopped voice, even though ConciergeChatViewModel survives. Skip the stop when the activity is changing configurations; leaving the screen, finishing the activity and clearing the view model still end it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Parse ui_payload sources, prompt suggestions and multimodal elements with typed chat's response parsing, so a voice turn can render what the same response renders in typed chat. A malformed card or source is dropped on its own, and a suggestion list with a non-string entry is dropped, as in typed chat. Widgets are not parsed because the SDK has no widget support. Parse the worker's text_input_error, which rejects a text prompt sent during a voice session. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Track the current voice turn the way web's handleTurnDone does. The user's transcript decides the turn; a new user turn closes the open reply, and messages for any other or already finished turn are dropped. The latest ui_payload snapshot is held for the turn. When the turn ends, the reply bubble gets the authoritative text and the sources, followed by the cards, CTAs and suggestions, through the same code typed chat uses. An error or an empty reply replaces the bubble with the new voice.turn.failed copy, still renders the payload and keeps the conversation open. An interrupted turn counts as completed. Add the voice.turn.failed and voice.turn.messageSendFailed copy with web's defaults. ConciergeChat pushes the theme's copy into the view model, as it does for the rest of the theme. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add VoiceTransport.send(data, topic, callback), which the app implements with reliable delivery and completes once, from any thread. During a voice conversation, a tapped prompt suggestion (including a welcome one) goes to the worker as a text_prompt on the bc-text-input topic, like on web, and is tracked as a submitted query with the held XDM context. The user's bubble shows at once and the worker's echo of it is dropped. After the conversation ends, taps stream over SSE as before; the composer stays read-only during voice, as on web. Taps are dropped while connecting or reconnecting, and from the start of the user's speech until the reply starts. A rejected prompt (text_input_error) fails the turn with voice.turn.failed, and a send that fails or throws fails it with voice.turn.messageSendFailed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The voice bootstrap now carries the held XDM context, resolved for the same session as the bootstrap request. The service replays it on every voice turn, so a tapped prompt suggestion's Query Submitted event uses that snapshot rather than the repository's current context. Updates made during a voice conversation apply from the next conversation or typed message; the implementation guide says so. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The session reports when the current turn starts and stops waiting for its reply: from the user's final transcript, spoken or sent as text, until the reply's first text, the turn's end, a newer turn or the end of the session. The chat shows the wait the way a typed turn does, as an empty reply bubble with the theme's loading message, and the reply fills that bubble. An empty bubble left behind is removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ConciergeChat and ConciergeChatView no longer take a voice transport. The app registers one with Concierge.setVoiceTransport, from any thread, and every chat reads it, so a new value reaches chats that are already open as well as later ones. A running conversation keeps the transport it started with. After null, the voice control stays while a conversation runs, so the user can stop it, and disappears once it ends. Resetting identities keeps the registered transport. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@rymorale A question about the voice public API on both platforms. Instead of passing the voice transport to each chat ( |
The voice button shows while a transport is registered with Concierge.setVoiceTransport or a conversation is still running. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resetting identities ends a running voice conversation and keeps the transport registered with Concierge.setVoiceTransport. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| private fun handleUserTranscript(delta: TranscriptDeltaData) { | ||
| val text = delta.delta.trim() | ||
| val echoing = turn | ||
| if (delta.final && echoing?.echoText != null && text == echoing.echoText) { |
There was a problem hiding this comment.
The echo of a text prompt only matches when it's a final user transcript whose trimmed text equals echoText exactly. If the worker sends interim echo chunks or normalizes the text (casing, punctuation, whitespace), the echo goes through startsNewTurn. That fails the prompt with TURN_FAILED and adds a duplicate user bubble. Does the worker echo the turn_id we send (txt-…)? If so, matching on that would be more robust.
There was a problem hiding this comment.
I checked the worker. It echoes a text prompt as a single user transcript: final: true, sequence: 0, with the text stripped withstrip() (the SDK already sends it trimmed), and no interim chunks. It doesn't echo our txt-… id: the echo carries the worker's own new turn id, and our id comes back only in text_input_error. So we can't match on the id today, and the exact match holds for what the worker sends. iOS matches the same way. I'd leave it as is; if the worker starts normalizing the text or echoing our id, we can switch to the id.
A transport may come back from a reconnect with the microphone live, so reapply the interruption mute when the session returns to listening. Document that setMicrophoneEnabled can be called while reconnecting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sorry for missing this question earlier. I think app-wide registration is fine given the single-conversation constraint. we can revisit this in the future if multiple conversation support is added. |
rymorale
left a comment
There was a problem hiding this comment.
The “Still on #197’s previous shape” note looks out of date after the bootstrap merge. The current head sends voice: {"action": "start"} and resolves the auth token, rather than the old livekit-bootstrap discriminator.
Could you update the rollout note and confirm whether Stage now accepts this shape? The existing note says it does not, so it is hard to tell which environment the current revision can be tested against.
| val errorNetwork: String? = null, | ||
|
|
||
| // Voice | ||
| val voiceTurnFailed: String? = null, |
There was a problem hiding this comment.
nit (non-blocking): Adding these parameters changes the JVM constructor and copy signatures of this public data class. I checked this on an emulator with a library compiled against the previous SDK. Calling ConciergeTextStrings(...) (named or positional) or .copy(...) from that library throws NoSuchMethodError on this branch. Property reads, destructuring and ConciergeThemeLoader.load(...) all still work, and anything rebuilt against this version is fine.
Since the documented path is theme JSON, and v3.8.0 already added inputAiChatIconTooltip to this class the same way, I don't think this needs to block. It might be worth a line in the release notes, or a decision on whether we want a binary-compatibility policy for the public theme models going forward.
There was a problem hiding this comment.
Thanks for checking this on an emulator. Agreed it's not blocking: theme JSON is the documented path, and v3.8.0 added inputAiChatIconTooltip the same way. I'll add a line to the 3.11.0 release notes saying the constructor and copy of ConciergeTextStrings changed, so code compiled against an earlier version must be rebuilt. A binary-compatibility policy for the public theme models is a good question for the SDK team; I'd keep it separate from this PR.
Replaces #198. Brand Concierge no longer looks up an
IVoicePluginthrough Mobile Core (adobe/aepsdk-core-android#844). It now owns the voice session logic, and the app supplies the real-time transport itself, registering it withConcierge.setVoiceTransport(section 7). This is the Android counterpart of adobe/aepsdk-concierge-ios#189.Description
Brand Concierge can hold a voice conversation over a transport the app provides. BC owns the conversation: credentials, microphone permission, session lifecycle, audio interruptions, data-channel parsing, transcript and UI. The app owns only the audio connection, through a small public
VoiceTransportinterface. BC takes no LiveKit, voice-extension or Core plugin dependency, and apps that don't use voice ship no WebRTC code.mavenCoreVersionstays at the released3.5.0.1. Transport interface and voice session logic
VoiceTransport.kt, root package):VoiceTransport:listener,continuesInBackground,connect(connection),setMicrophoneEnabled(enabled),disconnect(),send(data, topic, callback)VoiceSendCallback:onComplete(error), howsendreports its outcome (section 4).VoiceConnection: whatconnect(connection)receives,urlandtoken. Only BC creates it, so new fields can be added later without breaking existing transports.VoiceTransportListener:onStateChanged(transport, state),onDataReceived(transport, data, topic),onAudioInterruptionBegan(transport),onAudioInterruptionEnded(transport)VoiceTransportState:Connected,Reconnecting,Disconnected,Failed(error)voice/), from the voice-extension prototype:VoiceSessionController,VoiceSession,DataChannelMessageandDataChannelMessageParser.disconnect(). Callbacks from another sender, or after release, are dropped.send, which reports to its callback; see section 4.Connected, and changes it only throughsetMicrophoneEnabled, to mute during audio interruptions.setMicrophoneEnableduntil they end. Unlike iOS, Android has no app-wide interruption notification: audio focus changes go only to the focus holder (the transport's audio stack), and watching calls would needREAD_PHONE_STATE, which an SDK shouldn't require. Interruptions are tracked apart from the session state, so one that begins while connecting mutes the microphone as soon asConnectedarrives. When the audio will not come back (for example,AUDIOFOCUS_LOSS), the transport reportsFailedinstead, because the chat has no unmute control. A phone call is not handled as an interruption: Android doesn't tell other apps about a ringing call withoutREAD_PHONE_STATE, so the conversation continues while it rings, and answering opens the call screen, which moves the app to the background. Without the background opt-in (section 3) that ends the conversation; with it, the conversation continues and the microphone stays muted until the call ends (both checked on a Galaxy S25).Connectingstate, because BC tracks connecting itself.Reconnectingwhile it recovers a dropped connection (a network change, for example) andConnectedonce it is back. BC shows the connecting spinner and keeps the microphone as it was. If the transport is not back within 30 seconds, the session fails and BC callsdisconnect().ConnectednorFailedarrives within 20 seconds ofconnect(connection), the session fails with the usual voice error and BC callsdisconnect().2. Voice in the chat
Concierge.setVoiceTransport(transport)(section 7).ConciergeChatandConciergeChatViewdon't take it.VoiceSessionButtonin the input row, shown only while a transport is registered (or a session is still running).VoiceSessionControllerchecks it again, as a safety net for callers that don't go through the view model.wssorhttps, because the token travels on that connection. Any other scheme fails the session before the transport is touched.ErrorOccurred.error,worker_shutdown, or an unknown or missing reason fails it with the usual voice error andErrorOccurred.CHAT_IN_PROGRESS). Prompt suggestion taps go to the voice agent instead (section 4).onClearedend the session and cancel a still-open bootstrap.VoiceSessionController(through an injectable session factory for tests) instead of a plugin session.LiveKitTransportfor the test app is in feat: add a LiveKit voice transport to the test app #206.3. Background conversations
VoiceTransport.continuesInBackground(defaultfalse, so existing transports are unaffected) lets a transport opt in to keeping the conversation running when the app goes to the background: screen locked, or another app in front. BC reads it once per conversation, when it callsconnect(connection).connect, its manifest entries, and the Play Console declaration. The test app's service is in feat: add a LiveKit voice transport to the test app #206.Connected, in the foreground or the background, so a forgotten conversation can't hold a room indefinitely. Reconnects don't restart the count. The cap is fixed.-Xjvm-default=all-compatibility, so a Java class implementingVoiceTransportgetscontinuesInBackground's default instead of having to implement it, while apps compiled against an earlier release still link.4. Voice turns: UI payloads, turn states and suggestion taps (second review)
Same as adobe/aepsdk-concierge-ios#189 section 4 unless noted.
ui_payload(sources,promptSuggestions,multimodalElements) with typed chat'sConversationResponseParser, into the same models typed chat uses. A suggestion that isn't a string drops the list; a malformed card or source drops only itself. The agent can send several per turn, each a full snapshot, so the latest one is kept. When the turn ends, the reply bubble gets itssources, and cards, carousels, CTAs and prompt suggestions render through typed chat's code. As in typed chat on Android, a reply with CTAs and no product cards drops the suggestions.widgetsaren't rendered, as in typed chat.handleTurnDone:turnId). A new user turn closes the open reply bubble, and messages for another or an already-finished turn are dropped.erroror an emptyfullText: the reply bubble shows the newvoice.turn.failedcopy, the payload still renders and the session continues.interruptedcounts as completed. A lateerrorafter a completed turn (failed playback) is dropped.onTurnFinished.{"type":"text_prompt","turn_id","text"}on topicbc-text-input, through the newVoiceTransport.send(data, topic, callback). The SDK builds the message, so transports only move bytes. The user's bubble shows at once and the agent's echo of it is not shown again. Taps are ignored while connecting or reconnecting, and from the start of the user's speech until the reply starts. Atext_input_errorfor the tap, or the user speaking before the agent takes it, fails it withvoice.turn.failed; a failedsendshowsvoice.turn.messageSendFailed. The tap is tracked asquerySubmitted, like a typed send. The composer stays read-only during voice, as on web. After voice ends, taps stream as before.sendreports to a callback (Android-specific):send(data: ByteArray, topic: String, callback: VoiceSendCallback)returns at once and callscallback.onComplete(error)exactly once, from any thread:nullonce the message is accepted, or the error. Asendthat throws counts as a failure. The rest ofVoiceTransporthas no suspend functions, sosenddoesn't tie transports to coroutines (iOS usesasync throws). The transport's error text is logged at debug level only.sendmust deliver reliably. It has no default implementation, so existing transports must add it. The test app'sLiveKitTransportimplements it in feat: add a LiveKit voice transport to the test app #206.voice.turn.failed("Sorry, I couldn't process that. Please try again.") andvoice.turn.messageSendFailed("Sorry, your message couldn't be sent. Please try again."), same keys and defaults as web, in the style guide and the test app's theme.ConciergeChatpasses them from the theme to the view model.send(reliable delivery, the callback), each turn's cards and suggestions, and suggestion taps during voice.5. Held XDM context during voice
Same as adobe/aepsdk-concierge-ios#189 section 5.
updateXDMContext) for the bootstrap's session, and the service uses it for every turn of the conversation. So the context is captured once, when the conversation starts, as on web. Updates made during the conversation apply from the next voice conversation or typed message.querySubmittedwith that captured context, matching what the service sends.6. Thinking indicator during voice
Same as adobe/aepsdk-concierge-ios#189 section 6.
loading.message("Generating response from our knowledge base"), as typed chat does. It appears when the user's final words (or a suggestion tap) show, and the reply's first text replaces it in the same bubble.VoiceSessionControllerreports the wait to the view model through a new internal listener callback,onAwaitingReplyChanged. It turns off after the reply's first text, at the turn's end (completed, error,text_input_error, a failed send), when a newer turn replaces the turn, and when voice ends. An indicator still empty at that point is removed, so none is left after a stop or a failure.turn_completed(state=error).7. One transport for the app, registered with
Concierge.setVoiceTransportSame as adobe/aepsdk-concierge-ios#189 section 7.
voiceTransportparameter of bothConciergeChatcomposables and theConciergeChatView.voiceTransportproperty. Neither was released, so nothing is deprecated.@JvmStatic Concierge.setVoiceTransport(transport: VoiceTransport?)can be called from any thread, likesetAuthTokenProvider. Every chat's view model reads the registered transport, so a new value reaches chats that are already open as well as later ones.null, the voice button stays while a conversation runs, so the user can stop it, and disappears once it ends. Resetting identities keeps the registered transport.API note
ConciergeChatandConciergeChatVieware unchanged. The only addition to an existing class isConcierge.setVoiceTransport.How Has This Been Tested?
VoiceSessionControllerTest(64): lifecycle, the background opt-in snapshot and the 60-minute cap (started on the firstConnected, not restarted by reconnects, cancelled on end), connect and reconnect timeouts, credential validation (includingws/httprejected), permission, transport sharing and foreign callbacks, interruptions (including while connecting), agent-ended sessions by reason, transcript assembly, turn tracking (new user turn, other and finished turn ids, error / empty / interrupted states, late error), suggestion sends (payload and topic, echo, gating,text_input_error, speech before the echo, send failure reported or thrown) and the thinking indicator's on and off signals, all through aFakeVoiceTransport.DataChannelMessageParserTest(25): including the fullui_payloadandtext_input_error.ConciergeChatViewModelVoiceSessionTest(62, rewritten from Integrate the optional voice plugin into the chat UI #198 for the transport): availability, backgrounding (kept with the opt-in once connecting, ended without it or before connect), start/connect/stop, transcripts and the scroll anchor, errors, exclusivity, one conversation app-wide, each stop trigger, the permission flow, transport changes, each turn's end (reply rewritten with sources, cards and suggestions; CTAs dropping the suggestions; failure copy), suggestion taps to the session during voice and streamed after it, the held XDM context and session sent with the bootstrap, a suggestion tap tracked with that context after it changes, and the thinking indicator (shown, replaced by the reply, removed on stop and on a newer turn).ConciergeChatVoiceLifecycleTest(4):Concierge.setVoiceTransportreaching a chat that is already open, and voice across activity recreation, the chat leaving the screen and the activity finishing.TrailingControlTest(6).MessageListScrollTest(4): which message reserves space and where the list scrolls, with and without voice.make format,make lintandmake unit-testpass (fulltestPhoneDebugUnitTest: 1969 tests, no failures).LiveKitTransportfrom feat: add a LiveKit voice transport to the test app #206: open the chat, start voice, connect and subscribe to the agent's audio track, hold 10 s, stop cleanly.LiveKitTransport.send(Stage config in a local build only): a product card arriving while the screen is locked renders with the reply, its sources and suggestions after unlocking. A suggestion tapped during voice shows the user's bubble at once (not twice with the echo) and reaches the agent, which answers by voice. Taps while connecting, while the user speaks or before the reply starts are ignored, and after voice ends a tap streams as typed chat.Types of changes
Checklist: