> For the complete documentation index, see [llms.txt](https://docs-en.dydu.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-en.dydu.ai/developers/api-reference/dialog-api.md).

# Dialog API

The dialog engine can be queried in two ways:

* **in synchronous mode, with the REST API**: the bot only answers when the user sends a question. In the diagram below, *talk* requests are synchronous and their result contains the bot's answer;
* **in asynchronous mode, with a WebSocket**: the server can send messages without being asked, for example when a human operator writes to the user.

<figure><img src="https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FRXHgdzBwSMFgpTTKwIx8%2Fimage.png?alt=media&amp;token=129aaf66-ce8c-4245-a9e0-da7399034e95" alt="" width="361"><figcaption></figcaption></figure>

## REST API (synchronous mode)

You can test these APIs in the Swagger interface: go to **Preferences > Api > API access**, click the link provided, then **Chat**.

### General operation

* **Address**: `https://<server>/servlet/api/chat/...`, replacing `<server>` with the address of your platform.
* **Method**: `POST`, with form parameters (`Content-Type: application/x-www-form-urlencoded`). Only the APIs that read variables and status use `GET`.
* **Bot identifier**: it is always in the address (`/chat/talk/{botUUID}`). You can find it on the **Preferences > Api > API access** page.
* **Authentication**: none by default. If an OIDC filter is defined on your bot, add the `Authorization: Bearer <JWT token>` header.
* **Responses**: the values of JSON responses are base64 encoded. For example, `"typeResponse":"RE1VbmRlcnN0b29kUXVlc3Rpb24="` stands for "DMUnderstoodQuestion". Some APIs return JavaScript (for example `console.log('...')`).

{% hint style="warning" %}
The name of the dialog identifier parameter depends on the API: `contextUuid` for most APIs, but `contextUUID` for the satisfaction APIs (`feedback`) and `contextId` for `reading`. Parameter names are case-sensitive.
{% endhint %}

### Typical dialog flow

1. Get a dialog identifier with [Get a dialog identifier](#get-a-dialog-identifier), or directly send a first question with [Send a question](#send-a-question).
2. Send the next questions with this identifier.
3. Send the user's feedback with the [satisfaction](#satisfaction) APIs.

The dialog identifier groups all the interactions of a dialog. When it is not used for 10 minutes, the dialog is archived and the identifier is no longer valid. If you send an invalid or expired identifier, the server creates a new one.

### Common parameters

These parameters are used by several APIs. The table of each API lists the ones it accepts.

| Parameter                  | Description                                                                                                                                                                                                                                                   |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `userInput`                | User's question. Only the first 600 characters are taken into account.                                                                                                                                                                                        |
| `space`                    | Consultation space. To use no particular space, enter "Defaut".                                                                                                                                                                                               |
| `language`                 | Dialog language, in English with a capital letter: "French", "English", "Dutch", "Spanish", "German"… If the user writes in another language handled by the bot, the bot answers in the language used.                                                        |
| `alreadyCame`              | `true` if the user has already come, `false` otherwise.                                                                                                                                                                                                       |
| `clientId`                 | User identifier. Without this parameter, the dialog is anonymous. In the BMS dialog reading page, it is only displayed to administrators.                                                                                                                     |
| `userUrl`                  | URL of the page the question was asked from.                                                                                                                                                                                                                  |
| `browser`                  | User's browser.                                                                                                                                                                                                                                               |
| `os`                       | User's operating system.                                                                                                                                                                                                                                      |
| `contextType`              | Dialog type: "Web", "Vocal", "Android" or "iOS".                                                                                                                                                                                                              |
| `qualificationMode`        | `true`: qualification (testing) mode. Published and validated knowledge can be used and dialogs are not counted in the analytics. `false` (default): only published knowledge can be used and dialogs are counted.                                            |
| `solutionUsed`             | Solution used, in capital letters: "ASSISTANT", "LIVECHAT", "ASSISTANT\_AND\_LIVECHAT", "FIELDBOX", "VOCAL", "TEAMS", "WHATSAPP", "MESSENGER", "INSTAGRAM", "SMSMODE"…                                                                                        |
| `pureLiveChat`             | `true` to enable the pureLiveChat option.                                                                                                                                                                                                                     |
| `extraParameters`          | Question type, in JSON format: `{"type":"reword_auto"}`. Without this parameter, the question is considered as typed by the user. This type does not change the answer: it is used for analytics. See the [possible values](#question-types-extraparameters). |
| `variables`                | Context variables sent to the bot, in JSON format. Example: `{"name":"dupont","InvoiceSum":"123.45"}`. These variables can then be used in the BMS to personalize answers.                                                                                    |
| `doNotRegisterInteraction` | `true`: the interaction is not saved. `false`: it is saved.                                                                                                                                                                                                   |
| `competency`               | Livechat competency to use.                                                                                                                                                                                                                                   |
| `timestamp`                | Numeric value (integer).                                                                                                                                                                                                                                      |
| `templateFormats`          | Accepted answer template formats, separated by semicolons.                                                                                                                                                                                                    |

#### **Question types (extraParameters)**

| `type` value                     | Description                                                                                           |
| -------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `reword_auto`                    | Click on a rewording suggested by the bot when it did not understand the question.                    |
| `redirection`                    | Click on a URL of the bot's answer, opened in the same page.                                          |
| `redirection_newpage`            | Click on a URL of the bot's answer, opened in a new tab.                                              |
| `redirection_invalidlink`        | Click on an invalid link of the bot's answer.                                                         |
| `javascript`                     | Click on a link of the bot's answer that runs JavaScript (for example an escalation to the livechat). |
| `redirection_knowledge`          | Click on a link of the bot's answer that displays the answer of another knowledge.                    |
| `redirection_consultation_space` | Click on a link suggested by the bot to get the answer in another consultation space.                 |
| `redirection_personality`        | Click on a redirection link to a personality.                                                         |
| `before_close_dialog`            | Question sent before the dialog is closed.                                                            |
| `reword_teaser`                  | Click on a rewording of the teaser.                                                                   |
| `exportable_faq`                 | Question from the exportable FAQ.                                                                     |
| `reword_feedback`                | Click on a rewording suggested after a feedback.                                                      |
| `dtmf`                           | Key pressed on the phone keypad (voice bot).                                                          |

### Start and run a dialog

#### **Get a dialog identifier**

`POST /chat/context/{botUUID}`

| Parameter                                                                                                      | Required | Description                                  |
| -------------------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------- |
| `space`                                                                                                        | Yes      | Consultation space.                          |
| `language`                                                                                                     | Yes      | Dialog language.                             |
| `alreadyCame`, `clientId`, `os`, `browser`, `contextType`, `qualificationMode`, `solutionUsed`, `pureLiveChat` | No       | See [Common parameters](#common-parameters). |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/context/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "space=Defaut&language=English&alreadyCame=true&clientId=jmanier&contextType=Web&solutionUsed=ASSISTANT"
```

Response:

```
console.log('46064f7a-d026-4bf3-ab5d-69a9303a81e7');
```

#### **Send a question**

Two APIs are available:

* `POST /chat/talk/{botUUID}`: for the first question, without a dialog identifier. The server creates a new dialog;
* `POST /chat/talk/{botUUID}/{contextUUID}`: for the next questions, with the dialog identifier in the address.

| Parameter                                                                                                                                                                                                                           | Required | Description                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------- |
| `userInput`                                                                                                                                                                                                                         | Yes      | User's question.                             |
| `space`                                                                                                                                                                                                                             | Yes      | Consultation space.                          |
| `language`                                                                                                                                                                                                                          | Yes      | Dialog language.                             |
| `userUrl`, `alreadyCame`, `clientId`, `os`, `browser`, `contextType`, `qualificationMode`, `solutionUsed`, `pureLiveChat`, `extraParameters`, `variables`, `doNotRegisterInteraction`, `competency`, `timestamp`, `templateFormats` | No       | See [Common parameters](#common-parameters). |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/talk/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20/e6a5ae08-703c-4ddd-9d57-fa07a8908f0d" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d 'userInput=Hello&space=Defaut&language=English&solutionUsed=ASSISTANT&variables={"name":"dupont"}'
```

Response (values are base64 encoded):

```
{"values":{"knowledgeId":168168,"typeResponse":"RE1VbmRlcnN0b29kUXVlc3Rpb24=","contextId":"ZTZhNWFlMDgtNzAzYy00ZGRkLTlkNTctZmEwN2E4OTA4ZjBk","serverTime":1542039200149,"language":"ZW4=","botId":"ZWYwN2EzN2EtMmYzOC00NGYxLWEyYzQtZDJlNzFlN2M2ZDIw","text":"SGVsbG8gIQ==","hasProfilePicture":false,"startLivechat":false,"keepPopinMinimized":false,"human":false,"askFeedback":true},"type":"talkResponse"}
```

#### **Log a user visit**

`POST /chat/welcomecall/{botUUID}`

| Parameter           | Required | Description         |
| ------------------- | -------- | ------------------- |
| `contextUuid`       | Yes      | Dialog identifier.  |
| `solutionUsed`      | Yes      | Solution used.      |
| `language`          | Yes      | Dialog language.    |
| `space`             | Yes      | Consultation space. |
| `qualificationMode` | No       | Qualification mode. |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/welcomecall/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&language=English&space=Defaut"
```

Response:

```
/*logged*/
```

#### **Indicate that the user is typing**

`POST /chat/typing/{botUUID}`

| Parameter      | Required | Description                   |
| -------------- | -------- | ----------------------------- |
| `contextUuid`  | Yes      | Dialog identifier.            |
| `solutionUsed` | Yes      | Solution used.                |
| `content`      | Yes      | Text being typed.             |
| `typing`       | No       | `true` if the user is typing. |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/typing/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&content=Hel&typing=true"
```

Response:

```
{}
```

#### **Check for a new answer (livechat)**

In livechat polling mode, checks whether a new answer is waiting for the user.

`POST /chat/poll/last/{botUUID}`

| Parameter      | Required | Description                                                              |
| -------------- | -------- | ------------------------------------------------------------------------ |
| `contextUuid`  | Yes      | Dialog identifier.                                                       |
| `solutionUsed` | Yes      | Solution used.                                                           |
| `language`     | Yes      | Dialog language.                                                         |
| `space`        | Yes      | Consultation space.                                                      |
| `lastPoll`     | Yes      | Numeric value of the last poll.                                          |
| `format`       | No       | Response format: "JSon" (default), "XML", "JSonDydu", "Vocal" or "Html". |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/poll/last/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&language=English&space=Defaut&lastPoll=12"
```

Response:

```
dydu_notification('{"code":"RGlhbG9nRmluaXNoZWQ=","context":null,"serverTime":1542034663648,"text":"TGEgY29udmVyc2F0aW9uIGVzdCB0ZXJtaW7DqWU="}');
DYDUServlet.closeDialog(true, false);
```

### History

#### **Get the history of a dialog**

`POST /chat/history/{botUUID}`

| Parameter      | Required | Description                                          |
| -------------- | -------- | ---------------------------------------------------- |
| `contextUuid`  | Yes      | Identifier of the current dialog.                    |
| `solutionUsed` | Yes      | Solution used.                                       |
| `dialog`       | No       | Identifier of another dialog whose history you want. |
| `uiLocale`     | No       | Interface language.                                  |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/history/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT"
```

Response:

```
dydu_showDialogHistory();
```

#### **Get the previous dialogs of a user**

`POST /chat/dialog/previous/{botUUID}`

| Parameter      | Required | Description      |
| -------------- | -------- | ---------------- |
| `solutionUsed` | Yes      | Solution used.   |
| `clientId`     | Yes      | User identifier. |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/dialog/previous/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "solutionUsed=ASSISTANT&clientId=jmanier"
```

Response:

```
{"values":{"previousDialogs":[]},"type":"getPreviousDialogsResponse"}
```

### Satisfaction

#### **Send a feedback**

`POST /chat/feedback/{botUUID}`

| Parameter         | Required | Description                                      |
| ----------------- | -------- | ------------------------------------------------ |
| `contextUUID`     | Yes      | Dialog identifier.                               |
| `solutionUsed`    | Yes      | Solution used.                                   |
| `feedBack`        | Yes      | "positive", "negative" or "withoutAnswer".       |
| `interactionDate` | No       | Date of the related interaction (numeric value). |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/feedback/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUUID=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&feedBack=positive"
```

#### **Send a feedback comment**

`POST /chat/feedback/comment/{botUUID}`

| Parameter         | Required | Description                                      |
| ----------------- | -------- | ------------------------------------------------ |
| `contextUUID`     | Yes      | Dialog identifier.                               |
| `solutionUsed`    | Yes      | Solution used.                                   |
| `comment`         | Yes      | User's comment.                                  |
| `interactionDate` | No       | Date of the related interaction (numeric value). |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/feedback/comment/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUUID=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&comment=Thanks"
```

#### **Send the reason for dissatisfaction**

`POST /chat/feedback/insatisfaction/{botUUID}`

| Parameter         | Required | Description                                      |
| ----------------- | -------- | ------------------------------------------------ |
| `contextUUID`     | Yes      | Dialog identifier.                               |
| `solutionUsed`    | Yes      | Solution used.                                   |
| `choiceKey`       | Yes      | Key of the selected dissatisfaction reason.      |
| `interactionDate` | No       | Date of the related interaction (numeric value). |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/feedback/insatisfaction/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUUID=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&choiceKey=choiceKey_value"
```

### Context variables

#### **Set or delete a variable**

`POST /chat/variable/{botUUID}`

| Parameter      | Required | Description        |
| -------------- | -------- | ------------------ |
| `contextUuid`  | Yes      | Dialog identifier. |
| `solutionUsed` | Yes      | Solution used.     |
| `name`         | Yes      | Variable name.     |
| `value`        | No       | Variable value.    |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/variable/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&name=test&value=1"
```

#### **Set or delete several variables**

`POST /chat/variables/{botUUID}`

| Parameter      | Required | Description                                                                   |
| -------------- | -------- | ----------------------------------------------------------------------------- |
| `contextUuid`  | Yes      | Dialog identifier.                                                            |
| `solutionUsed` | Yes      | Solution used.                                                                |
| `variables`    | Yes      | Variables in JSON format. Example: `{"name":"dupont","InvoiceSum":"123.45"}`. |

#### **Read the variables of a dialog**

`GET /chat/variables/{botUUID}/{contextUuid}`

Returns the context variables of the dialog in JSON format.

### Surveys

#### **Get the configuration of a survey**

`POST /chat/survey/configuration/{botUUID}`

| Parameter      | Required | Description        |
| -------------- | -------- | ------------------ |
| `contextUuid`  | Yes      | Dialog identifier. |
| `solutionUsed` | Yes      | Solution used.     |
| `language`     | Yes      | Dialog language.   |
| `surveyId`     | Yes      | Survey identifier. |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/survey/configuration/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&language=English&surveyId=20f4ab33-eb28-47d7-850c-60e5c6a352b3"
```

Response:

```
{"values":{"surveyId":"MjBmNGFiMzMtZWIyOC00N2Q3LTg1MGMtNjBlNWM2YTM1MmIz","name":"TmV3IHN1cnZleQ==","contextId":"ZTZhNWFlMDgtNzAzYy00ZGRkLTlkNTctZmEwN2E4OTA4ZjBk"},"type":"surveyConfigurationResponse"}
```

#### **Send the answers to a survey**

`POST /chat/survey/{botUUID}`

| Parameter                 | Required | Description                                   |
| ------------------------- | -------- | --------------------------------------------- |
| `contextUuid`             | Yes      | Dialog identifier.                            |
| `solutionUsed`            | Yes      | Solution used.                                |
| `fields`                  | Yes      | Answers to the survey fields.                 |
| `interactionSurveyAnswer` | No       | `true` if the survey is about an interaction. |

### Search the knowledge

#### **Search for a knowledge**

`POST /chat/search/{botUUID}`

| Parameter               | Required | Description                                                                              |
| ----------------------- | -------- | ---------------------------------------------------------------------------------------- |
| `language`              | Yes      | Search language. Without this parameter, the API returns a 400 "Missing language" error. |
| `search`                | No       | Searched text.                                                                           |
| `space`                 | No       | Consultation space.                                                                      |
| `searchInParents`       | No       | `true` (default) to also search in the parent bots.                                      |
| `searchInPersonalities` | No       | `true` to also search in personalities. It is `false` if the parameter is not sent.      |
| `onlyShowRewordables`   | No       | `true` (default) to only return knowledge that can be suggested as rewording.            |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/search/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "language=English&search=opening%20hours"
```

#### **Get the most viewed knowledge**

`POST /chat/topknowledge/{botUUID}`

| Parameter            | Required | Description                                                                                                                                     |
| -------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `solutionUsed`       | Yes      | Solution used.                                                                                                                                  |
| `language`           | Yes      | Dialog language.                                                                                                                                |
| `period`             | Yes      | Period: "Today", "Yesterday", "Last7Days" or "Last30Days". An unknown value is replaced by "Last30Days".                                        |
| `space`              | No       | Consultation space.                                                                                                                             |
| `tag`                | No       | Name or identifier (tagID) of a topic. To find the tagID, right-click the topic, then **Inspect**: in `div id="tag-6671"`, the tagID is "6671". |
| `includeTagChildren` | No       | `true` to include sub-topics.                                                                                                                   |
| `qualificationMode`  | No       | Qualification mode.                                                                                                                             |
| `maxKnowledge`       | No       | Maximum number of knowledge returned (10 by default).                                                                                           |
| `withContent`        | No       | `true` to also return the content of the knowledge.                                                                                             |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/topknowledge/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "solutionUsed=ASSISTANT&language=English&period=Last7Days&maxKnowledge=5"
```

Response (the `knowledgeArticles` list is base64 encoded):

```
{"values":{"knowledgeArticles":"W3sicmV3b3JkIjoi...","serverTime":1542040024994,"tagName":"VGFnX3ZhbHVl"},"type":"topKnowledgeResponse"}
```

### Other APIs

#### **Send an error**

`POST /chat/error/{botUUID}`

| Parameter                                              | Required | Description                             |
| ------------------------------------------------------ | -------- | --------------------------------------- |
| `contextUuid`                                          | Yes      | Dialog identifier.                      |
| `solutionUsed`                                         | Yes      | Solution used.                          |
| `error`                                                | Yes      | Error type.                             |
| `message`                                              | Yes      | Error message.                          |
| `browser`, `os`, `stackTrace`, `jsCreation`, `userUrl` | No       | Additional information about the error. |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/error/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "contextUuid=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&solutionUsed=ASSISTANT&error=js%20error&message=test%20error"
```

Response:

```
{}
```

#### **Register a GDPR request**

`POST /chat/gdpr/{botUUID}`

| Parameter  | Required | Description                                          |
| ---------- | -------- | ---------------------------------------------------- |
| `clientId` | Yes      | User identifier.                                     |
| `object`   | Yes      | "Get" to get the user's data, "Delete" to delete it. |
| `mail`     | Yes      | User's email address.                                |
| `language` | No       | Language of the email sent.                          |

curl request:

```
curl -X POST "https://<server>/servlet/api/chat/gdpr/ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20" \
  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
  -d "clientId=jmanier&object=Get&mail=jmanier%40dydu.ai&language=English"
```

Response:

```
{}
```

#### **Additional APIs**

These APIs are also available in the **Chat** category of the Swagger interface:

| API                                                                    | Description                                                                                                |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `GET /chat/status/{botUUID}/{contextId}`                               | Get the status of a dialog.                                                                                |
| `POST /chat/availablecontext/{botUUID}/{contextUuid}`                  | Check whether a dialog identifier is still valid.                                                          |
| `POST /chat/reading/{botUUID}/`                                        | Indicate whether the user is reading the dialog (`contextId`, `solutionUsed`, `reading` parameters).       |
| `POST /chat/registerlastinteraction/{botUUID}`                         | Indicate whether the last interaction must be saved (`contextUUID`, `registerLastInteraction` parameters). |
| `POST /chat/pushrules/{botUUID}`                                       | Get the behavioral targeting rules.                                                                        |
| `GET /chat/attachment/download/{botId}/{contextUUID}/{attachmentUUID}` | Download an attachment of the dialog (`token` parameter required).                                         |

## WebSocket (asynchronous mode)

The asynchronous mode uses a WebSocket, with the **dyduchat** subprotocol. The endpoint is `/chatWs`.

This mode is especially useful when the user talks with a human operator: the operator does not have to wait for a user's question to answer. They can write first or send several messages in a row.

<figure><img src="https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FI1t1nY5qWeTKQMktA2vE%2Fimage.png?alt=media&amp;token=ce83d517-7222-4e38-b8b9-0b83ca912ebd" alt="" width="361"><figcaption></figcaption></figure>

### Client requests

The client sends its requests in JSON format. All field values must be base64 encoded.

#### **talk request**

<figure><img src="https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2F0qMhIVF9fyL74yspWNGt%2Fimage.png?alt=media&amp;token=661e6813-21ac-48e7-8b83-03349e030202" alt="" width="501"><figcaption></figcaption></figure>

The parameters of the *parameters* field are the same as those of the [REST API](#common-parameters).

#### **feedBack requests**

As with the REST API, no response is returned for feedback requests. The field values are the same as for the [REST API](#satisfaction).

### Server requests

#### **Answer to display**

The server tells the client that a message was sent by the bot or by a human operator. These messages can arrive without the user asking a question.

<figure><img src="https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FDfc9bpJU2bi1CW2XdwLP%2Fimage.png?alt=media&amp;token=a1a14501-9689-4817-a36b-b65f49048bcb" alt="" width="536"><figcaption></figcaption></figure>

The fields are the same as in the REST API response, plus the *human* field: it is `true` if the message comes from a human operator.

#### **Notification**

Notifications inform the user without replacing the last answer, for example to tell them that the operator is no longer connected.

<figure><img src="https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FK9Hi8pkAaR3Y0YK2QZdH%2Fimage.png?alt=media&amp;token=06b61fe4-5630-4d12-a3c0-4bdde4a71988" alt="" width="529"><figcaption></figcaption></figure>
