# Chat with NPCs & Check Goal with SSE

## SSE Chat (Single Chat & Group Chat, Memory Share)

To chat with different characters, the client need to start a SSE call to receive msg.

`POST`[`https://api.rpggo.ai/v2/open/game/chatsse`](https://api.rpggo.ai/v2/open/game/chatsse)&#x20;

**Request Body**

| Name            | Type       | Description                               |
| --------------- | ---------- | ----------------------------------------- |
| game\_id        | String     | the unique id of the game                 |
| session\_id     | String     | the unique id of the game session         |
| character\_id   | String     | the unique id of the character            |
| message\_id     | String     | any unique id to identify the msg         |
| message         | String     | the message content                       |
| advance\_config | dictionary | config to enable the image, voice output. |

**Header**

| Name          | Type   | Description                                                                  |
| ------------- | ------ | ---------------------------------------------------------------------------- |
| Authorization | String | Bearer Token [Apply Your Test Key](/dev-docs/support/apply-your-test-key.md) |
| Content-Type  | String | application/json                                                             |

#### Normal Conversation Request

{% code title="Sample Curl" lineNumbers="true" %}

```bash
curl --location 'https://api.rpggo.ai/v2/open/game/chatsse' \
--header 'accept: application/json' \
--header 'Authorization:$YOUR_RPGGO_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "character_id": "0b2d7f6b-cf8b-4bca-9aec-da8236ffb40a",
  "game_id": "42d029a8-b5a7-49cb-94f4-8baefb0b898a",
  "message": "hi",
  "message_id": "b5fasdffx",
  "session_id": "42d029a8sdrrwqd"
}'
```

{% endcode %}

#### Normal Conversation Message

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
fin
data
{"ret":200,"message":"success","data":{"result":{"character_id":"goal_check_dm","character_type":"goal_check_dm","image":"","text":"","text_ext":"","epoch":{"current_count":0,"max_chat_count":0},"insiders":[],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{"shared_memory":{"goal_check_dm_epoch":1}},"chapters_map":["da08c8ff-490e-4a7f-853c-c64d8c803b15"]}}}
data
{"ret":200,"message":"success","data":{"result":{"character_id":"7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","character_type":"common_npc","image":"","text":"Hey there! *(smiling)* What's up? 😊","text_ext":"","epoch":{"current_count":1,"max_chat_count":90},"insiders":["7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","ea1858ce-5317-4689-b940-742dbe0919c8","cb3059a6-3fba-4dc9-a1b0-f20e6bb4e9ec","6032b7f2-b514-409e-9a65-bcceb975daa8","4a5a365f-23ac-443e-9f3d-0ca59b913d15"],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"goals0","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{},"chapters_map":[]}}}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}

#### Multimodal Conversation Request

{% code title="Sample Curl" lineNumbers="true" %}

```bash
curl --location 'https://api.rpggo.ai/v2/open/game/chatsse' \
--header 'accept: application/json' \
--header 'Authorization: ' \
--header 'Content-Type: application/json' \
--data {
  "game_id": "42d029a8-b5a7-49cb-94f4-8baefb0b898a",
  "character_id": "7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e",
  "message": "Can you tell me more about what you saw through the drone? 📡",
  "user_id": "6bad72e7-a936-4069-84f8-670540cf3cac",
  "session_id": "2Kzoxbeht_aoHNgDeHLtN",
  "message_id": "lkxQ8yGzbklVp3DwlHWQH",
  "advance_config": {
    "enable_image_streaming": true
  }
}'
```

{% endcode %}

#### Multimodal Conversation Message

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
fin
data
{"ret":200,"message":"success","data":{"result":{"character_id":"picture_produce_dm","character_type":"picture_produce_dm","image":"https://storage.googleapis.com/rpggo-imagegen/42d029a8-b5a7-49cb-94f4-8baefb0b898a/f28452f5a91b4ce687d56c0c08cd454f.jpeg","image_type":1,"text":"With a spark of excitement in her eyes, Chiara leans in, recounting her close encounter—a shadowy figure adorned with a familiar emblem, hinting at connections to the racing underworld.","text_ext":"","epoch":{"current_count":0,"max_chat_count":0},"insiders":[],"message_id":"lkxQ8yGzbklVp3DwlHWQH","log_id":"10077ae2-637b-4558-979e-ceb3880fbb46","action_list":[]},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{},"chapters_map":["da08c8ff-490e-4a7f-853c-c64d8c803b15"],"displayed_status":{},"multimodal":{"action":2,"action_message":"picture produce sync"}},"transaction_details":{"ImageConsumption":{"type":"ImageConsumption","amount":4,"fund_direction":"OUT","name":"Image Streaming","description":"Create breathtaking Al-generated images that bring thegame's plot to life."}}}}
data
{"ret":200,"message":"success","data":{"result":{"character_id":"goal_check_dm","character_type":"goal_check_dm","image":"","text":"","text_ext":"","epoch":{"current_count":0,"max_chat_count":0},"insiders":[],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{"shared_memory":{"goal_check_dm_epoch":1}},"chapters_map":["da08c8ff-490e-4a7f-853c-c64d8c803b15"]}}}
data
{"ret":200,"message":"success","data":{"result":{"character_id":"7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","character_type":"common_npc","image":"","text":"Hey there! *(smiling)* What's up? 😊","text_ext":"","epoch":{"current_count":1,"max_chat_count":90},"insiders":["7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","ea1858ce-5317-4689-b940-742dbe0919c8","cb3059a6-3fba-4dc9-a1b0-f20e6bb4e9ec","6032b7f2-b514-409e-9a65-bcceb975daa8","4a5a365f-23ac-443e-9f3d-0ca59b913d15"],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"goals0","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{},"chapters_map":[]}}}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}

## Game Control Message

#### 1. Chapter Switch

| character\_type | message field                | value  | command note            |
| --------------- | ---------------------------- | ------ | ----------------------- |
| goal\_check\_dm | data.game\_status.action     | 2      | switch chapter          |
| common\_npc     | game\_status.action\_message | string | the new chapter content |

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
fin
data
{"ret":200,"message":"success","data":{"result":{"character_id":"goal_check_dm","character_type":"goal_check_dm","image":"","text":"","text_ext":"","epoch":{"current_count":0,"max_chat_count":0},"insiders":[],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":2,"action_message":"","game_meta":{"shared_memory":{"goal_check_dm_epoch":1}},"chapters_map":["da08c8ff-490e-4a7f-853c-c64d8c803b15"]}}}
data
{"ret":200,"message":"success","data":{"result":{"character_id":"7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","character_type":"common_npc","image":"","text":"Hey there! *(smiling)* What's up? 😊","text_ext":"","epoch":{"current_count":1,"max_chat_count":90},"insiders":["7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","ea1858ce-5317-4689-b940-742dbe0919c8","cb3059a6-3fba-4dc9-a1b0-f20e6bb4e9ec","6032b7f2-b514-409e-9a65-bcceb975daa8","4a5a365f-23ac-443e-9f3d-0ca59b913d15"],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"goals0","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{},"chapters_map":[]}}}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}

#### 2. Game Ending

| character\_type | message field                | value  | command note       |
| --------------- | ---------------------------- | ------ | ------------------ |
| goal\_check\_dm | data.game\_status.action     | 3      | Game is ending     |
| common\_npc     | game\_status.action\_message | string | The ending summary |

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
fin
data
{"ret":200,"message":"success","data":{"result":{"character_id":"goal_check_dm","character_type":"goal_check_dm","image":"","text":"","text_ext":"","epoch":{"current_count":0,"max_chat_count":0},"insiders":[],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":3,"action_message":"","game_meta":{"shared_memory":{"goal_check_dm_epoch":1}},"chapters_map":["da08c8ff-490e-4a7f-853c-c64d8c803b15"]}}}
data
{"ret":200,"message":"success","data":{"result":{"character_id":"7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","character_type":"common_npc","image":"","text":"Hey there! *(smiling)* What's up? 😊","text_ext":"","epoch":{"current_count":1,"max_chat_count":90},"insiders":["7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","ea1858ce-5317-4689-b940-742dbe0919c8","cb3059a6-3fba-4dc9-a1b0-f20e6bb4e9ec","6032b7f2-b514-409e-9a65-bcceb975daa8","4a5a365f-23ac-443e-9f3d-0ca59b913d15"],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"goals0","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{},"chapters_map":[]}}}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}

#### 3. Failed to pass game

| character\_type | message field                        | value  | command note                  |
| --------------- | ------------------------------------ | ------ | ----------------------------- |
| goal\_check\_dm | data.game\_status.action             | 4      | Fail the goal                 |
| common\_npc     | goal.chapter\_tip.closing\_statement | string | The ending summary of failure |

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
fin
data
{"ret":200,"message":"success","data":{"result":{"character_id":"goal_check_dm","character_type":"goal_check_dm","image":"","text":"","text_ext":"","epoch":{"current_count":0,"max_chat_count":0},"insiders":[],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":"The goal is 'zingbagaly' failed."},"goals_status":[{"goal":"The goal is 'zinbagaly' failed.","goal_id":"fail_goal","achieved":true}]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":4,"action_message":"","game_meta":{"shared_memory":{"goal_check_dm_epoch":1}},"chapters_map":["da08c8ff-490e-4a7f-853c-c64d8c803b15"]}}}
data
{"ret":200,"message":"success","data":{"result":{"character_id":"7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","character_type":"common_npc","image":"","text":"Hey there! *(smiling)* What's up? 😊","text_ext":"","epoch":{"current_count":1,"max_chat_count":90},"insiders":["7ed2dfa5-bcbc-4621-b2bd-dc0d0555811e","ea1858ce-5317-4689-b940-742dbe0919c8","cb3059a6-3fba-4dc9-a1b0-f20e6bb4e9ec","6032b7f2-b514-409e-9a65-bcceb975daa8","4a5a365f-23ac-443e-9f3d-0ca59b913d15"],"message_id":"b5fasdffxef"},"game_status":{"game_id":"42d029a8-b5a7-49cb-94f4-8baefb0b898a","goal_id":"goals0","goal":{"chapter_tip":{"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","closing_statement":""},"goals_status":[]},"chapter_id":"da08c8ff-490e-4a7f-853c-c64d8c803b15","action":0,"action_message":"","game_meta":{},"chapters_map":[]}}}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}

#### 4. Other error messages

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
err
{"ret":10000303,"message":"The game session has ended","data":null}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="200: OK " %}
{% code lineNumbers="true" %}

```json
err
{"ret":10000307,"message":"Data error. Please refresh the page or restart the game","data":null}
```

{% endcode %}
{% endtab %}

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://developer.rpggo.ai/dev-docs/player-api/api-overview/api-v2-new/chat-with-npcs-and-check-goal-with-sse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
