Skip to content

Commit

Permalink
fix(converse-api): proper filtering, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
slvnperron committed Feb 2, 2019
1 parent 2c790c1 commit 9551543
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
14 changes: 11 additions & 3 deletions docs/guide/docs/build/channels.md
Expand Up @@ -9,7 +9,7 @@ title: Messaging Channels

The JSON Channel is an easy way to integrate Botpress with any application or any other channels. This API will allow you to speak to your bot and get an answer synchronously.

#### How to uses
#### Usage (Public API)

`POST /api/v1/bots/{botId}/converse/{userId}` where **userId** is a unique string identifying a user that chats with your bot (**botId**).

Expand All @@ -22,14 +22,22 @@ The JSON Channel is an easy way to integrate Botpress with any application or an
}
```

#### Optionnal Data
#### Usage (Debug API)

You can include more data to your response by using the `?include=nlu,state` query params.
There's also a secured route (requires authentication to Botpress to consume this API). Using this route, you can include more data to your response by using the `include` query params separated by commas.

##### Example

```
POST /api/v1/bots/{botId}/converse/{userId}/secured?include=nlu,state,suggestions,decision
```

Possible options:

- **nlu**: The output of Botpress NLU
- **state**: The state object of the user conversation
- **suggestions**: The reply suggestions made by the modules
- **decision**: The final decision made by the Decision Engine

##### API Response

Expand Down
9 changes: 9 additions & 0 deletions src/bp/core/routers/bots/converse.ts
Expand Up @@ -56,10 +56,19 @@ export class ConverseRouter implements CustomRouter {
if (!parts.includes('nlu')) {
delete output.nlu
}

if (!parts.includes('state')) {
delete output.state
}

if (!parts.includes('suggestions')) {
delete output.suggestions
}

if (!parts.includes('decision')) {
delete output.decision
}

return output
}
}
Expand Up @@ -92,7 +92,7 @@ export default class EmulatorChat extends React.Component {
const res = await axios.post(
`${window.BOT_API_PATH}/converse/${this.state.userId}/secured`,
{ text },
{ params: { include: 'nlu,state' } }
{ params: { include: 'nlu,state,suggestions,decision' } }
)

const duration = Date.now() - sentAt
Expand Down

0 comments on commit 9551543

Please sign in to comment.