# Dialog API

### Querying the dialog engine

The dialog engine can be queried by web services. Depending of what you are using, you must use either a web service in synchronous mode or a web service in asynchronous mode:

* A dialog in synchronous mode implies that the dialog engine will only respond when asked by a user's question. In the sequence diagram below, the *talk* dialog requests are synchronous and the result contains the bot's answer;
* A dialog in asynchronous mode implies that the dialog engine can send messages without having been requested. In the sequence diagram below, the *feedback* dialog requests are asynchronous and no feedback is expected.

<figure><img src="https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FLdQwuBT3fczxmTa3IRAl%2Fimage.png?alt=media&#x26;token=aaca6994-e7a7-4d8e-bfa6-e4ed3621deb1" alt=""><figcaption></figcaption></figure>

### Synchronous dialog web service

You can use the swagger interface available from **Preferences > Api > API access**. Click the link available and click **Chat**.

This web service is in REST mode, accessible via HTTP GET or HTTP POST.

#### Parameters

Here are the parameters of the queries to the web service:

| **Parameters**           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| contextId                | Dialog ID                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|                          | The response of the web service will contain, among others, the value to be later on given to this field to gather all the interactions in a single dialog. An interaction is part of a dialog only if they have the same contextID. On the server side, when the context ID is unused for 10 minutes, the dialog is archived and this ID is revoked. If an invalid or revoked context ID is sent to the web service, the server will ignore it and create a new valid context ID. This parameter is sent the first time by the server with the first query, then it has to be filled in the entry parameters for the next requests. |
| botUUID                  | Bot ID (Bot identification)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                          | The bot ID can be found on the page **Préférences > Api > API access**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| userInput                | User Input)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                          | This parameter contains the user question. Only the first 600 characters of the question are taken into account by the dialog engine.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| space                    | Consultation space                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | The consultation space to be used can be sent to the dialog box thanks to this parameter. So no consultation space is used over others, this parameters has to be set to Default.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| language                 | ISO code of the language (fr, en, nl) or language selection in swagger                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|                          | The language parameter is useful when the bot is multilingual.This parameter shows the default language of the bot. If the user talks to the bot in another language that it can handle, it will answer anyway in the used language.                                                                                                                                                                                                                                                                                                                                                                                                 |
| alreadyCame              | Information if user has already come                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|                          | This parameter shows if the user has already come.The **true** value shows that the user has already come.. The **false** value shows that the user has never come before.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| clientId                 | User ID (User identification)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                          | If this parameter is not filled in, the dialog will be anonymous.If this parameter is filled in, which can happen if the dialog box is used in a connected space of the website, this ID will be linked to the conversation. In the back office, on the dialog reading page, the user name will only be shown to admins.                                                                                                                                                                                                                                                                                                             |
| userUrl                  | User URL (User current url)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                          | This parameter shows the URL from which the question was asked.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| browser                  | Browser                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|                          | This parameter shows the browser used by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| os                       | OS (Operating System)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|                          | This parameter shows the user's OS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| enableLanguageDetection  | Language detection                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | This parameter shows if language detection is enabled.When set to **true**, language detection is enabled. When set to **false**, language detection is off.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| contextType              | Dialog context                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|                          | This parameter shows the the context of the dialog:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|                          | - Web ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|                          | - Vocal ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|                          | - Android ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                          | - iOS.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| qualificationMode        | Qualification mode                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | This parameter shows if the questions asked to the bot are in qualification mode. By setting it to **true**, knowledge items are published and usable. Dialogs are not counted in the analytics. By setting it to **false**, only already published knowledge items can be used. Dialogs are counted in analytics. This setting is false by default.                                                                                                                                                                                                                                                                                 |
| solutionUsed             | Solution used                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                          | This parameter shows the type of solution used: assistant, livechat, etc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| pureLiveChat             | pureLiveChat                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|                          | This parameter shows if the pureLiveChat option is enabled.If **true**, the option **pureLivechat** is enabled. If **false**, the option **pureLivechat** is disabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| extraParameters          | Question type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                          | This parameter shows the query is of a special type.By default, if no type is filled in, the query will be shown as entered by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|                          | It is useful if the bot has, for example, reworded and the user has clicked on one of the rewords, or if the answer contained clickable links (to another answer or a URL). This parameters lets you indicate the question is of a different type.                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | It has no influence on the processing by the dialog engine, but help identify the origin of requests in analytics.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | The available types are:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|                          | - **reword\_auto:** click on one of the rewords suggested by the bot if the question was misunderstood;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|                          | - **redirection:** click on a URL in a bot answer with opening in the same tab;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|                          | - **redirection\_newpage :** click on a URL in a bot answer with opening in a new tab;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|                          | - **redirection\_javascript:** click on a URL in a bot answer with launch of a Javascript(ex: escalation to Livechat);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|                          | - **redirection\_knowledge:** click on a URL in a bot answer with opening of another knowledge;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|                          | - **redirection\_consultation\_space :** click on a link when the bot did not have an answer in the current consultation space and suggested to the user to visit another consultation space;                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                          | - **redirection\_personnality**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|                          | - **before\_close\_dialog**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|                          | - **reword\_teaser**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|                          | - **exportable\_faq**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|                          | - **reword\_feedback**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| variables                | context variables\\                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|                          | This parameter allows to pass additional information to the bot. This information can then be used in the backoffice to give custom answers or answers that dependent of the use context.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|                          | They have to be sent as follows: **{"Key1":"value1","Key2":"value2"}**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|                          | For example, if the following context variables have to be shared:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | name: dupont                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|                          | InvoiceSum: 123.45                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | The contextVariables parameter will be: {"name":"dupont","InvoiceSum":"123.45"}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| doNotRegisterInteraction | Information about dialog storage                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                          | Setting this parameter to **true** disables saving interactions.Setting this parameter to **false** enables saving interactions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| competency               | Operator Competency                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|                          | This parameter shows the used operator competency.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| timestamp                | Time of the dialog                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                          | This parameter shows the time of the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| templateFormats          | Template formats                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                          | This parameter shows used format templates.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| tag (ou tagID)           | Tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|                          | This parameter allows to include a tag.To insert the value of a tag, write in its name or tagID. To find the tagID of a tag: right click > inspect your subtag. Then, find the following code (for example):                                                                                                                                                                                                                                                                                                                                                                                                                         |
|                          | div id="tag-6671"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|                          | Here, the tagID is 6671.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| period                   | Period                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|                          | Allows to filter in a period. Possible values are: Today, Yesterday, Last7Days, CurrentMonth, LastMonth, Last30Days, Last3Months, Last6Months, Last12Months.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|                          | Allows to exclude or include the gallery to which your knowledge base is linked. Setting it to **true** excludes the gallery. Setting is to **false** includes the gallery.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| excludeGalleryContent    | Exclude Gallery Content                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

#### Queries*Chat*

Retrieve a dialog context ID

| Mandatory parameters | Optional parameters        |
| -------------------- | -------------------------- |
| - botUUID            | - alreadyCame              |
| - space              | - clientId                 |
| - language           | - os                       |
|                      | - browser                  |
|                      | - disableLanguageDetection |
|                      | - ContextType              |
|                      | - qualificationMode        |
|                      | - solutionUsed             |
|                      | - pureLiveChat             |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/context/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**space**=Defaut&amp;**language**=French&amp;alreadyCame=true&amp;clientId=jmanier&amp;os=Linux&amp;browser=Chrome&amp;disableLanguageDetection=true&amp;contextType=Web&amp;qualificationMode=true&amp;solutionUsed=ASSISTANT&amp;pureLiveChat=false"
```

Body answer:

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

Retrieve the list of previous dialogs associated to a user

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - solutionUsed       |                     |
| - clientId           |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/dialog/previous/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**solutionUsed**=ASSISTANT&amp;**clientId**=jmanier"
```

Body answer:

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

Send error

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            | - browser           |
| - contextUUID        | - os                |
| - solutionUsed       | - stackTrace        |
| - error              | - jsCreation        |
| - message            | - userUrl           |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/error/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "contextUuid=**e6a5ae08-703c-4ddd-9d57-fa07a8908f0d**&amp;**solutionUsed**=ASSISTANT&amp;**error**=js%20error&amp;**message**=test%20error&amp;browser=Chrome&amp;os=Linux&amp;stackTrace=stacktrace_value&amp;jsCreation=jscreation_value&amp;userUrl=doyoudreamup.com"
```

Body answer:

```
{}
```

Send satisfaction opinion

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - feedBack           |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/feedback/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUUID**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**feedBack**=positive"
```

Send satisfaction without comment

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - comment            |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/feedback/comment/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUUID**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**comment**=feedback_comment"
```

Send dissatisfaction opinion with selected reason

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - choiceKey          |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/feedback/insatisfaction/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUUID**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**choiceKey**=choiceKey_value"
```

Save GDPR request

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            | - language          |
| - clientId           |                     |
| - object             |                     |
| - mail               |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/gdpr/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**clientId**=jmanier&amp;**object**=Get&amp;**mail**=jmanier%40dydu.ai&amp;language=French"
```

Body answer:

```
{}
```

Retrieve dialog history

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - dialog             |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/history/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**dialog**=ddce9eb2-4015-4c68-bf4c-e59f97096f81"
```

Body answer:

```
dydu_showDialogHistory();
```

Check if there is a new user answer (Livechat mode)

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - language           |                     |
| - space              |                     |
| - lastPoll           |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/poll/last/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**language**=French&amp;**space**=Defaut&amp;**lastPoll**=12"
```

Body answer:

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

Perform a search in a bot's knowledge:

| Mandatory parameters | Optional parameters     |
| -------------------- | ----------------------- |
| - botUUID            | - language              |
|                      | - search                |
|                      | - searchInPersonalities |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/search/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "language=French&amp;search=search_value&amp;searchInPersonalities=true"
```

Body answer:

```
[]
```

Send an answer to a survey

| Mandatory parameters | Optional parameters       |
| -------------------- | ------------------------- |
| - botUUID            | - interactionSurveyAnswer |
| - contextUUID        |                           |
| - solutionUsed       |                           |
| - fields             |                           |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/survey/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**fields**=test_field&amp;interactionSurveyAnswer=true"
```

Body answer:

```
```

Retrieve survey configuration

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - language           |                     |
| - surveyId           |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/survey/configuration/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**language**=French&amp;**surveyId**=20f4ab33-eb28-47d7-850c-60e5c6a352b3"
```

Body answer:

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

Send interaction without context specification (start new context)

| Mandatory parameters | Optional parameters        |
| -------------------- | -------------------------- |
| - botUUID            | - userUrl                  |
| - userInput          | - alreadyCame              |
| - space              | - clientId                 |
| - language           | - os                       |
|                      | - browser                  |
|                      | - enableLanguageDetection  |
|                      | - contextType              |
|                      | - qualificationMode        |
|                      | - solutionUsed             |
|                      | - pureLiveChat             |
|                      | - extraParameters          |
|                      | - doNotRegisterInteraction |
|                      | - competency               |
|                      | - timestamp                |
|                      | - templateFormats          |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/talk/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**userInput**=test&amp;**space**=Defaut&amp;**language**=French&amp;userUrl=doyoudreamup.com&amp;alreadyCame=true&amp;clientId=jmanier&amp;os=Linux&amp;browser=Chrome&amp;enableLanguageDectection=true&amp;contextType=Web&amp;qualificationMode=true&amp;solutionUsed=ASSISTANT&amp;pureLiveChat=false&amp;extraParameters=extra_value&amp;doNotRegisterInteraction=true&amp;competency=marketing&amp;timestamp=24&amp;templateFormats=expert"
```

Body answer:

```
{"values":{"knowledgeId":168168,"typeResponse":"RE1VbmRlcnN0b29kUXVlc3Rpb24=","contextId":"NzlkNTBlOWYtNmU1ZC00MzBiLWE1ODUtZmIyYWFlZDNiMWJh","serverTime":1542038040852,"language":"ZnI=","botId":"ZWYwN2EzN2EtMmYzOC00NGYxLWEyYzQtZDJlNzFlN2M2ZDIw","text":"UXVlIHNvdWhhaXRlei12b3VzIHNhdm9pcsKgPzxici8+PGJyLz48YSBocmVmPSIjIiBjbGFzcz0icmV3b3JkIiBvbmNsaWNrPSJ0cnkge3Jld29yZCgnQ29tbWVudCB0ZXN0ZXIgbFwnYXNzaXN0YW50ID8nLHsmcXVvdDtsYXN0Y29uZGl0aW9uJnF1b3Q7OjE2ODg4MCwmcXVvdDt0eXBlJnF1b3Q7OiZxdW90O3JlZGlyZWN0aW9uX2tub3dsZWRnZSZxdW90O30pOyByZXR1cm4gZmFsc2U7fWNhdGNoKGUpe30iPkNvbW1lbnQgdGVzdGVyIGwnYXNzaXN0YW50wqA\/PC9hPjxici8+PGEgaHJlZj0iIyIgY2xhc3M9InJld29yZCIgb25jbGljaz0idHJ5IHtyZXdvcmQoJ0NvbW1lbnQgdXRpbGlzZXIgbGVzIGNvbnZlcnNhdGlvbnMgdGVzdHMgPycseyZxdW90O2xhc3Rjb25kaXRpb24mcXVvdDs6MTY4ODgwLCZxdW90O3R5cGUmcXVvdDs6JnF1b3Q7cmVkaXJlY3Rpb25fa25vd2xlZGdlJnF1b3Q7fSk7IHJldHVybiBmYWxzZTt9Y2F0Y2goZSl7fSI+Q29tbWVudCB1dGlsaXNlciBsZXMgY29udmVyc2F0aW9ucyB0ZXN0c8KgPzwvYT48YnIvPjxhIGhyZWY9IiMiIGNsYXNzPSJyZXdvcmQiIG9uY2xpY2s9InRyeSB7cmV3b3JkKCdDb21tZW50IHRlc3RlciBsZXMgdmFyaWFibGVzIGRlIGNvbnRleHRlID8nLHsmcXVvdDtsYXN0Y29uZGl0aW9uJnF1b3Q7OjE2ODg4MCwmcXVvdDt0eXBlJnF1b3Q7OiZxdW90O3JlZGlyZWN0aW9uX2tub3dsZWRnZSZxdW90O30pOyByZXR1cm4gZmFsc2U7fWNhdGNoKGUpe30iPkNvbW1lbnQgdGVzdGVyIGxlcyB2YXJpYWJsZXMgZGUgY29udGV4dGXCoD88L2E+","hasProfilePicture":false,"startLivechat":false,"keepPopinMinimized":false,"human":false,"askFeedback":true},"type":"talkResponse"}
```

Send interaction with specific context

| Mandatory parameters | Optional parameters        |
| -------------------- | -------------------------- |
| - botUUID            | - userUrl                  |
| - contextUUID        | - alreadyCame              |
| - userInput          | - clientId                 |
| - space              | - os                       |
| - language           | - browser                  |
|                      | - enableLanguageDetection  |
|                      | - contextType              |
|                      | - qualificationMode        |
|                      | - solutionUsed             |
|                      | - pureLiveChat             |
|                      | - extraParameters          |
|                      | - DoNotRegisterInteraction |
|                      | - competency               |
|                      | - timestamp                |
|                      | - templateFormats          |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/talk/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**/**e6a5ae08-703c-4ddd-9d57-fa07a8908f0d**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**userInput**=test&amp;**space**=Defaut&amp;**language**=French&amp;userUrl=doyoudreamup.com&amp;alreadyCame=true&amp;clientId=jmanier&amp;os=Linux&amp;browser=Chrome&amp;enableLanguageDectection=true&amp;contextType=Web&amp;qualificationMode=true&amp;solutionUsed=ASSISTANT&amp;pureLiveChat=false&amp;extraParameters=extra_value&amp;doNotRegisterInteraction=true&amp;competency=marketing&amp;timestamp=24&amp;templateFormats=expert"
```

Answer body:

```
{"values":{"knowledgeId":168168,"typeResponse":"RE1VbmRlcnN0b29kUXVlc3Rpb24=","contextId":"MzBiYTMyMjQtYzM0Mi00OTQ0LTg2NDAtMjRmODEwZGIyM2Iw","serverTime":1542039200149,"language":"ZnI=","botId":"ZWYwN2EzN2EtMmYzOC00NGYxLWEyYzQtZDJlNzFlN2M2ZDIw","text":"UXVlIHNvdWhhaXRlei12b3VzIHNhdm9pcsKgPzxici8+PGJyLz48YSBocmVmPSIjIiBjbGFzcz0icmV3b3JkIiBvbmNsaWNrPSJ0cnkge3Jld29yZCgnQ29tbWVudCB0ZXN0ZXIgbFwnYXNzaXN0YW50ID8nLHsmcXVvdDtsYXN0Y29uZGl0aW9uJnF1b3Q7OjE2ODg4MCwmcXVvdDt0eXBlJnF1b3Q7OiZxdW90O3JlZGlyZWN0aW9uX2tub3dsZWRnZSZxdW90O30pOyByZXR1cm4gZmFsc2U7fWNhdGNoKGUpe30iPkNvbW1lbnQgdGVzdGVyIGwnYXNzaXN0YW50wqA\/PC9hPjxici8+PGEgaHJlZj0iIyIgY2xhc3M9InJld29yZCIgb25jbGljaz0idHJ5IHtyZXdvcmQoJ0NvbW1lbnQgdXRpbGlzZXIgbGVzIGNvbnZlcnNhdGlvbnMgdGVzdHMgPycseyZxdW90O2xhc3Rjb25kaXRpb24mcXVvdDs6MTY4ODgwLCZxdW90O3R5cGUmcXVvdDs6JnF1b3Q7cmVkaXJlY3Rpb25fa25vd2xlZGdlJnF1b3Q7fSk7IHJldHVybiBmYWxzZTt9Y2F0Y2goZSl7fSI+Q29tbWVudCB1dGlsaXNlciBsZXMgY29udmVyc2F0aW9ucyB0ZXN0c8KgPzwvYT48YnIvPjxhIGhyZWY9IiMiIGNsYXNzPSJyZXdvcmQiIG9uY2xpY2s9InRyeSB7cmV3b3JkKCdDb21tZW50IHRlc3RlciBsZXMgdmFyaWFibGVzIGRlIGNvbnRleHRlID8nLHsmcXVvdDtsYXN0Y29uZGl0aW9uJnF1b3Q7OjE2ODg4MCwmcXVvdDt0eXBlJnF1b3Q7OiZxdW90O3JlZGlyZWN0aW9uX2tub3dsZWRnZSZxdW90O30pOyByZXR1cm4gZmFsc2U7fWNhdGNoKGUpe30iPkNvbW1lbnQgdGVzdGVyIGxlcyB2YXJpYWJsZXMgZGUgY29udGV4dGXCoD88L2E+","hasProfilePicture":false,"startLivechat":false,"keepPopinMinimized":false,"human":false,"askFeedback":true},"type":"talkResponse"}
```

Retrieve top used knowledge

| Mandatory parameters | Optional parameters  |
| -------------------- | -------------------- |
| - botUUID            | - includeTagChildren |
| - solutionUsed       | - qualificationMode  |
| - language           | - maxKnowledge       |
| - space              |                      |
| - period             |                      |
| - tag                |                      |

Note: you can also insert the tagID instead of the tag name (see details in parameter table).

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/topknowledge/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**solutionUsed**=ASSISTANT&amp;**language**=French&amp;**space**=Defaut&amp;**period**=period_value&amp;**tag**=Tag_value&amp;includeTagChildren=true&amp;qualificationMode=true&amp;maxKnowledge=5"
```

Body answer:

```
{"values":{"knowledgeArticles":"W3sicmV3b3JkIjoiQ29tbWVudCBjcsOpZXIgdW5lIGNvbm5haXNzYW5jZSA\/IiwicGF0aFRhZyI6IkNvbm5haXNzYW5jZXNcLzAxLiBDcsOpYXRpb24gZGUgY29ubmFpc3NhbmNlcyIsInVzYWdlIjotMS4wLCJpbnB1dENvbmRpdGlvbklkIjoyOTIxMX0seyJyZXdvcmQiOiJDb21tZW50IGNyw6llciB1biB0YWJsZWF1ID8iLCJwYXRoVGFnIjoiQ29ubmFpc3NhbmNlc1wvMDQuIFLDqXBvbnNlIMOgIHVuZSBxdWVzdGlvbiIsInVzYWdlIjotMS4wLCJpbnB1dENvbmRpdGlvbklkIjozMzg3Nn0seyJyZXdvcmQiOiJDb21tZW50IGNyw6llciB1bmUgbm91dmVsbGUgY29uZmlndXJhdGlvbiBwb3VyIG1vbiBjaGF0Ym90ID8iLCJwYXRoVGFnIjoiUHLDqWbDqXJlbmNlc1wvQ29uZmlndXJhdGlvbiBjaGF0Ym94IiwidXNhZ2UiOi0xLjAsImlucHV0Q29uZGl0aW9uSWQiOjM0NjA2fSx7InJld29yZCI6Ikd1aWRlcyBpbnRlcmFjdGlmcyIsInBhdGhUYWciOiJBcHBjdWVzIiwidXNhZ2UiOjIxLjAsImlucHV0Q29uZGl0aW9uSWQiOjMxODA4OX0seyJyZXdvcmQiOiJDcsOpYXRpb24gZCd1bmUgY29ubmFpc3NhbmNlIiwicGF0aFRhZyI6IkFwcGN1ZXMiLCJ1c2FnZSI6MTQuMCwiaW5wdXRDb25kaXRpb25JZCI6MzE4MDg3fV0=","serverTime":1542040024994,"tagName":"VGFnX3ZhbHVl"},"type":"topKnowledgeResponse"}
```

Send information about content typed in by user

| Mandatory settings | Optional settings |
| ------------------ | ----------------- |
| - botUUID          | - typing          |
| - contextUUID      |                   |
| - solutionUsed     |                   |
| - content          |                   |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/typing/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**content**=content_value&amp;typing=true"
```

Body answer:

```
{}
```

Insert of delete a context variable

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            |                     |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - name               |                     |
| - value              |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/variable/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**name**=test&amp;**value**=1"
```

Store a user visit

| Mandatory parameters | Optional parameters |
| -------------------- | ------------------- |
| - botUUID            | - qualificationMode |
| - contextUUID        |                     |
| - solutionUsed       |                     |
| - language           |                     |
| - space              |                     |

Curl request:

```
curl -X POST "https://app1.earth.doyoudreamup.com/servlet/api/chat/welcomecall/**ef07a37a-2f38-44f1-a2c4-d2e71e7c6d20**" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -d "**contextUuid**=e6a5ae08-703c-4ddd-9d57-fa07a8908f0d&amp;**solutionUsed**=ASSISTANT&amp;**language**=French&amp;**space**=Defaut&amp;**qualificationMode**=true"
```

Body answer:

```
/*logged*/
```

### Asynchronous dialog web service[​](https://dev.docs.dydu.ai/docs/Developers/API_reference/query-dialog-engine#asynchronous-dialog-web-service) <a href="#asynchronous-dialog-web-service" id="asynchronous-dialog-web-service"></a>

The asynchronous web service works on the principle of websockets.

The protocol to use in websockets is named **dyduchat**.

This mechanism is especially useful when the user talks with an operator because then, the operator does not have to wait for a user's question to give an answer. They can speak first or send several messages to the user.

![](https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2F2l3HL8KwOKcDDeH3IK9A%2Fimage.png?alt=media\&token=5e6147f6-8c66-46f6-88e9-73b885b31f4e)

#### Customer requests[​](https://dev.docs.dydu.ai/docs/Developers/API_reference/query-dialog-engine#customer-requests) <a href="#customer-requests" id="customer-requests"></a>

The client must send its requests in JSON format as described below:

***Request*** tal&#x6B;**\*\***

The format of the request *talk* is as follows:

![](https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FqR9hFGV9lfzrJNkKdDWz%2Fimage.png?alt=media\&token=06652f29-03ca-44f3-bde4-4a39f9381f99)

All field values ​​must be base64 encoded.

The parameters in the *parameters* field are the same as those defined for the REST web service from the synchronous mode.

***Requests*** feedBac&#x6B;**\*\***

As in synchronous mode, no feedback is expected for feedBack requests.

All field values must be base64 encoded.

The values of the fields are the same as those defined for the synchronous mode REST web service.

#### Server Requests[​](https://dev.docs.dydu.ai/docs/Developers/API_reference/query-dialog-engine#server-requests) <a href="#server-requests" id="server-requests"></a>

**Answer to display**

Requests sent by the server tell the client that a message has been issued by an automated bot or by a human operator.

They can be sent without the user having made a request.

![](https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FdIrilkOVtZpzWRqM26fk%2Fimage.png?alt=media\&token=3facc069-0387-44d3-b6f9-e04edbd3f7d0)

All parameters except *human* are exactly the same as for the Synchronous Mode REST web service.

The new *human* field indicates that the message is from a human operator if it is *true*.

**Notification**

Notifications are used to inform the user of some elements without replacing the last answer.

They can, for example, inform the user that the human operator is no longer connected.

![](https://264031769-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPMvi3Izk7dvjl9HitZpp%2Fuploads%2FgVf1lT8ZdA3Plzb7bFm4%2Fimage.png?alt=media\&token=f30d610d-55b5-4e73-b3f7-1d2b3f9bbb92)
