For the complete documentation index, see llms.txt. This page is also available as Markdown.

Gate your UI on availability

Gate a custom chat field or microphone button on conversation availability so player input waits until a character can hear it.

Bind your own chat field, microphone button, or send action to ConvaiManager.ConversationAvailability so it only accepts input once the addressed character can actually hear it. Use this page when you are building custom input UI rather than using the shipped chat field, which already gates itself — see Customise the chat field prompts if that is what you are configuring.

Prerequisites

Read the current verdict

ConvaiManager.ConversationAvailability returns the current ConvaiConversationAvailability for ConvaiManager.AddressedCharacter. Call CanAcceptPlayerInput() on the result to get the single boolean a UI needs:

using Convai.Runtime.Components;
using UnityEngine;
using UnityEngine.UI;

public class SendButtonGate : MonoBehaviour
{
    [SerializeField] private ConvaiManager _manager;
    [SerializeField] private Button _sendButton;

    private void Update()
    {
        _sendButton.interactable = _manager.ConversationAvailability.CanAcceptPlayerInput();
    }
}

React to the change event instead of polling

ConvaiManager.ConversationAvailabilityChanged fires whenever the verdict moves, including when the player starts addressing a different character whose availability differs. Subscribe to it to update UI on the moment rather than on the next frame:

Gate on a specific character instead of the addressed one

A UI element tied to one particular character — a name plate, a per-character indicator in a multi-character scene — should read ConvaiCharacter.ConversationAvailability on that character directly, rather than ConvaiManager.ConversationAvailability, which always answers for whoever is currently addressed:

Verify the gate

Enter Play mode, connect, and try to type or press send before the character has been confirmed. The gate should block the action until availability reports Ready or Answering. Disconnect the character mid-conversation and confirm the gate closes again.

Next steps

React to the player starting to speakConversation availability reference

Last updated

Was this helpful?