Skip to content
Permalink
Browse files

Updated hosted docs

  • Loading branch information...
mishushakov committed Aug 4, 2019
1 parent 9354df3 commit b65fda3214fddf26f84c2c195631054b9c8a95dd
Showing with 345 additions and 9 deletions.
  1. +5 βˆ’5 README.md
  2. +1 βˆ’0 hosted/README.md
  3. +335 βˆ’0 hosted/api.md
  4. +2 βˆ’2 hosted/integrations.md
  5. +2 βˆ’2 hosted/usage.md
@@ -197,10 +197,10 @@ Content-Type: application/json
{
"session": "test",
"queryInput": {
"text": {
"text": "Hello",
"languageCode": "en"
}
"text": {
"text": "Hello",
"languageCode": "en"
}
}
}
```
@@ -391,7 +391,7 @@ ws.on('close', (code, error) => {
| Dialogflow Gateway (Enterprise Edition) | Ushakov | TBA | [https://dialogflow.cloud.ushakov.co](Homepage) | Self-hosted, premium support, API Extensions, free updates | No |
| Fulfillment Tester | Ushakov | Testing | [https://github.com/mishushakov/dialogflow-fulfillment-tester](Homepage) | For testing purposes only | No |

[Submit a PR](https://github.com/mishushakov/dialogflow-gateway-docs/pulls), if you want to add your implementation to the list!
[Submit your implementation](https://github.com/mishushakov/dialogflow-gateway-docs/pulls)

## Contact

@@ -4,6 +4,7 @@ This directory contains documentation of the hosted version of [Dialogflow Gatew

- [Installation](installation.md)
- [Configuration](configuration.md)
- [API](api.md)
- [Usage](usage.md)
- [Integrations](integrations.md)
- [FAQ](faq.md)
@@ -0,0 +1,335 @@
# Dialogflow Gateway by Ushakov (Hosted) API

## Contents

- [API](#api)
- [Response Codes](#response-codes)
- [Errors](#errors)
- [Endpoints](#endpoints)
- [Base Endpoint](#base-endpoint)
- [Base Endpoint Variables](#base-endpoint-variables)
- [Base Endpoint Example](#base-endpoint-example)
- [Requests](#requests)
- [Retrieving Agents](#retrieving-agents)
- [Request](#request)
- [Request Variables](#request-variables)
- [Response Body](#response-body)
- [Example Request](#example-request)
- [Example Response](#example-response)
- [Detecting Intents](#detecting-intents)
- [Request](#request-1)
- [Request Variables](#request-variables-1)
- [Request Body](#request-body)
- [Response Body](#response-body-1)
- [Example Request](#example-request-1)
- [Example Response](#example-response-1)
- [Realtime API](#realtime-api)
- [Close Codes](#close-codes)
- [Errors](#errors-1)
- [Endpoints](#endpoints)
- [Base Endpoint](#base-endpoint-1)
- [Base Endpoint Variables](#base-endpoint-variables-1)
- [Base Endpoint Example](#base-endpoint-example-1)
- [Requests](#requests-1)
- [Detecting Intents](#detecting-intents-1)
- [Request](#request-2)
- [Request Variables](#request-variables-2)
- [Request Body](#request-body-1)
- [Response Body](#response-body-2)
- [Example Request](#example-request-2)
- [Example Response](#example-response-2)
- [Contact](#contact)

## API

### Response Codes

| HTTP-Code | Reason |
|-----------|--------------------------------------------------------------------------------|
| 200 | Request was successful |
| 400 | The request body or session ID is invalid and/or missing |
| 403 | The deployment was blocked or the service account key is no longer valid |
| 404 | The deployment was not found |
| 500 | Internal server error |
| 503 | The service is unavailable |

### Errors

Example JSON response, containing error

```json
{"error": "Deployment was not found", "code": 404}
```

### Endpoints

#### Base Endpoint

```
https://<PROJECT_ID>.gateway.dialogflow.cloud.ushakov.co
```

#### Base Endpoint Variables

| Variable | Description |
|------------|------------------------------|
| PROJECT_ID | Required, Project Identifier |

#### Base Endpoint Example

```
https://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co
```

## Requests

#### Retrieving Agents

#### Request

```http
GET <BASE_ENDPOINT>
```

#### Request Variables

| Variable | Description |
|---------------|-----------------------------|
| BASE_ENDPOINT | Required, Endpoint of Agent |

#### Response Body

[Agent](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/projects.agent)

#### Example Request

```http
GET https://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co
```

#### Example Response

```json
{
"parent": "projects/dialogflow-web-v2",
"displayName": "DialogflowWebV2",
"defaultLanguageCode": "en",
"supportedLanguageCodes": [
"ru"
],
"timeZone": "Europe/Madrid",
"description": "This is a unofficial Progressive Web Application for Dialogflow V2, with support for rich-responses and amazing features you need to check out. Choose your language and send Hello to get started",
"avatarUri": "https://storage.googleapis.com/cloudprod-apiai/ce408f19-7966-487d-8614-f5b1f0474ba6_x.png",
"enableLogging": true,
"matchMode": "MATCH_MODE_HYBRID",
"classificationThreshold": 0.3
}
```

### Detecting Intents

#### Request

Using session id as path parameter

```http
POST <BASE_ENDPOINT>/<SESSION_ID>
```

Or skip the path parameter and put <SESSION_ID> in the request body (preferred)

```http
POST <BASE_ENDPOINT>
```

#### Request Variables

| Variable | Description |
|----------|-------------|
| BASE_ENDPOINT | Required, Endpoint of Agent |
| SESSION_ID | Required. The name of the session this query is sent to. It can be a random number or some type of user identifier. The length of the session ID must not exceed 36 bytes |

#### Request Body

[DetectIntentRequest](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/projects.agent.sessions/detectIntent#request-body)

#### Response Body

[DetectIntentResponse](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/DetectIntentResponse)

#### Example Request

```http
POST https://app-of-the-day-9a9f6.gateway.dialogflow.cloud.ushakov.co
Content-Type: application/json
{
"session": "test",
"queryInput": {
"text": {
"text": "Hello",
"languageCode": "en"
}
}
}
```

#### Example Response

```json
{
"responseId": "85c3d6bd-6f8c-4000-a1ec-fdd6f636b2e8",
"queryResult": {
"queryText": "Hello",
"action": "input.welcome",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Cannot display response in Dialogflow simulator. Please test on the Google Assistant simulator instead.",
"fulfillmentMessages": [...],
"webhookPayload": {...},
"intent": {
"name": "projects/app-of-the-day-9a9f6/agent/intents/1e00bd68-62f0-4b8e-9cdd-a81c19f73855",
"displayName": "Default Welcome Intent"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"end_conversation": true,
"webhook_latency_ms": 187
},
"languageCode": "en"
},
"webhookStatus": {
"message": "Webhook execution successful"
}
}
```

## Realtime API

Realtime API implements [Secure WebSocket](https://en.wikipedia.org/wiki/WebSocket) communication between Dialogflow Gateway and the clients

### Close Codes

| Code | Reason |
|-----------|----------------------------------------------------------------------------|
| 4400 | The request body or session ID is invalid and/or missing |
| 4403 | The deployment was blocked or the service account key is no longer valid |
| 4404 | The deployment was not found |
| 4500 | Internal server error |

### Errors

Example error:

```
4404 'Deployment was not found'
```

### Endpoints

#### Base Endpoint

```
wss://<PROJECT_ID>.gateway.dialogflow.cloud.ushakov.co
```

#### Base Endpoint Variables

| Variable | Description |
|------------|------------------------------|
| PROJECT_ID | Required, Project Identifier |

#### Base Endpoint Example

```
wss://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co
```

## Requests

### Detecting Intents

#### Request

```http
POST <BASE_ENDPOINT>
```

#### Request Variables

| Variable | Description |
|----------|-------------|
| BASE_ENDPOINT | Required, Endpoint of Agent |

#### Request Body

[DetectIntentRequest](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/projects.agent.sessions/detectIntent#request-body)

#### Response Body

[DetectIntentResponse](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/DetectIntentResponse)

#### Example Request

Note: The examples are in js

Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted)

```js
const WebSocket = require('ws')
const ws = new WebSocket('ws://app-of-the-day-9a9f6.gateway.dialogflow.cloud.ushakov.co')
ws.send(
JSON.stringify({
session: "123",
queryInput: {
text: {
text: "Hello",
languageCode: "en"
}
}
})
)
ws.on('message', data => {
console.log(data)
})
ws.on('close', (code, error) => {
console.log(code, error)
})
```

#### Example Response

```json
{
"responseId": "85c3d6bd-6f8c-4000-a1ec-fdd6f636b2e8",
"queryResult": {
"queryText": "Hello",
"action": "input.welcome",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Cannot display response in Dialogflow simulator. Please test on the Google Assistant simulator instead.",
"fulfillmentMessages": [...],
"webhookPayload": {...},
"intent": {
"name": "projects/app-of-the-day-9a9f6/agent/intents/1e00bd68-62f0-4b8e-9cdd-a81c19f73855",
"displayName": "Default Welcome Intent"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"end_conversation": true,
"webhook_latency_ms": 187
},
"languageCode": "en"
},
"webhookStatus": {
"message": "Webhook execution successful"
}
}
```

## Contact

If you have any questions/troubles, regarding the API, please [contact us](https://ushakov.co/#contact)
@@ -2,10 +2,10 @@

## First Party

- [Dialogflow Gateway API](./../README.md#api)
- [Dialogflow Gateway API](api.md#api)
![](./images/gatewayurl.png)

- [Dialogflow Gateway Realtime API](./../README.md#realtime-api)
- [Dialogflow Gateway Realtime API](api.md#realtime-api)
![](./images/gatewayurlrt.png)

- [Dialogflow for Web v2](https://github.com/mishushakov/dialogflow-web-v2)
@@ -1,6 +1,6 @@
# Dialogflow Gateway by Ushakov (Hosted) Usage

In this guide we will code our own CLI-Integration for Dialogflow using [Dialogflow Gateway API](./../README.md#api) and [Dialogflow Gateway Realtime API](./../README.md#realtime-api).
In this guide we will code our own CLI-Integration for Dialogflow using [Dialogflow Gateway API](api.md.md#api) and [Dialogflow Gateway Realtime API](api.md.md#realtime-api).

![](images/1*Sax2IOrqX6_09FPS-kqLdA.gif)

@@ -216,6 +216,6 @@ Your Agent will reply with Dialogflow Response, Webhook or Actions on Google Sim
ask() // <- Start the messages loop
```
3. Run test it!
3. Run it!

I hope you have learned some basics on how to easily create cool and stunning Dialogflow Integrations using Dialogflow Gateway APIs! Now is your turn to make some πŸ˜„

0 comments on commit b65fda3

Please sign in to comment.
You can’t perform that action at this time.