> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-availability/gate-your-ui.md).

# 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](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-availability/customise-chat-prompts.md) if that is what you are configuring.

### Prerequisites

* A scene with `ConvaiManager` and at least one active `ConvaiCharacter`. See [Scene components reference](/api-docs/plugins-and-integrations/convai-unity-sdk/getting-started/scene-components.md).
* Familiarity with the conversation availability states. See [How conversation availability works](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-availability/how-availability-works.md).

### 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:

```csharp
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:

```csharp
private void OnEnable() => _manager.ConversationAvailabilityChanged += HandleAvailabilityChanged;
private void OnDisable() => _manager.ConversationAvailabilityChanged -= HandleAvailabilityChanged;

private void HandleAvailabilityChanged(ConvaiConversationAvailability availability)
{
    _sendButton.interactable = availability.CanAcceptPlayerInput();
}
```

### 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:

```csharp
[SerializeField] private ConvaiCharacter _character;
[SerializeField] private Image _indicator;

private void Update()
{
    _indicator.color = _character.CanAcceptPlayerInput ? Color.green : Color.gray;
}
```

{% hint style="warning" %}
`ConvaiCharacter.ConversationAvailability` is not the same as `ConvaiCharacter.IsCharacterReady`. `IsCharacterReady` is set once by the character-ready signal from Convai and does not clear when the character later loses its seat in the room. Use `ConversationAvailability` for anything that gates player input.
{% endhint %}

### 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

{% content-ref url="/pages/w8SIt9eZDYa9GNiuNcEE" %}
[React to the player starting to speak](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-availability/local-player-activity.md)
{% endcontent-ref %}

{% content-ref url="/pages/aSqM5Dbw1ipIKyU6CFo9" %}
[Conversation availability reference](/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-availability/availability-reference.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.convai.com/api-docs/plugins-and-integrations/convai-unity-sdk/features/conversation-availability/gate-your-ui.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
