Your Own Assistant UI

By default, a call shows a glow round the edges of the screen with a small end button. Some apps want the assistant to look like part of the app instead: an orb, a status line, the agent's words on screen, and its actions shown as they happen. Headless mode turns the SDK's call UI off and gives your app what it needs to draw its own.

Headless mode needs vable_flutter 0.0.8, the iOS SDK 0.0.9 or the Android SDK 0.0.1+10.

What you get

  • No native UI. Nothing is drawn during a call. Your app starts and ends it.
  • Events for the agent's state, its words as they arrive, what the user says, voice levels for an orb, and each action the agent takes on the screen.
  • Control over pacing (Flutter). Show what the agent is about to touch before it touches it, type character by character, pause or stop it, and let the user take over by touching the screen.
  • Things only the user can do (Flutter). Mark controls such as a payment button that the agent can see and point out, but not press.
  • Your app's words in the agent's voice. Have the agent say a question, then show your own quick replies.

Flutter

Turn the native UI off before the call starts, then listen to Vable.events:

await Vable.setCallStyle(VableCallStyle.none);

Vable.events.listen((event) {
  switch (event) {
    case VableAgentStateChanged(:final state):
      orb.state = state;
    case VableInputLevel(:final level):
      orb.level = level;
    case VableAssistantText(:final text):
      caption.text = text;
    case VableActionStarted(:final action):
      highlight(action.bounds);
    default:
  }
});

await Vable.startVoiceChat(context);

Events

EventWhen
VableCallStarted, VableCallEndedA call connects or ends
VableAgentStateChangedThe agent becomes idle, listening, thinking, speaking or acting. Vable.agentState has the current one
VableAssistantTextThe agent's reply as it arrives: delta, the whole text so far, and isStreaming. On a call it arrives a little ahead of the voice
VableUserTranscriptWhat the user has said so far, then the whole sentence with isFinal
VableUserInterruptedThe user talked over the agent, and it stopped
VableInputLevelThe user's mic level from 0 to 1, about 10 times a second, with the agent's as agentLevel
VableActionStarted, VableActionFinishedThe agent acting on the screen. The finish says whether it worked and what the agent was told

Each action is a VableAction with its kind (click, inputText, scroll, goBack, adjust, navigate, pointAt or intent), the element's elementId and label, its bounds on screen, and the agent's args, such as the text it's typing.

Showing what the agent is about to do

An action gate runs before every tap, text entry, scroll, back, slider, navigation and intent, once the target is on screen. The agent waits for it, so you can highlight the target first. Return false to skip the action, and the agent is told the user declined.

Vable.setActionGate((action) async {
  highlight(action.bounds);
  await Future.delayed(const Duration(milliseconds: 400));
  return true;
});

// Type so the user sees it, instead of all at once
Vable.setTyping(const VableTyping.perCharacter(Duration(milliseconds: 45)));

Pausing and stopping

APIWhat it does
Vable.pauseActions()Holds the agent's next action. The call carries on, so the user can still talk to it
Vable.resumeActions()Lets it carry on
Vable.cancelCurrentTask()Stops what the agent is saying, the reply it's working on, and what it was going to do on the screen. The agent is told the user stopped
Vable.notifyUserInteraction(elementId: id)Tells the agent the user changed something themselves, so it doesn't undo it

With VableCallStyle.none, the user touching the screen pauses the agent, and the agent is told what they used with its next action. The pause ends when you resume it, or when the user next talks to the agent; then what it was waiting to do is dropped, because the conversation has moved on. Talking over the agent drops it too. Turn this off with Vable.pauseOnUserTouch = false.

Wrap your own assistant UI in VableAssistantUi. The agent can't see or press what's inside it, and touching it doesn't pause the agent:

VableAssistantUi(
  child: IconButton(
    icon: const Icon(Icons.stop),
    onPressed: Vable.cancelCurrentTask,
  ),
)

Things only the user can do

VableRequiresUser keeps a control for the user, such as paying or sharing a passport. The agent still sees it, marked with the reason. When it tries the control, it's told it's waiting for the user. With VableCallStyle.none, the agent can point at the control instead: you get a VableActionStarted with the pointAt kind, so you can highlight it.

VableRequiresUser(
  reason: 'payment',
  child: FilledButton(onPressed: pay, child: const Text('Pay £240')),
)

VableNoOp still hides a control from the agent completely.

Asking the user to choose

Vable.say(text) has the agent say your words, in its voice, and keeps them in the conversation. For quick replies, give the agent an intent whose handler asks the question, shows your choices and waits for the user's pick. The agent waits for the result.

VableIntent(
  name: 'askUser',
  description: 'Ask the user to pick one of a few options',
  parameters: {
    'question': VableIntentParameter(description: 'The question', type: 'string', required: true),
    'options': VableIntentParameter(description: 'The choices, comma separated', type: 'string', required: true),
  },
  onIntent: (parameters) async {
    await Vable.say(parameters['question']);
    final choice = await showQuickReplies(parameters['options']);
    return 'The user chose $choice';
  },
)

The vable_flutter example app has a screen built this way. Run it with --dart-define=VABLE_HEADLESS=true.


iOS

The iOS SDK draws nothing with .none, and your VableNavigationDelegate hears what the call is doing. Every method has a default, so implement only those you need.

Vable.shared.setCallStyle(.none)

final class CallObserver: VableNavigationDelegate {
    func onNavigateRequested(url: String) {}
    func onAgentState(_ state: String) {}          // listening, thinking, speaking or acting
    func onAssistantText(_ text: String, isFinal: Bool) {}
    func onUserTranscript(_ text: String, isFinal: Bool) {}
    func onUserInterrupted() {}
    func onVoiceLevels(agent: Float, user: Float) {}
}
APIWhat it does
setCallStyle(.none)Draws nothing during a call. End it with endVoiceChat()
cancelTurn()Stops what the agent is saying, its reply, and the actions it's waiting on
say(_:)Has the agent say your text word for word
onUserSpeechStarted()Called each time the user starts to speak

The action gate, typing, pausing and VableRequiresUser are in the Flutter SDK, which carries out the agent's actions in Flutter apps. In a native app, your app carries out the agent's intents itself, so it already decides when and how.


Android

Vable.setCallStyle(CallStyle.None)

Vable.setEventCallback(object : VableEventCallback {
    override fun onNavigateRequested(url: String) {}
    override fun onIntent(id: String, parameters: JSONObject) {}
    override fun onAgentState(state: String) {}
    override fun onAssistantText(text: String, isFinal: Boolean) {}
    override fun onUserTranscript(text: String, isFinal: Boolean) {}
    override fun onUserInterrupted() {}
    override fun onVoiceLevels(agent: Float, user: Float) {}
})
APIWhat it does
Vable.setCallStyle(CallStyle.None)Draws nothing during a call. End it with Vable.endVoiceChat()
Vable.cancelTurn()Stops what the agent is saying, its reply, and the actions it's waiting on
Vable.say(text)Has the agent say your text word for word
onUserSpeechStarted()Called each time the user starts to speak

The callbacks are called on the main thread.