> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/tutorials-and-examples/ui-camera-player/npc-toolkit.md).

# NPC Toolkit

Reusable NPC behaviours and dialogue UI for SDK7 scenes.

Use reusable NPC behaviours and dialogue UI for SDK7 scenes.

## Project information

**Maintained by:** Decentraland

[View source](https://github.com/decentraland-scenes/dcl-npc-toolkit)

**License:** [Apache-2.0](https://github.com/decentraland-scenes/dcl-npc-toolkit/blob/main/LICENSE). Check upstream terms before reuse; code and assets may have different terms.

## Explore the code

These links point to a specific source snapshot so the explanations remain useful as upstream development continues. They are learning references, not a security assessment.

### Separate revealing dialogue from advancing it

`handleDialogClick`, `rushText`, and `confirmText` first reveal the remaining characters if text is still typing. Subsequent input advances the script or selects a numeric dialogue branch, with callbacks for game actions.

**Project context:** Read this alongside the toolkit's `Dialog` data and `npcDialogComponent` state to understand how UI input drives a conversation.

**Source references:**

* [`handleDialogClick`, `rushText`, and `confirmText`](https://github.com/decentraland-scenes/dcl-npc-toolkit/blob/60e327c67a126d92e47ecf8e7eda342ce1191076/src/dialog.ts#L489-L549)

### Connect proximity and pointer input to an NPC interaction

`addClickReactions` and `addTriggerArea` configure pointer callbacks and a child sphere trigger, with settings for click-only activation and continuing dialogue when the player walks away. `activate` and `endInteraction` coordinate the active NPC, cooldown, dialogue, and optional player-facing behavior.

**Project context:** These functions rely on the toolkit's callback maps and tracking system.

**Source references:**

* [`addClickReactions` and `addTriggerArea`](https://github.com/decentraland-scenes/dcl-npc-toolkit/blob/60e327c67a126d92e47ecf8e7eda342ce1191076/src/npc.ts#L410-L531)
* [`activate` and `endInteraction`](https://github.com/decentraland-scenes/dcl-npc-toolkit/blob/60e327c67a126d92e47ecf8e7eda342ce1191076/src/npc.ts#L769-L823)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/tutorials-and-examples/ui-camera-player/npc-toolkit.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
