> 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.
