Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Updated samples, unzipped sample agents, fixed peer dependency issue
Browse files Browse the repository at this point in the history
Change-Id: I89f5a92d5df08aa7bf3485c199154a5a1377d1f7
  • Loading branch information
Matt Carroll committed Jun 4, 2018
1 parent d6eabd5 commit d8396fa
Show file tree
Hide file tree
Showing 48 changed files with 1,060 additions and 45 deletions.
33 changes: 22 additions & 11 deletions docs/WebhookClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ Dialogflow's simulator
* [.query](#WebhookClient+query) : <code>string</code>
* [.locale](#WebhookClient+locale) : <code>string</code>
* [.session](#WebhookClient+session) : <code>string</code>
* [.add(response)](#WebhookClient+add)
* [.consoleMessages](#WebhookClient+consoleMessages) : [<code>Array.&lt;RichResponse&gt;</code>](#RichResponse)
* [.add(responses)](#WebhookClient+add)
* [.addResponse_(response)](#WebhookClient+addResponse_)
* [.handleRequest(handler)](#WebhookClient+handleRequest) ⇒ <code>Promise</code>
* [.getConsoleMessages()](#WebhookClient+getConsoleMessages) ⇒ <code>Array.&lt;RichResponses&gt;</code>
* [.setContext(context)](#WebhookClient+setContext)[<code>WebhookClient</code>](#WebhookClient)
* [.clearOutgoingContexts()](#WebhookClient+clearOutgoingContexts)[<code>WebhookClient</code>](#WebhookClient)
* [.clearContext(context)](#WebhookClient+clearContext)[<code>WebhookClient</code>](#WebhookClient)
Expand Down Expand Up @@ -109,10 +110,28 @@ Dialogflow input contexts included in the request or null if no value
Dialogflow v2 API only
https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/WebhookRequest#FIELDS.session

**Kind**: instance property of [<code>WebhookClient</code>](#WebhookClient)
<a name="WebhookClient+consoleMessages"></a>

### webhookClient.consoleMessages : [<code>Array.&lt;RichResponse&gt;</code>](#RichResponse)
List of messages defined in Dialogflow's console for the matched intent
https://dialogflow.com/docs/rich-messages

**Kind**: instance property of [<code>WebhookClient</code>](#WebhookClient)
<a name="WebhookClient+add"></a>

### webhookClient.add(response)
### webhookClient.add(responses)
Add a response or list of responses to be sent to Dialogflow

**Kind**: instance method of [<code>WebhookClient</code>](#WebhookClient)

| Param | Type | Description |
| --- | --- | --- |
| responses | [<code>RichResponse</code>](#RichResponse) \| <code>string</code> \| [<code>Array.&lt;RichResponse&gt;</code>](#RichResponse) \| <code>Array.&lt;string&gt;</code> | (list) or single responses |

<a name="WebhookClient+addResponse_"></a>

### webhookClient.addResponse_(response)
Add a response to be sent to Dialogflow

**Kind**: instance method of [<code>WebhookClient</code>](#WebhookClient)
Expand All @@ -133,14 +152,6 @@ Each handler must be a function callback.
| --- | --- | --- |
| handler | <code>Map</code> \| <code>requestCallback</code> | map of Dialogflow action name to handler function or function to handle all requests (regardless of Dialogflow action). |

<a name="WebhookClient+getConsoleMessages"></a>

### webhookClient.getConsoleMessages() ⇒ <code>Array.&lt;RichResponses&gt;</code>
Get a list of responses defined in Dialogflow's console
for the matched intent
https://dialogflow.com/docs/rich-messages

**Kind**: instance method of [<code>WebhookClient</code>](#WebhookClient)
<a name="WebhookClient+setContext"></a>

### webhookClient.setContext(context) ⇒ [<code>WebhookClient</code>](#WebhookClient)
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dialogflow-fulfillment",
"description": "Dialogflow Fulfillment Library for Node.js",
"main": "src/dialogflow-fulfillment.js",
"version": "0.4.0",
"version": "0.4.1",
"license": "Apache-2.0",
"author": "Google Inc.",
"directories": {
Expand Down Expand Up @@ -37,11 +37,10 @@
"fulfillment"
],
"dependencies": {
"actions-on-google": "^2.1.2",
"debug": "^3.1.0"
},
"peerDependencies": {
"actions-on-google": "^2.0.1"
"actions-on-google": "^2.1.3"
},
"devDependencies": {
"ava": "^0.24.0",
Expand Down
9 changes: 5 additions & 4 deletions samples/actions-on-google/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ Click on the **Add to Dialogflow** button below and follow the prompts to create
[![Dialogflow Fullfillment: Actions on Google](https://storage.googleapis.com/dialogflow-oneclick/deploy.svg "Dialogflow Fullfillment: Actions on Google")](https://console.dialogflow.com/api-client/oneclick?templateUrl=https%3A%2F%2Fstorage.googleapis.com%2Fdialogflow-oneclick%2Factions-on-google-agent.zip&agentName=ActionsOnGoogleSample)

### Option 2: Dialogflow Inline Editor
1. [Sign up for or sign into Dialogflow](https://console.dialogflow.com/api-client/#/login)
1. Create a Dialogflow agent
1. [Sign up for or sign into Dialogflow](https://console.dialogflow.com/api-client/#/login) and [create a agent](https://dialogflow.com/docs/agents#create_an_agent)
1. Go to your agent's settings and [Restore from zip](https://dialogflow.com/docs/agents#export_and_import) using the `dialogflow-agent.zip` in this directory (Note: this will overwrite your existing agent)
1. [Enable the Cloud Function for Firebase inline editor](https://dialogflow.com/docs/fulfillment#cloud_functions_for_firebase)
1. Copy this code in `functions/index.js` the `index.js` file in the Dialogflow Cloud Function for Firebase inline editor.
1. Add `"dialogflow-fulfillment": "^0.4.0"` and `"actions-on-google": "^2.1.2"` to the `package.json` file's `dependencies` object in the Dialogflow Cloud Function for Firebase inline editor.
1. Add `"dialogflow-fulfillment": "^0.4.1"` and `"actions-on-google": "^2.1.3"` to the `package.json` file's `dependencies` object in the Dialogflow Cloud Function for Firebase inline editor.
1. Click `Deploy`

### Option 3: Firebase CLI
1. Create a Dialogflow agent
1. [Sign up for or sign into Dialogflow](https://console.dialogflow.com/api-client/#/login) and [create a agent](https://dialogflow.com/docs/agents#create_an_agent)
1. Go to your agent's settings and [Restore from zip](https://dialogflow.com/docs/agents#export_and_import) using the `dialogflow-agent.zip` in this directory (Note: this will overwrite your existing agent)
1. `cd` to the `functions` directory
1. Run `npm install`
1. Install the Firebase CLI by running `npm install -g firebase-tools`
Expand Down
Binary file not shown.
Binary file added samples/actions-on-google/dialogflow-agent.zip
Binary file not shown.
42 changes: 42 additions & 0 deletions samples/actions-on-google/dialogflow-agent/agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"description": "",
"language": "en",
"disableInteractionLogs": false,
"disableStackdriverLogs": true,
"googleAssistant": {
"googleAssistantCompatible": true,
"project": "libsample-advanced",
"welcomeIntentSignInRequired": false,
"startIntents": [],
"systemIntents": [],
"endIntentIds": [
"736b2be9-7526-4f76-91ca-e16f46ea2cca",
"6e9eae14-ec0e-4925-8506-96adab96eee4"
],
"oAuthLinking": {
"required": false,
"grantType": "AUTH_CODE_GRANT"
},
"voiceType": "MALE_1",
"capabilities": [],
"protocolVersion": "V2",
"autoPreviewEnabled": true,
"isDeviceAgent": false
},
"defaultTimezone": "America/Los_Angeles",
"webhook": {
"url": "https://us-central1-actionsontransactions.cloudfunctions.net/dialogflowFirebaseFulfillment",
"headers": {
"": ""
},
"available": true,
"useForDomains": false,
"cloudFunctionsEnabled": true,
"cloudFunctionsInitialized": true
},
"isPrivate": true,
"customClassifierMode": "use.after",
"mlMinConfidence": 0.3,
"supportedLanguages": [],
"onePlatformApiVersion": "v2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"id": "6e9eae14-ec0e-4925-8506-96adab96eee4",
"name": "Action on Google List Select",
"auto": true,
"contexts": [],
"responses": [
{
"resetContexts": false,
"affectedContexts": [],
"parameters": [],
"messages": [
{
"type": "simple_response",
"platform": "google",
"lang": "en",
"textToSpeech": "You selected an item from a list or carousel with the key \"#actions_intent_OPTION.OPTION\""
}
],
"defaultResponsePlatforms": {
"google": false
},
"speech": []
}
],
"priority": 500000,
"webhookUsed": false,
"webhookForSlotFilling": false,
"lastUpdate": 1528133199,
"fallbackIntent": false,
"events": [
{
"name": "actions_intent_OPTION"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "a574dd15-59da-46e7-a17f-a621902a5bc7",
"name": "Default Fallback Intent",
"auto": true,
"contexts": [],
"responses": [
{
"resetContexts": false,
"action": "input.unknown",
"affectedContexts": [],
"parameters": [],
"messages": [
{
"type": 0,
"lang": "en",
"speech": [
"I didn\u0027t get that. Can you say it again?",
"I missed what you said. Say it again?",
"Sorry, could you say that again?",
"Sorry, can you say that again?",
"Can you say that again?",
"Sorry, I didn\u0027t get that.",
"Sorry, what was that?",
"One more time?",
"What was that?",
"Say that again?",
"I didn\u0027t get that.",
"I missed that."
]
}
],
"defaultResponsePlatforms": {},
"speech": []
}
],
"priority": 500000,
"webhookUsed": false,
"webhookForSlotFilling": false,
"fallbackIntent": true,
"events": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"id": "d4299d80-7da4-4fd2-a7b7-477ffb7a5df9",
"name": "Default Welcome Intent",
"auto": true,
"contexts": [],
"responses": [
{
"resetContexts": false,
"action": "input.welcome",
"affectedContexts": [],
"parameters": [],
"messages": [
{
"type": 0,
"lang": "en",
"speech": [
"Hi!",
"Hello!",
"Good day!",
"Greetings!"
]
}
],
"defaultResponsePlatforms": {},
"speech": []
}
],
"priority": 500000,
"webhookUsed": false,
"webhookForSlotFilling": false,
"fallbackIntent": false,
"events": [
{
"name": "WELCOME"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"id": "8ea5901d-817c-4514-8d00-5f8619e4f26e",
"name": "Other Intent",
"auto": true,
"contexts": [],
"responses": [
{
"resetContexts": false,
"affectedContexts": [],
"parameters": [],
"messages": [
{
"type": 0,
"lang": "en",
"speech": []
}
],
"defaultResponsePlatforms": {},
"speech": []
}
],
"priority": 500000,
"webhookUsed": true,
"webhookForSlotFilling": false,
"lastUpdate": 1528132560,
"fallbackIntent": false,
"events": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"id": "262b5c54-aed4-4ad1-8a6f-424cf0c644df",
"data": [
{
"text": "other intent",
"userDefined": false
}
],
"isTemplate": false,
"count": 0,
"updated": 1528132560
}
]
3 changes: 3 additions & 0 deletions samples/actions-on-google/dialogflow-agent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.0.0"
}
10 changes: 5 additions & 5 deletions samples/actions-on-google/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"firebase-admin": "^4.2.1",
"firebase-functions": "^0.5.7",
"dialogflow-fulfillment": "^0.4.0",
"actions-on-google": "^2.1.2"
"firebase-admin": "^5.12.1",
"firebase-functions": "^1.0.3",
"actions-on-google": "^2.1.3",
"dialogflow-fulfillment": "0.4.1"
}
}
}
8 changes: 4 additions & 4 deletions samples/multi-lang-and-locale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ Click on the **Add to Dialogflow** button below and follow the prompts to create
[![Multi-locale](https://storage.googleapis.com/dialogflow-oneclick/deploy.svg "Multi-locale")](https://console.dialogflow.com/api-client/oneclick?templateUrl=https%3A%2F%2Fstorage.googleapis.com%2Fdialogflow-oneclick%2Fmultilocale-agent.zip&agentName=MultilocaleSample)

### Option 2: Dialogflow Inline Editor
1. [Sign up for or sign into Dialogflow](https://console.dialogflow.com/api-client/#/login)
1. Create a Dialogflow agent
1. [Sign up for or sign into Dialogflow](https://console.dialogflow.com/api-client/#/login) and [create a agent](https://dialogflow.com/docs/agents#create_an_agent)
1. Go to your agent's settings and [Restore from zip](https://dialogflow.com/docs/agents#export_and_import) using the `dialogflow-agent.zip` in this directory (Note: this will overwrite your existing agent)
1. [Enable the Cloud Function for Firebase inline editor](https://dialogflow.com/docs/fulfillment#cloud_functions_for_firebase)
1. Change the name of the function in `functions/index.js` from `dialogflowFulfillmentMultiLocale` to `dialogflowFirebaseFulfillment`
1. Copy this code in `functions/index.js` the `index.js` file in the Dialogflow Cloud Function for Firebase inline editor.
1. Add `"dialogflow-fulfillment": "^0.4.0"` to the `package.json` file's `dependencies` object in the Dialogflow Cloud Function for Firebase inline editor.
1. Click `Deploy`

### Option 3: Firebase CLI
1. Create a Dialogflow agent
1. Go to your agent's settings and [Restore from zip](https://dialogflow.com/docs/agents#export_and_import) using the `multilocaleAgent.zip` in this directory (Note: this will overwrite your existing agent)
1. [Sign up for or sign into Dialogflow](https://console.dialogflow.com/api-client/#/login) and [create a agent](https://dialogflow.com/docs/agents#create_an_agent)
1. Go to your agent's settings and [Restore from zip](https://dialogflow.com/docs/agents#export_and_import) using the `dialogflow-agent.zip` in this directory (Note: this will overwrite your existing agent)
1. `cd` to the `functions` directory
1. Run `npm install`
1. Install the Firebase CLI by running `npm install -g firebase-tools`
Expand Down
39 changes: 39 additions & 0 deletions samples/multi-lang-and-locale/dialogflow-agent/agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"description": "",
"language": "en",
"disableInteractionLogs": false,
"googleAssistant": {
"googleAssistantCompatible": true,
"project": "libsample-multilangandlocale",
"welcomeIntentSignInRequired": false,
"startIntents": [],
"systemIntents": [],
"endIntentIds": [],
"oAuthLinking": {
"required": false,
"grantType": "AUTH_CODE_GRANT"
},
"voiceType": "MALE_1",
"capabilities": [],
"protocolVersion": "V2",
"autoPreviewEnabled": true
},
"defaultTimezone": "America/Los_Angeles",
"webhook": {
"url": "https://us-central1-libsample-advanced.cloudfunctions.net/dialogflowFirebaseFulfillment",
"headers": {
"": ""
},
"available": true,
"useForDomains": false,
"cloudFunctionsEnabled": true,
"cloudFunctionsInitialized": true
},
"isPrivate": true,
"customClassifierMode": "use.after",
"mlMinConfidence": 0.3,
"supportedLanguages": [
"fr"
],
"onePlatformApiVersion": "v2"
}

0 comments on commit d8396fa

Please sign in to comment.