├── .eslintrc.json
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── agent.zip
├── agent
├── agent.json
├── entities
│ ├── letter.json
│ └── letter_entries_en.json
├── intents
│ ├── Fallback.json
│ ├── Guess Letter or Word.json
│ ├── Guess Letter or Word_usersays_en.json
│ ├── Instructions.json
│ ├── Instructions_usersays_en.json
│ ├── Play Again.json
│ ├── Play Again_usersays_en.json
│ ├── Quit.json
│ ├── Quit_usersays_en.json
│ ├── Start Game.json
│ ├── Start Game_usersays_en.json
│ └── Welcome.json
└── package.json
├── firebase.json
├── functions
├── index.js
├── package.json
└── util
│ └── dictionary.js
└── public
├── 404.html
├── assets
├── background.png
├── fonts
│ └── bitmap
│ │ ├── google-sans-font.png
│ │ └── google-sans-font.xml
├── snow-pal.json
├── snow-pal.png
├── snow-pal.sketch
├── win-lose.json
├── win-lose.png
├── win-lose.sketch
├── you-lose.png
└── you-win.png
├── css
└── main.css
├── index.html
└── js
├── assistant.js
├── game.js
└── log.js
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parserOptions": {
3 | "ecmaVersion": 2018,
4 | "sourceType": "script"
5 | },
6 | "extends": ["google"],
7 | "env": {
8 | "node": true
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | functions/node_modules
2 | .firebaserc
3 | package-lock.json
4 | yarn.lock
5 | .firebase
6 | *.log
7 | .DS_Store
8 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we
6 | have to jump a couple of legal hurdles.
7 |
8 | Please fill out either the individual or corporate Contributor License Agreement
9 | (CLA).
10 |
11 | * If you are an individual writing original source code and you're sure you
12 | own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual).
13 | * If you work for a company that wants to allow you to contribute your work,
14 | then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate).
15 |
16 | Follow either of the two links above to access the appropriate CLA and
17 | instructions for how to sign and return it. Once we receive it, we'll be able to
18 | accept your pull requests.
19 |
20 | ## Contributing A Patch
21 |
22 | 1. Submit an issue describing your proposed change to the repo in question.
23 | 1. The repo owner will respond to your issue promptly.
24 | 1. If your proposed change is accepted, and you haven't already done so, sign a
25 | Contributor License Agreement (see details above).
26 | 1. Fork the desired repo, develop and test your code changes.
27 | 1. Ensure that your code adheres to the existing style in the sample to which
28 | you are contributing. Refer to the
29 | [Google Cloud Platform Samples Style Guide](https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the
30 | recommended coding standards for this organization.
31 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
32 | 1. Submit a pull request.
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Actions on Google: Snow Pal Interactive Canvas Sample
2 |
3 | *:warning: Warning: Conversational Actions will be deprecated on June 13, 2023. For more information,
4 | see [Conversational Actions Sunset](https://goo.gle/ca-sunset).*
5 |
6 |
7 | This sample demonstrates how to create an [Interactive Canvas](https://developers.google.com/assistant/interactivecanvas/) experience using Actions on Google for the Google Assistant. It uses the [Node.js client library](https://github.com/actions-on-google/actions-on-google-nodejs) and is deployed on [Cloud Functions for Firebase](https://firebase.google.com/docs/functions/) and [Firebase Hosting](https://firebase.google.com/docs/hosting).
8 |
9 | :warning: This code sample was built using Dialogflow. We now recommend using [Actions Builder or the Actions SDK](https://developers.google.com/assistant/conversational/overview) to develop, test, and deploy Conversational Actions.
10 |
11 | ## Setup Instructions
12 | ### Prerequisites
13 | 1. Node.js and NPM
14 | + We recommend installing using [nvm for Linux/Mac](https://github.com/creationix/nvm) and [nvm-windows for Windows](https://github.com/coreybutler/nvm-windows)
15 | 1. Install the [Firebase CLI](https://developers.google.com/assistant/actions/dialogflow/deploy-fulfillment)
16 | + We recommend using MAJOR version `6` with `6.5.0` or above, `npm install -g firebase-tools@^6.5.0`
17 | + Run `firebase login` with your Google account
18 |
19 | ### Configuration
20 | #### Actions Console
21 | 1. From the [Actions on Google Console](https://console.actions.google.com/), add a new project > **Create Project** > under **More options** > **Conversational**
22 | 1. Click **Deploy** in the top menu. Then, click **Additional information**.
23 | 1. Under **Category**, select **Games & fun**
24 | 1. Under **Interactive Canvas** *Do your Actions use Interactive Canvas?*, check **Yes**
25 | 1. Click **Develop** in the top menu. Then, click **Actions** > **Add Your First Action** > **Custom intent** > **BUILD** (this will bring you to the Dialogflow console) > Select language and time zone > **CREATE**.
26 | 1. In the Dialogflow console, go to **Settings** ⚙ > **Export and Import** > **Restore from zip** using the `agent.zip` in this sample's directory.
27 |
28 |
29 | #### Firebase Deployment
30 | 1. On your local machine, in the `functions` directory, run `npm install`
31 | 1. Run `firebase deploy --project {PROJECT_ID}` to deploy the function and hosting
32 | + To find your **Project ID**: In [Dialogflow console](https://console.dialogflow.com/) under **Settings** ⚙ > **General** tab > **Project ID**.
33 |
34 | #### Dialogflow Console
35 | 1. Return to the [Dialogflow Console](https://console.dialogflow.com) > select **Fulfillment** > **Enable** Webhook > Set **URL** to the **Function URL** that was returned after the deploy command > **SAVE**.
36 | ```
37 | Function URL (dialogflowFirebaseFulfillment): https://${REGION}-${PROJECT_ID}.cloudfunctions.net/dialogflowFirebaseFulfillment
38 | ```
39 | 1. From the left navigation menu, click **Integrations** > **Integration Settings** under Google Assistant > Enable **Auto-preview changes** > **Test** to open the Actions on Google simulator then say or type `Talk to my test app`.
40 |
41 | ### Running this Sample
42 | + You can test your Action on any Google Assistant-enabled device on which the Assistant is signed into the same account used to create this project. Just say or type, “OK Google, talk to my test app”.
43 | + You can also use the Actions on Google Console simulator to test most features and preview on-device behavior.
44 |
45 | ## References & Issues
46 | + Questions? Go to [StackOverflow](https://stackoverflow.com/questions/tagged/actions-on-google), [Assistant Developer Community on Reddit](https://www.reddit.com/r/GoogleAssistantDev/) or [Support](https://developers.google.com/assistant/support).
47 | + For bugs, please report an issue on Github.
48 | + Actions on Google [Interactive Canvas Documentation](https://developers.google.com/assistant/interactivecanvas/)
49 | + Actions on Google [Documentation](https://developers.google.com/assistant)
50 | + Actions on Google [Codelabs](https://codelabs.developers.google.com/?cat=Assistant)
51 | + [Webhook Boilerplate Template](https://github.com/actions-on-google/dialogflow-webhook-boilerplate-nodejs) for Actions on Google
52 |
53 | ## Make Contributions
54 | Please read and follow the steps in the [CONTRIBUTING.md](CONTRIBUTING.md).
55 |
56 | ## License
57 | See [LICENSE](LICENSE).
58 |
59 | ## Terms
60 | Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the [Google APIs Terms of Service](https://developers.google.com/terms/).
61 |
--------------------------------------------------------------------------------
/agent.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/actions-on-google/dialogflow-snowman-nodejs/a102fee2810b60745481e2b8d7da467cf525706e/agent.zip
--------------------------------------------------------------------------------
/agent/agent.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "",
3 | "language": "en",
4 | "shortDescription": "",
5 | "examples": "",
6 | "linkToDocs": "",
7 | "disableInteractionLogs": false,
8 | "disableStackdriverLogs": true,
9 | "googleAssistant": {
10 | "googleAssistantCompatible": true,
11 | "project": "",
12 | "welcomeIntentSignInRequired": false,
13 | "startIntents": [],
14 | "systemIntents": [],
15 | "endIntentIds": [
16 | "0a44ec19-583e-4a55-9507-a7a3141280a2"
17 | ],
18 | "oAuthLinking": {
19 | "required": false,
20 | "providerId": "",
21 | "authorizationUrl": "",
22 | "tokenUrl": "",
23 | "scopes": "",
24 | "privacyPolicyUrl": "",
25 | "grantType": "AUTH_CODE_GRANT"
26 | },
27 | "voiceType": "MALE_1",
28 | "capabilities": [],
29 | "env": "",
30 | "protocolVersion": "V2",
31 | "autoPreviewEnabled": true,
32 | "isDeviceAgent": false
33 | },
34 | "defaultTimezone": "America/Los_Angeles",
35 | "webhook": {
36 | "url": "https://us-central1-PROJECT_ID.cloudfunctions.net/dialogflowFirebaseFulfillment",
37 | "username": "",
38 | "headers": {
39 | "": ""
40 | },
41 | "available": true,
42 | "useForDomains": false,
43 | "cloudFunctionsEnabled": false,
44 | "cloudFunctionsInitialized": false
45 | },
46 | "isPrivate": true,
47 | "customClassifierMode": "use.after",
48 | "mlMinConfidence": 0.3,
49 | "supportedLanguages": [],
50 | "onePlatformApiVersion": "v2",
51 | "analyzeQueryTextSentiment": false,
52 | "enabledKnowledgeBaseNames": [],
53 | "knowledgeServiceConfidenceAdjustment": -0.4,
54 | "dialogBuilderMode": false,
55 | "baseActionPackagesUrl": ""
56 | }
--------------------------------------------------------------------------------
/agent/entities/letter.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "c6b738cb-4cbc-47e9-8a3c-6b8fc72fabc3",
3 | "name": "letter",
4 | "isOverridable": true,
5 | "isEnum": false,
6 | "isRegexp": false,
7 | "automatedExpansion": false,
8 | "allowFuzzyExtraction": false
9 | }
--------------------------------------------------------------------------------
/agent/entities/letter_entries_en.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "value": "a",
4 | "synonyms": [
5 | "a"
6 | ]
7 | },
8 | {
9 | "value": "b",
10 | "synonyms": [
11 | "b"
12 | ]
13 | },
14 | {
15 | "value": "c",
16 | "synonyms": [
17 | "c"
18 | ]
19 | },
20 | {
21 | "value": "d",
22 | "synonyms": [
23 | "d"
24 | ]
25 | },
26 | {
27 | "value": "e",
28 | "synonyms": [
29 | "e"
30 | ]
31 | },
32 | {
33 | "value": "f",
34 | "synonyms": [
35 | "f"
36 | ]
37 | },
38 | {
39 | "value": "g",
40 | "synonyms": [
41 | "g"
42 | ]
43 | },
44 | {
45 | "value": "h",
46 | "synonyms": [
47 | "h"
48 | ]
49 | },
50 | {
51 | "value": "i",
52 | "synonyms": [
53 | "i"
54 | ]
55 | },
56 | {
57 | "value": "j",
58 | "synonyms": [
59 | "j"
60 | ]
61 | },
62 | {
63 | "value": "k",
64 | "synonyms": [
65 | "k"
66 | ]
67 | },
68 | {
69 | "value": "l",
70 | "synonyms": [
71 | "l"
72 | ]
73 | },
74 | {
75 | "value": "m",
76 | "synonyms": [
77 | "m"
78 | ]
79 | },
80 | {
81 | "value": "n",
82 | "synonyms": [
83 | "n"
84 | ]
85 | },
86 | {
87 | "value": "o",
88 | "synonyms": [
89 | "o"
90 | ]
91 | },
92 | {
93 | "value": "p",
94 | "synonyms": [
95 | "p"
96 | ]
97 | },
98 | {
99 | "value": "q",
100 | "synonyms": [
101 | "q"
102 | ]
103 | },
104 | {
105 | "value": "r",
106 | "synonyms": [
107 | "r"
108 | ]
109 | },
110 | {
111 | "value": "s",
112 | "synonyms": [
113 | "s"
114 | ]
115 | },
116 | {
117 | "value": "t",
118 | "synonyms": [
119 | "t"
120 | ]
121 | },
122 | {
123 | "value": "u",
124 | "synonyms": [
125 | "u"
126 | ]
127 | },
128 | {
129 | "value": "v",
130 | "synonyms": [
131 | "v"
132 | ]
133 | },
134 | {
135 | "value": "w",
136 | "synonyms": [
137 | "w"
138 | ]
139 | },
140 | {
141 | "value": "x",
142 | "synonyms": [
143 | "x"
144 | ]
145 | },
146 | {
147 | "value": "y",
148 | "synonyms": [
149 | "y"
150 | ]
151 | },
152 | {
153 | "value": "z",
154 | "synonyms": [
155 | "z"
156 | ]
157 | }
158 | ]
--------------------------------------------------------------------------------
/agent/intents/Fallback.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "ef09eaa7-72b3-4fe0-8551-84096acca188",
3 | "name": "Fallback",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [],
11 | "messages": [],
12 | "defaultResponsePlatforms": {},
13 | "speech": []
14 | }
15 | ],
16 | "priority": 500000,
17 | "webhookUsed": true,
18 | "webhookForSlotFilling": false,
19 | "fallbackIntent": true,
20 | "events": [],
21 | "conditionalResponses": [],
22 | "condition": "",
23 | "conditionalFollowupEvents": []
24 | }
--------------------------------------------------------------------------------
/agent/intents/Guess Letter or Word.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "bd490bf1-d6b8-4e8e-90d5-8a059ca12474",
3 | "name": "Guess Letter or Word",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [
11 | {
12 | "id": "3268c5a2-d5be-417b-be63-0f3faf551414",
13 | "required": false,
14 | "dataType": "@sys.any",
15 | "name": "letterOrWord",
16 | "value": "$letterOrWord",
17 | "promptMessages": [],
18 | "noMatchPromptMessages": [],
19 | "noInputPromptMessages": [],
20 | "outputDialogContexts": [],
21 | "isList": false
22 | }
23 | ],
24 | "messages": [
25 | {
26 | "type": 0,
27 | "lang": "en",
28 | "condition": "",
29 | "speech": []
30 | }
31 | ],
32 | "defaultResponsePlatforms": {},
33 | "speech": []
34 | }
35 | ],
36 | "priority": 500000,
37 | "webhookUsed": true,
38 | "webhookForSlotFilling": false,
39 | "fallbackIntent": false,
40 | "events": [],
41 | "conditionalResponses": [],
42 | "condition": "",
43 | "conditionalFollowupEvents": []
44 | }
--------------------------------------------------------------------------------
/agent/intents/Guess Letter or Word_usersays_en.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "43c07458-1ed8-4327-a42d-7901022afd0f",
4 | "data": [
5 | {
6 | "text": "France",
7 | "alias": "letterOrWord",
8 | "meta": "@sys.any",
9 | "userDefined": true
10 | }
11 | ],
12 | "isTemplate": false,
13 | "count": 0,
14 | "updated": 0
15 | },
16 | {
17 | "id": "aff6f0ec-ad01-4e4d-9fd8-4e573f6c4bb4",
18 | "data": [
19 | {
20 | "text": "it\u0027s ",
21 | "userDefined": false
22 | },
23 | {
24 | "text": "google",
25 | "alias": "letterOrWord",
26 | "meta": "@sys.any",
27 | "userDefined": true
28 | }
29 | ],
30 | "isTemplate": false,
31 | "count": 0,
32 | "updated": 0
33 | },
34 | {
35 | "id": "170afa3c-97f6-47f5-8b7a-043be9cd5ad4",
36 | "data": [
37 | {
38 | "text": "I guess it\u0027s ",
39 | "userDefined": false
40 | },
41 | {
42 | "text": "house",
43 | "alias": "letterOrWord",
44 | "meta": "@sys.any",
45 | "userDefined": true
46 | }
47 | ],
48 | "isTemplate": false,
49 | "count": 0,
50 | "updated": 0
51 | },
52 | {
53 | "id": "e835b7e5-4469-4764-884c-17b4989f9d6c",
54 | "data": [
55 | {
56 | "text": "it\u0027s ",
57 | "userDefined": false
58 | },
59 | {
60 | "text": "sombrero",
61 | "alias": "letterOrWord",
62 | "meta": "@sys.any",
63 | "userDefined": true
64 | }
65 | ],
66 | "isTemplate": false,
67 | "count": 0,
68 | "updated": 0
69 | },
70 | {
71 | "id": "dcd5523a-2bc6-4072-8819-362e2e5b0120",
72 | "data": [
73 | {
74 | "text": "it\u0027s the word ",
75 | "userDefined": false
76 | },
77 | {
78 | "text": "apartment",
79 | "alias": "letterOrWord",
80 | "meta": "@sys.any",
81 | "userDefined": true
82 | }
83 | ],
84 | "isTemplate": false,
85 | "count": 0,
86 | "updated": 0
87 | },
88 | {
89 | "id": "07b6a3ed-d0a3-41a3-b7ef-6836e50b042b",
90 | "data": [
91 | {
92 | "text": "what about ",
93 | "userDefined": false
94 | },
95 | {
96 | "text": "panfleto",
97 | "alias": "letterOrWord",
98 | "meta": "@sys.any",
99 | "userDefined": true
100 | }
101 | ],
102 | "isTemplate": false,
103 | "count": 0,
104 | "updated": 0
105 | },
106 | {
107 | "id": "a0ecb8e7-8dd5-46d0-8e41-a72cc5e96b53",
108 | "data": [
109 | {
110 | "text": "try ",
111 | "userDefined": false
112 | },
113 | {
114 | "text": "Colombia",
115 | "alias": "letterOrWord",
116 | "meta": "@sys.any",
117 | "userDefined": true
118 | }
119 | ],
120 | "isTemplate": false,
121 | "count": 0,
122 | "updated": 0
123 | },
124 | {
125 | "id": "ba2e53de-e5f5-4ed4-b3fa-80da0dc0d62d",
126 | "data": [
127 | {
128 | "text": "the word is ",
129 | "userDefined": false
130 | },
131 | {
132 | "text": "home",
133 | "alias": "letterOrWord",
134 | "meta": "@sys.any",
135 | "userDefined": true
136 | }
137 | ],
138 | "isTemplate": false,
139 | "count": 0,
140 | "updated": 0
141 | },
142 | {
143 | "id": "29928c04-dd88-4f6c-af19-1803fd6e7ffe",
144 | "data": [
145 | {
146 | "text": "i guess ",
147 | "userDefined": false
148 | },
149 | {
150 | "text": "z",
151 | "alias": "letterOrWord",
152 | "meta": "@sys.any",
153 | "userDefined": true
154 | }
155 | ],
156 | "isTemplate": false,
157 | "count": 0,
158 | "updated": 0
159 | },
160 | {
161 | "id": "87c2f068-2fad-419b-a1a4-fd70fdfca53e",
162 | "data": [
163 | {
164 | "text": "letter ",
165 | "userDefined": false
166 | },
167 | {
168 | "text": "a",
169 | "alias": "letterOrWord",
170 | "meta": "@sys.any",
171 | "userDefined": true
172 | }
173 | ],
174 | "isTemplate": false,
175 | "count": 0,
176 | "updated": 0
177 | }
178 | ]
--------------------------------------------------------------------------------
/agent/intents/Instructions.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "42c877a7-4b2c-4dc4-a039-86cc175f8b03",
3 | "name": "Instructions",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [],
11 | "messages": [],
12 | "defaultResponsePlatforms": {},
13 | "speech": []
14 | }
15 | ],
16 | "priority": 500000,
17 | "webhookUsed": true,
18 | "webhookForSlotFilling": false,
19 | "fallbackIntent": false,
20 | "events": [],
21 | "conditionalResponses": [],
22 | "condition": "",
23 | "conditionalFollowupEvents": []
24 | }
--------------------------------------------------------------------------------
/agent/intents/Instructions_usersays_en.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "2c8f8fb0-8c9b-49ac-bbc0-35cc002c713e",
4 | "data": [
5 | {
6 | "text": "help",
7 | "userDefined": false
8 | }
9 | ],
10 | "isTemplate": false,
11 | "count": 0,
12 | "updated": 0
13 | },
14 | {
15 | "id": "47e61ef2-01a2-4f4e-b9c8-f8023140bafb",
16 | "data": [
17 | {
18 | "text": "ask for help",
19 | "userDefined": false
20 | }
21 | ],
22 | "isTemplate": false,
23 | "count": 0,
24 | "updated": 0
25 | },
26 | {
27 | "id": "2de0503b-18d9-4a27-9ba2-ef38544dbf25",
28 | "data": [
29 | {
30 | "text": "what do you want me to do?",
31 | "userDefined": false
32 | }
33 | ],
34 | "isTemplate": false,
35 | "count": 0,
36 | "updated": 0
37 | },
38 | {
39 | "id": "7178eef2-323b-4973-aa85-206528b2d082",
40 | "data": [
41 | {
42 | "text": "what are the instructions?",
43 | "userDefined": false
44 | }
45 | ],
46 | "isTemplate": false,
47 | "count": 0,
48 | "updated": 0
49 | },
50 | {
51 | "id": "1db72cf0-7c89-4e73-bb74-9ab7abf3132b",
52 | "data": [
53 | {
54 | "text": "instructions",
55 | "userDefined": false
56 | }
57 | ],
58 | "isTemplate": false,
59 | "count": 0,
60 | "updated": 0
61 | }
62 | ]
--------------------------------------------------------------------------------
/agent/intents/Play Again.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "f49138fb-ea3d-4d16-803d-89122fad5525",
3 | "name": "Play Again",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [],
11 | "messages": [
12 | {
13 | "type": 0,
14 | "lang": "en",
15 | "condition": "",
16 | "speech": []
17 | }
18 | ],
19 | "defaultResponsePlatforms": {},
20 | "speech": []
21 | }
22 | ],
23 | "priority": 500000,
24 | "webhookUsed": true,
25 | "webhookForSlotFilling": false,
26 | "fallbackIntent": false,
27 | "events": [],
28 | "conditionalResponses": [],
29 | "condition": "",
30 | "conditionalFollowupEvents": []
31 | }
--------------------------------------------------------------------------------
/agent/intents/Play Again_usersays_en.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "37fd528e-8b53-4117-b98c-c9259e45d46d",
4 | "data": [
5 | {
6 | "text": "play another game",
7 | "userDefined": false
8 | }
9 | ],
10 | "isTemplate": false,
11 | "count": 0,
12 | "updated": 0
13 | },
14 | {
15 | "id": "b875b4eb-7067-4abf-b767-9c6565b3a000",
16 | "data": [
17 | {
18 | "text": "another word",
19 | "userDefined": false
20 | }
21 | ],
22 | "isTemplate": false,
23 | "count": 0,
24 | "updated": 0
25 | },
26 | {
27 | "id": "64b5c96a-2f53-448c-9841-be0974b975e4",
28 | "data": [
29 | {
30 | "text": "another one",
31 | "userDefined": false
32 | }
33 | ],
34 | "isTemplate": false,
35 | "count": 0,
36 | "updated": 0
37 | },
38 | {
39 | "id": "818643e1-4b6a-47ad-ab4e-13c9c25ccae7",
40 | "data": [
41 | {
42 | "text": "restart",
43 | "userDefined": false
44 | }
45 | ],
46 | "isTemplate": false,
47 | "count": 0,
48 | "updated": 0
49 | },
50 | {
51 | "id": "b21845c8-3012-45e3-ae17-d50f5b6f6922",
52 | "data": [
53 | {
54 | "text": "play again",
55 | "userDefined": false
56 | }
57 | ],
58 | "isTemplate": false,
59 | "count": 0,
60 | "updated": 0
61 | }
62 | ]
--------------------------------------------------------------------------------
/agent/intents/Quit.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "0a44ec19-583e-4a55-9507-a7a3141280a2",
3 | "name": "Quit",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [],
11 | "messages": [
12 | {
13 | "type": 0,
14 | "lang": "en",
15 | "condition": "",
16 | "speech": []
17 | }
18 | ],
19 | "defaultResponsePlatforms": {},
20 | "speech": []
21 | }
22 | ],
23 | "priority": 500000,
24 | "webhookUsed": false,
25 | "webhookForSlotFilling": false,
26 | "fallbackIntent": false,
27 | "events": [],
28 | "conditionalResponses": [],
29 | "condition": "",
30 | "conditionalFollowupEvents": []
31 | }
--------------------------------------------------------------------------------
/agent/intents/Quit_usersays_en.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "0ec1ea7a-2c96-4451-9f4b-b05c4a04db60",
4 | "data": [
5 | {
6 | "text": "no",
7 | "userDefined": false
8 | }
9 | ],
10 | "isTemplate": false,
11 | "count": 0,
12 | "updated": 0
13 | },
14 | {
15 | "id": "424f4e7a-2d49-4e98-9a42-e3add9af9f2c",
16 | "data": [
17 | {
18 | "text": "quit game",
19 | "userDefined": false
20 | }
21 | ],
22 | "isTemplate": false,
23 | "count": 0,
24 | "updated": 0
25 | },
26 | {
27 | "id": "e39906ba-fb02-4c53-953f-9a7594a15950",
28 | "data": [
29 | {
30 | "text": "goodbye",
31 | "userDefined": false
32 | }
33 | ],
34 | "isTemplate": false,
35 | "count": 0,
36 | "updated": 0
37 | },
38 | {
39 | "id": "b63a7f10-1bfe-44f1-ae24-a6d005535e5b",
40 | "data": [
41 | {
42 | "text": "I\u0027m done",
43 | "userDefined": false
44 | }
45 | ],
46 | "isTemplate": false,
47 | "count": 0,
48 | "updated": 0
49 | },
50 | {
51 | "id": "ce021760-9e84-4fec-a9af-c9d3711cb6ec",
52 | "data": [
53 | {
54 | "text": "quit",
55 | "userDefined": false
56 | }
57 | ],
58 | "isTemplate": false,
59 | "count": 0,
60 | "updated": 0
61 | }
62 | ]
--------------------------------------------------------------------------------
/agent/intents/Start Game.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "f2eb67aa-2d88-4cab-98b4-778363a72f8a",
3 | "name": "Start Game",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [],
11 | "messages": [
12 | {
13 | "type": 0,
14 | "lang": "en",
15 | "condition": "",
16 | "speech": []
17 | }
18 | ],
19 | "defaultResponsePlatforms": {},
20 | "speech": []
21 | }
22 | ],
23 | "priority": 500000,
24 | "webhookUsed": true,
25 | "webhookForSlotFilling": false,
26 | "fallbackIntent": false,
27 | "events": [],
28 | "conditionalResponses": [],
29 | "condition": "",
30 | "conditionalFollowupEvents": []
31 | }
--------------------------------------------------------------------------------
/agent/intents/Start Game_usersays_en.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "f75d4426-0be3-45ee-8f5f-6e3ce35680d8",
4 | "data": [
5 | {
6 | "text": "yes",
7 | "userDefined": false
8 | }
9 | ],
10 | "isTemplate": false,
11 | "count": 0,
12 | "updated": 0
13 | }
14 | ]
--------------------------------------------------------------------------------
/agent/intents/Welcome.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "df333e1d-586b-4bc2-b3a2-b77296a4a6e5",
3 | "name": "Welcome",
4 | "auto": true,
5 | "contexts": [],
6 | "responses": [
7 | {
8 | "resetContexts": false,
9 | "affectedContexts": [],
10 | "parameters": [],
11 | "messages": [],
12 | "defaultResponsePlatforms": {},
13 | "speech": []
14 | }
15 | ],
16 | "priority": 500000,
17 | "webhookUsed": true,
18 | "webhookForSlotFilling": false,
19 | "fallbackIntent": false,
20 | "events": [
21 | {
22 | "name": "WELCOME"
23 | },
24 | {
25 | "name": "actions_intent_PLAY_GAME"
26 | }
27 | ],
28 | "conditionalResponses": [],
29 | "condition": "",
30 | "conditionalFollowupEvents": []
31 | }
--------------------------------------------------------------------------------
/agent/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0"
3 | }
--------------------------------------------------------------------------------
/firebase.json:
--------------------------------------------------------------------------------
1 | {
2 | "hosting": {
3 | "public": "public",
4 | "headers": [
5 | {
6 | "source": "**",
7 | "headers": [
8 | {
9 | "key": "Cache-Control",
10 | "value": "no-cache,no-store,must-revalidate"
11 | },
12 | {
13 | "key": "Access-Control-Allow-Origin",
14 | "value": "*"
15 | },
16 | {
17 | "key": "Access-Control-Expose-Headers",
18 | "value": "ETag"
19 | }
20 | ]
21 | }
22 | ]
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/functions/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | 'use strict';
18 |
19 | const functions = require('firebase-functions');
20 | const {dialogflow, HtmlResponse} = require('actions-on-google');
21 | const Dictionary = require('./util/dictionary.js');
22 |
23 | const firebaseConfig = JSON.parse(process.env.FIREBASE_CONFIG);
24 | const app = dialogflow({debug: true});
25 |
26 | const MAX_INCORRECT_GUESSES = 5;
27 |
28 | const INSTRUCTIONS =
29 | `Try to figure out the word by guessing letters that you think are in the word. ` +
30 | `Figure out the word before Snow Pal melts to win the game! After 5 ` +
31 | `incorrect guesses, Snow Pal melts and the game is over. ` +
32 | `If you know the word, you can say, for instance, “The word is penguin.” ` +
33 | `You can try another word, or ask for help.`;
34 |
35 | const PLAY_AGAIN_INSTRUCTIONS = `Would you like to play again or quit?`;
36 |
37 | const WELCOME_BACK_GREETINGS = [
38 | `Hey, you're back to Snow Pal!`,
39 | `Welcome back to Snow Pal!`,
40 | `I'm glad you're back to play!`,
41 | `Hey there, you made it! Let's play Snow Pal.`
42 | ];
43 |
44 | const START_GAME_RESPONSES = [
45 | `Try guessing a letter in the word, or guess the entire word if you think you know what it is.`,
46 | `Try guessing a letter in the word, or guess the entire word if you're feeling confident!`,
47 | `Try guessing a letter in the word or guessing the word.`,
48 | `Try guessing a letter in the word or guessing the word.`
49 | ];
50 |
51 | const RIGHT_RESPONSES = ['Right on! Good guess.', 'Splendid!',
52 | 'Wonderful! Keep going!', 'Easy peasy lemon squeezy!', 'Easy as pie!'];
53 |
54 | const WRONG_RESPONSES = [`Whoops, that letter isn’t in the word. Try again!`,
55 | 'Try again!', 'You can do this!', 'Incorrect. Keep on trying!'];
56 |
57 | const WIN_RESPONSES = ['Congratulations and BRAVO!',
58 | 'You did it! So proud of you!',
59 | 'Well done!', 'I’m happy for you!',
60 | 'This is awesome! You’re awesome! Way to go!'];
61 |
62 | const DICTIONARY = new Dictionary();
63 |
64 | /**
65 | * Pick a random item from an array. This is to make
66 | * responses more conversational.
67 | *
68 | * @param {array} array representing a list of elements.
69 | * @return {string} item from an array.
70 | */
71 | const randomArrayItem = (array) => {
72 | return array[Math.floor(Math.random() * array.length)];
73 | };
74 |
75 | /**
76 | * Updates the string to display to the user with the guessed
77 | * letter or word.
78 | *
79 | * @param {string} letterOrWord the letter or word used to update the display string.
80 | */
81 | const updateWordToDisplay = (conv, letterOrWord) => {
82 | if(letterOrWord === conv.data.correctWord) {
83 | conv.data.wordToDisplay = conv.data.correctWord;
84 | } else {
85 | conv.data.correctWord.split('').forEach((character, index) => {
86 | if (letterOrWord === character) {
87 | conv.data.wordToDisplay = conv.data.wordToDisplay.substr(0, index) +
88 | letterOrWord + conv.data.wordToDisplay.substr(index + letterOrWord.length)
89 | }
90 | });
91 | }
92 | }
93 |
94 | app.intent('Welcome', (conv) => {
95 | if (conv.user.last.seen) {
96 | conv.ask(`${randomArrayItem(WELCOME_BACK_GREETINGS)} Would you like to start playing the game?`);
97 | } else {
98 | conv.ask(`Welcome to Snow Pal! Would you like to start playing the game?`);
99 | }
100 | conv.ask(new HtmlResponse({
101 | url: `https://${firebaseConfig.projectId}.firebaseapp.com`,
102 | }));
103 | });
104 |
105 | app.intent('Start Game', (conv) => {
106 | if (conv.user.last.seen) {
107 | conv.ask(randomArrayItem(START_GAME_RESPONSES));
108 | } else {
109 | conv.ask(`${INSTRUCTIONS}`);
110 | }
111 | conv.data.incorrectGuesses = 0;
112 | // Generate new word to guess
113 | conv.data.correctWord = DICTIONARY.getWord().toLocaleUpperCase();
114 | conv.data.wordToDisplay = '_'.repeat(conv.data.correctWord.length);
115 | conv.ask(new HtmlResponse({
116 | data: {
117 | state: 'NEW_GAME',
118 | wordToDisplay: conv.data.wordToDisplay
119 | },
120 | }));
121 | });
122 |
123 | app.intent('Fallback', (conv) => {
124 | conv.ask(`I don’t understand. Try guessing a letter!`);
125 | conv.ask(new HtmlResponse());
126 | });
127 |
128 | /**
129 | * Guess a letter or word from Snow Pal.
130 | *
131 | * @param {conv} standard Actions on Google conversation object.
132 | * @param {string} letterOrWord from A-Z.
133 | */
134 | app.intent('Guess Letter or Word', (conv, {letterOrWord}) => {
135 | conv.ask(`
The specified file was not found on this website. Please check the URL for mistakes and try again.
29 |This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html
file in your project's configured public
directory.