1
Import the NPC Builder Unity Package
Download the NPC Builder Plugin for Unity from the Unity Asset Store (or the link provided by NPC Builder). Once downloaded, open your Unity project:
- Go to Assets → Import Package → Custom Package.
- Select the downloaded NPC Builder Unity package (e.g., a
.unitypackagefile). - Click Import and ensure all files are selected. Unity will add the NPC Builder plugin files into your project.
2
Verify Installation
After import, check that the NPC Builder plugin assets are present in your Unity project’s Assets folder (there will likely be an
NPCBuilder folder with scripts, a README, etc.). You should see a script or component called NPCBuilderInteractions and related assets. This confirms the plugin is installed and ready to use.1
Locate the Config File
In your Unity Project window, navigate to the NPC Builder plugin’s files (for example, Assets/NPCBuilder/). There should be a file named 
config.json at the root of the NPCBuilder plugin folder.
2
Edit the Config with Credentials
Open config.json in a text editor (or click it in Unity and use the Inspector if available). You will see placeholders for
clientId, clientSecret, and bearerToken. Fill in these fields with the values provided by NPC Builder:- clientId and clientSecret: These come from the NPC Builder platform (under your project’s API Keys). They are used for secure, permanent authentication.
- bearerToken: This is an optional token for authentication. You can use a Bearer token (generated in the NPC Builder web portal) for simpler integration or testing.
3
Save and Secure
Save the config.json file after entering your credentials. Keep these values secure – do not share this file or check it into public source control. The plugin will read this config at runtime to authenticate with the NPC Builder service. If at any point you need to rotate your credentials (e.g., if a key is compromised or updated), remember to update this file accordingly.
1
Attach the NPCBuilderInteractions Component
In your Unity scene, select the GameObject that represents your NPC (for example, a character prefab or an empty object that will act as the NPC’s logic holder). In the Unity Inspector, click Add Component and add “NPCBuilderInteractions”.
This component will handle communication with the NPC Builder backend. You can adjust settings on this component if needed (like default character info), or leave it with defaults to be set via script.
This component will handle communication with the NPC Builder backend. You can adjust settings on this component if needed (like default character info), or leave it with defaults to be set via script.2
Obtain Required IDs from NPC Builder
Ensure you have the relevant IDs from the NPC Builder platform for the NPC you want to use:
- Game ID – the ID of your game project (you would have noted this when setting up credentials).
- World ID (and possibly Region/Location ID if context is used) – where your NPC is located. If your NPC was created under a specific world, use that.
- Character Name or Character ID – identify which NPC character to engage (you can use the character’s name as defined on the platform, or a unique ID if provided).
(The NPCBuilderInteractions component or scripts will need to know these to send the right info. For simplicity, you might hardcode them in a script or retrieve from a config.)
3
Initiate an NPC Interaction via Script
Create a Unity C# script (e.g., ApiInteractionsExample.cs) and attach it to the same GameObject with NPCBuilderInteractions. This script will initialize the conversation. For example:In the above script:
After playing the scene, you should see the NPC’s response appear in the Console (and any events, if triggered). Each subsequent call to
- We grab the
NPCBuilderInteractionscomponent. - We subscribe to an event
OnMessageReceivedwhich triggers every time the NPC responds. - We initiate the conversation by calling
StartInteraction(ConversationRole.User, "Hello there!"). This sends a user message “Hello there!” to the NPC. The plugin in turn contacts the NPC Builder API. - When a response comes back from the NPC, our
OnNPCMessageReceivedhandler is called. In this example, we simply log the NPC’s reply to the Unity Console.
After playing the scene, you should see the NPC’s response appear in the Console (and any events, if triggered). Each subsequent call to
StartInteraction will continue the dialogue (remember, the plugin keeps track of the conversation context).
- Define Globally (Reusable events/items): You can create a library of events and items in the Settings (or global collections) section of NPC Builder. Events defined globally can be reused by any character in any game. For instance, you define an event “wave” globally once, and then multiple NPCs can trigger “wave” without redefining it each time.
- Define per Character: You can also add events or items directly to a specific character’s configuration. In the NPC’s detail page on the platform, you might find options to “Add New Event” or “Add New Item” under that character. These are local to the character. Use this when an event is very specific to one NPC.
- Name/UID: A unique identifier for the event (e.g., “wave” or “attack”). This is the string that will appear in the API responses under user_events or character_events.
- Description: (Optional) A human-readable description of what the event represents. This can be helpful for remembering the intent (e.g., “NPC waves at the player”).
- Type: You must specify if an event is an Action or an Item type:
- Action: A standalone action. It’s just an event with a name/description (the NPC or user does something without involving an inventory item).
- Item: An event that involves an item. If you choose Item type, you will likely link an actual item from the Item list (see below) to define what item is involved when this event triggers.
- Name/UID: A unique identifier for the item (e.g., “Healing Potion” or “Gold Coin”).
- Description: A description of the item.
- Type: You might categorize items by purpose:
- Trade: Items meant for trading or exchange events.
- Action: Items that have a direct use or action in the storyline (e.g., a key item needed to progress a quest).