-
Notifications
You must be signed in to change notification settings - Fork 15
/
google-action.html
182 lines (168 loc) · 8.42 KB
/
google-action.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!--
node-red-contrib-google-action - A Node Red node to handle actions from Google Action
MIT License
Copyright (c) 2018 Dean Cording <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<script type="text/x-red" data-template-name="google-action in">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" >
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
<input type="text" id="node-input-topic">
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-plug"></i> Port</span></label>
<input id="node-input-port" type="text" placeholder="8081">
</div>
<div class="form-row">
<label for="node-input-url"><i class="fa fa-tag"></i> URL</span></label>
<input id="node-input-url" type="text" placeholder="/">
</div>
<div class="form-row">
<label for="node-input-key"><i class="fa fa-tag"></i> SSL Private Key File</span></label>
<input id="node-input-key" type="text" placeholder="/path/on/server/to/private.key">
</div>
<div class="form-row">
<label for="node-input-cert"><i class="fa fa-tag"></i> SSL Certificate File</span></label>
<input id="node-input-cert" type="text" placeholder="/path/on/server/to/certificate.crt">
</div>
</script>
<script type="text/x-red" data-help-name="google-action in">
<p>Creates an end-point for receiving requests from Google Actions.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>name <span class="property-type">string </span><dt>
<dd>name of node displayed in editor </dd>
<dt>topic <span class="property-type">string </span><dt>
<dd>topic applied to <code>msg</code> </dd>
<dt>port <span class="property-type"> integer</span><dt>
<dd>port number for server to listen on </dd>
<dt>url <span class="property-type"> string</span><dt>
<dd>url for server to listen on </dd>
<dt>SSL private key file <span class="property-type">filename </span><dt>
<dd>full path to SSL private key file on Node Red server</dd>
<dt>SSl certificate file <span class="property-type">filename </span><dt>
<dd>full pathname to SSL certificate file on Node Red server</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>conversationId<span class="property-type">string</span><dt>
<dd>A identifier for the conversation. If the flow asks the user a question, the response will
have the same identifier.<dd>
<dt>intent<span class="property-type">string</span><dt>
<dd>Indicates the intent of the conversation with the user.</dd>
<dt>userId<span class="property-type">string</span></dt>
<dd>A unique identifier for the user. If the user is registered and recognised then the user id
is consistent across conversations.</dd>
<dt>locale<span class="property-type">string</span></dt>
<dd>country and language code for the request</dd>
<dt>dialogState<span class="property-type">object</span></dt>
<dd>An object that can be used to store state information between turns of the conversation.</dd>
<dt>payload<span class="property-type">string</span></dt>
<dd>The raw text of the user's spoken or typed input.</dd>
</dl>
<h3>Details</h3>
<p>The node will listen for incoming action requests from Google Actions.</p>
<p>The main intents for requests are:
<ul>
<li>actions.intent.MAIN - Default entry point at start of conversation</li>
<li>actions.intent.TEXT - A turn of the conversation</li>
<li>actions.intent.CANCEL - The user has terminated the conversation</li>
</ul>
See <a href="https://developers.google.com/actions/reference/rest/intents">Google Actions Reference</a> for more information.</p>
<p><b>Note:</b> this node does not send any response to the request. The flow
must include an Google Action Response node to complete the request.</p>
</script>
<script type="text/x-red" data-template-name="google-action response">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
<div class="form-tips">The messages sent to this node must originate from a Google Action input node.</span></div>
</script>
<script type="text/x-red" data-help-name="google-action response">
<p>Sends responses back to requests received from a Google Action input node.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>conversationId<span class="property-type">string</span><dt>
<dd>A identifier for the conversation that this is a response for. If the flow asks the user a question, the response will have the same identifier.<dd>
<dt>dialogState<span class="property-type">object</span></dt>
<dd>An object that can be used to store state information between turns of the conversation.</dd>
<dt>payload <span class="property-type">string|array</span></dt>
<dd>The text of the response to be returned.</dd>
<dt>closeConversation<span class="property-type">boolean</span></dt>
<dd>If true, the converation will be terminated after this response. Otherwise the conversation will remain active and wait for further input from the user.</dd>
</dl>
<h3>Details</h3>
<p>Returns a response to an action request received from a Google Action Input node.</p>
<p>The response can be in plain text or marked up using
<a href="https://developers.google.com/actions/reference/ssml">SSML</a> for additional control of speech
output. An array of up to four messages can be provided if you are asking the user for input. The
first message is used as the prompt to the user for input. The second and third messages are used as
follow up prompts if no input is received. The fourth message is used to terminate the conversation.
If less than four messages are provided, default messages will be used.</p>
</script>
<script type="text/javascript">
(function() {
RED.nodes.registerType('google-action in',{
category: 'input',
color:"rgb(131, 231, 174)",
defaults: {
name: {value:""},
topic: {value:""},
port: {value:"8081",required:true, validate: RED.validators.number()},
url: {value:"/", required:true},
key: {value:"", requred:true},
cert: {value: "", required:true}
},
inputs:0,
outputs:1,
icon: "bridge.png",
label: function() {
if (this.name) {
return this.name;
} else {
return "Action";
}
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
RED.nodes.registerType('google-action response',{
category: 'output',
color:"rgb(131, 231, 174)",
defaults: {
name: {value:""}
},
inputs:1,
outputs:0,
align: "right",
icon: "bridge.png",
label: function() {
if (this.name) {
return this.name;
} else {
return "Response";
}
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
})();
</script>