This guide will walk you through the basics of creating an NPC using a character engine. We will make characters from the Harry Potter Universe.
Nothing really. But knowing how to call APIs and form JSONs is good to have.
We will start by creating Harry and his friends! We can define multiple aspects of their characters including their Personality, backstory, friends, enemies, occupation and gender. For Harry, it looks like
Name: Harry Potter
Age: 17
Personality: Brave, Loyal, Determined
Backstory: The Boy Who Lived, famous for surviving an attack by Lord Voldemort. Raised by his aunt and uncle, later attends Hogwarts School of Witchcraft and Wizardry.
Friends: Ron Weasley, Hermione Granger
Enemies: Lord Voldemort, Draco Malfoy
Occupation: Student
Gender: Male
To create this NPC, you need to send this info to us using the register_npc
endpoint.
<aside> đź’ˇ If you are not familiar with endpoints, imagine going to a bank to open an account, you go to the clerk, give them your information and voila! you have a bank account and you leave with an account number. Endpoints act like clerks here. one clerk will register your npc, other will handle their messages and so on.
</aside>
The information follows a specific format however, called JSON. Its like filling a form. This is what Harry’s character sheet looks like when JSONized.
{
"Name": "Harry Potter",
"Age": 17,
"Personality": "Brave, Loyal, Determined",
"Backstory": "The Boy Who Lived, famous for surviving an attack by Lord Voldemort. Raised by his aunt and uncle, later attends Hogwarts School of Witchcraft and Wizardry.",
"Friends": ["Ron Weasley", "Hermione Granger"],
"Enemies": ["Lord Voldemort", "Draco Malfoy"],
"Occupation": "Student",
"Gender": "Male"
}
<aside> 💡 You don’t need to create JSONs yourself, you can ask ChatGPT by providing this example along with character sheet for you NPC
</aside>
You can try asking our clerk to register this NPC below. Just click send. If you click the body tab, you will find the JSON we prepared.
https://hopp.sh/e/tD29AsKUAq2X
Or use the link below if the above embed is not working for you.
<aside> đź’ˇ
If you do not see the JSON data in the embed above, try stretching the embed to make it bigger and ensure you are in the body tab.
</aside>
https://hopp.sh/r/ND90nkd1AddW
You will get a “uuid” in return, save this. This will be used to uniquely identify your NPC. It looks like this
{"uuid": "d444d6b7-c6ec-4358-9342-9f6df9e72837"}
<aside> đź’ˇ
Ensure that you register the friends and enemies of the NPC too for better results.
</aside>
Now, we need to register players. Unlike an NPC, they require just name and gender.
{
"Name":"jeeravan"
"Gender":"Male"
}
You can try this below
https://hopp.sh/e/xFKLDAyBt8vN
{"uuid": "d444d6b7-c6ec-4358-9342-9f6df9e72837"}
Try this link if the above embed is not working
https://hopp.sh/r/xFKLDAyBt8vN
This is why we have been registering the NPCs and Players. Whenever your players say something to a Character Engine enabled NPC, they can respond naturally using the information provided and they can also remember their conversations with the player.
This is what we will send
player
: player uuid from registration
npc
: npc uuid from registration
message
: player’s message
mood
: player’s mood
{
"npc": "d444d6b7-c6ec-4358-9342-9f6df9e72837",
"player" : "a5d553d5-9fa9-4e3e-8d3a-05bd73816fa8",
"message" : "Hi, I am new in this college. Can you help me? I am looking for the potions class",
"mood": "worried and in a hurry"
}
Try it below
https://hopp.sh/e/xhATdJw4SErI
Or use this
https://hopp.sh/r/9fl6sl7aFhHf
You will receive something like this
{"response": "\\"Blimey, you're in a rush, aren't you? I've got my own worries, trying to get to Transfiguration before Snape starts yelling at us. But, alright, let's get this over with. Hermione's probably waiting for us, and I don't want to keep her stuck in the library all day.\\""}
See! So much in character
Now Harry won’t act lively all the time, conversations change and so does the mood. When you want to change a NPC’s mood. send the following information
{
"receiver_id": "d444d6b7-c6ec-4358-9342-9f6df9e72837",
"sender_id" : "a5d553d5-9fa9-4e3e-8d3a-05bd73816fa8",
"mood": "Happy after winning quidditch"
}
Try it below
https://hopp.sh/e/oyn79CtqhlYo
Or use this link
https://hopp.sh/r/x4NopbizP4MG
You will receive something like this
{"mood": "Excited"}
<aside> đź’ˇ
Note that you are not setting the mood here. You are updating it based on their recent chats and a new event as mood
</aside>
Your players do not need to initiate a conversion every time. NPCs can proactively start a conversation too!
Works same as npc response but without the player message
{
"npc": "d444d6b7-c6ec-4358-9342-9f6df9e72837",
"player" : "a5d553d5-9fa9-4e3e-8d3a-05bd73816fa8",
"mood": "worried and in a hurry"
}
https://hopp.sh/e/kpdcD5BCviok
Or use this link
https://hopp.sh/r/kpdcD5BCviok
The response will look something like this
{"response": "(grumbling) Ugh, just when I thought I had a moment to myself... Look, I'm already running late for Transfiguration, but I suppose I can spare a minute to help you. You're looking for the potions class, right? (glancing around nervously) Just don't expect me to stick around too long, got it?"}
That’s all! You are now all set to make your own Hogwart’s Legacy!
This doc will be constantly change as we improve and update our features. Any feature requests, feedback or bug reports can be sent to [email protected]