> For the complete documentation index, see [llms.txt](https://developer.rpggo.ai/dev-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.rpggo.ai/dev-docs/player-api/api-overview/api-v1-deprecated/npc.md).

# NPC

There are two types of NPCs: regular NPCs and DMs.&#x20;

NPCs possess distinct personalities, backgrounds, and in-game roles. Players can interact with them to gather clues.

DMs primarily drive the game's storyline and provide players with information about the current game goals and verification of game outcomes.

## Chat with NPC & DM

## Chat with NPCs or the DM in the game to gather clues or advance the gameplay.

<mark style="color:green;">`POST`</mark> `https://api.rpggo.ai/open/game/chat`&#x20;

#### Request Body

| Name                                          | Type   | Description                                                                              |
| --------------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| session\_id<mark style="color:red;">\*</mark> | String | game session's unique ID, which records the current game state and conversation history. |
| npc\_id<mark style="color:red;">\*</mark>     | String | the ID of the NPC or DM you wish to engage in a conversation with.                       |
| message<mark style="color:red;">\*</mark>     | String | chat message                                                                             |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "code": 0,
  "msg": "ok",
  "data": {
    "result": {
      "image": "",
      "text": "I am James, the loyal butler of Mr. John...",
      "epoch": {
        "current_count": 5,
        "max_chat_count": 10
      }
    },
    "game_status": {
      "game_id": "22",
      "goal_id": "1",
      "scene_id": "2",
      "action": 0
    }
  }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

When conversing with an NPC, focus on the content of the "result" field in the response.&#x20;

* "text" contains the NPC's textual response, and "image" is reserved for future support of AI-generated images.&#x20;
* To enhance gameplay, each NPC has a limit on the number of chat rounds. Within the "epoch," "max\_chat\_count" represents the maximum dialogue rounds, while "current\_count" tracks the current number of dialogues.

When conversing with the DM, in addition to the previously mentioned details, pay attention to the "game\_status" field for advancing the game. The "action" field indicates the upcoming game state:

* 0 -  remaining in the current goal, requiring the user to continue exploring clues and provide the DM with the correct answers.
* 1  -  moving on to the next goal, indicating that the user has completed the current goal and should proceed to the next one based on the DM's response.

{% hint style="info" %}
Players can obtain the current goal through chat with the DM, so developers don't need to handle this. The DM will automatically inform the player of the next stage's goals.
{% endhint %}

* 2 - moving on to next scene, signifying that the user has successfully completed all objectives within the current scene and is moving on to the next one. You need to initiate a new scene by calling the "[https://api.rpggo.ai/open/game/startgame ](<https://api.rpggo.ai/open/game/startgame >)" API, specifying the "game\_id" and "scene\_id."

{% hint style="info" %}
In the "game\_status," the IDs correspond to the next steps to take. If you need to proceed to the next scene, simply use these IDs.
{% endhint %}

* 3 - indicating that the user has completed all goals in all scenes, successfully finishing the game.


---

# 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://developer.rpggo.ai/dev-docs/player-api/api-overview/api-v1-deprecated/npc.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.
