Skip to content

Commit d0c301e

Browse files
committed
Add Assistant ID Check
1 parent 99d56df commit d0c301e

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

services/assistant/v2.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
</div>
5252

5353
<div class="form-row">
54-
<label for="node-input-assistantid"><i class="fa fa-tag"></i> Assitant ID</label>
55-
<input type="text" id="node-input-assistantid" placeholder="Assistant ID">
54+
<label for="node-input-assistant_id"><i class="fa fa-tag"></i> Assitant ID</label>
55+
<input type="text" id="node-input-assistant_id" placeholder="Assistant ID">
5656
</div>
5757

5858
<div class="form-row">
@@ -85,10 +85,9 @@
8585
<label for="node-input-multisession" style="width: 70%;"> Multiple Sessions</label>
8686
</div>
8787

88-
8988
<div class="form-tips" id="assistantv2-form-tips">
90-
<strong>Note:</strong> When using multiple sessions, <code>msg.params.session</code>
91-
must be set.<br>
89+
<strong>Note:</strong> When using multiple sessions, and <code>msg.params.session</code>
90+
is not set then a new session id is generated. <br>
9291
See info box for details.
9392
</div>
9493
</script>
@@ -164,7 +163,7 @@
164163
name: { value: '' },
165164
'default-endpoint' : {value: true},
166165
'service-endpoint' : {value: 'https://gateway.watsonplatform.net/assistant/api'},
167-
assitantid: {value: ''},
166+
assistant_id: {value: ''},
168167
debug: {value: false},
169168
restart: {value: false},
170169
returncontext: {value: true},

services/assistant/v2.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,22 @@ module.exports = function(RED) {
7777
return Promise.resolve();
7878
}
7979

80+
function idCheck(msg, config) {
81+
if (!config.assistant_id && !(msg.params && msg.params.assistant_id)) {
82+
return Promise.reject('Missing assistant_id. Check node documentation.');
83+
}
84+
return Promise.resolve();
85+
}
86+
8087
this.on('input', function(msg) {
8188
node.status({});
8289

8390
var creds = setCredentials(msg);
8491

8592
credentialCheck(creds.username, creds.password, creds.apikey)
93+
.then(function(){
94+
return idCheck(msg, config);
95+
})
8696
.then(function(){
8797
msg.payload = 'No functionality yet';
8898
return Promise.resolve();

0 commit comments

Comments
 (0)