Npc friend and npc chat

Is it possible to implement features such as adding an NPC as a friend or chatting with NPCs (where the game server communicates with GPT)? Additionally, I would like to display the details of these NPC friends on a dashboard. What would be the best practice for implementation: using the runtime framework or modifying the source code and rebuilding the game server?

Are there any case studies or examples I can refer to?

Hi @zaichenhu,

The way to allow these NPCs to be added as friends would be to create dummy user accounts for them, which the user can then add, and flag these accounts as NPC (either on that account’s user metadata, or elsewhere).

You can setup after-hooks on the add friend API to automatically accept incoming invites for these specific users (you’d have to check if the target user is an NPC or not to make sure you don’t auto-add requests to regular users).

You’d also use after-hooks on the realtime channel message send APIs to have your custom GPT logic, where if the target user is an NPC you can fetch the response and use ChannelMessageSend to send a response back to the user.

On the dashboard front, I guess it really depends on what you mean, if this is an admin dashboard to inspect these NPCs messages and so on, I think the built in Nakama Console should suffice, if you’d need a custom built dashboard, you could use the existing API to register a raw http handler (Go runtime only) and build your own. If you go down this avenue, don’t forget that any registered raw http handler does not include any auth checks, so you’d have to implement your own.

We don’t have examples for this specific use case, but there should be some examples on how to use after-hooks and other bits and pieces around our docs.

Best.

1 Like