Skip to content

Commit 2e846d2

Browse files
committed
* Fixed a bug causing multiple messages to get rejected by the live servers.
* Updated LKG build and package.json version.
1 parent 45ad121 commit 2e846d2

File tree

4 files changed

+39
-116
lines changed

4 files changed

+39
-116
lines changed

Node/lib/botbuilder.d.ts

Lines changed: 16 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,12 @@ export interface IDialogResult<T> {
305305
export interface IPromptOptions {
306306
/**
307307
* Optional retry prompt to send if the users response isn't understood. Default is to just
308-
* reprompt with the configured [defaultRetryPrompt](http://docs.botframework.com/sdkreference/nodejs/interfaces/_botbuilder_d_.ipromptsoptions.html#defaultretryprompt) plus the original prompt. Note that if the original
309-
* prompt is an _IMessage_ the default behaviour is to simply re-send the original prompt.
308+
* reprompt with the configured [defaultRetryPrompt](http://docs.botframework.com/sdkreference/nodejs/interfaces/_botbuilder_d_.ipromptsoptions.html#defaultretryprompt)
309+
* plus the original prompt.
310+
*
311+
* Note that if the original prompt is an _IMessage_ the retry prompt will be sent as a seperate
312+
* message followed by the original message. If the retryPrompt is also an _IMessage_ it will
313+
* instead be sent in place of the original message.
310314
* * _{string}_ - Initial message to send the user.
311315
* * _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
312316
* * _{IMessage}_ - Initial message to send the user. Message can contain attachments.
@@ -367,6 +371,9 @@ export interface IPromptChoiceResult extends IPromptResult<IFindMatchResult> { }
367371
/** Strongly typed Time Prompt Result. */
368372
export interface IPromptTimeResult extends IPromptResult<IEntity> { }
369373

374+
/** Strongly typed Attachment Prompt Result. */
375+
export interface IPromptAttachmentResult extends IPromptResult<IAttachment[]> { }
376+
370377
/** Plugin for recognizing prompt responses recieved by a user. */
371378
export interface IPromptRecognizer {
372379
/**
@@ -412,40 +419,6 @@ export interface IPromptRecognizerArgs {
412419
export interface IPromptsOptions {
413420
/** Replaces the default recognizer (SimplePromptRecognizer) used to recognize prompt replies. */
414421
recognizer?: IPromptRecognizer
415-
416-
/** The default retry prompt to use. The default value is "I didn't understand." */
417-
defaultRetryPrompt?: string;
418-
}
419-
420-
/** Context information passed to field related handlers. */
421-
export interface IFieldConext {
422-
userData: any;
423-
form: any;
424-
field: string;
425-
}
426-
427-
/**
428-
* Handler that gets called anytime a field is about to invoke a prompt.
429-
*/
430-
export interface IFieldPromptHandler {
431-
/**
432-
* @param context Contextual information related to the current field.
433-
* @param next Function to call to continue execution of the prompt.
434-
* Passing _true_ for __skip__ will cause the current field to be skipped.
435-
*/
436-
(context: IFieldConext, next: (skip: boolean) => void): void;
437-
}
438-
439-
/** Options passed to form fields. */
440-
export interface IFieldOptions extends IPromptOptions {
441-
/**
442-
* Called anytime a given field is about to invoke the prompt. This function lets the
443-
* developer progromatically determine if a prompt should be skipped or not.
444-
*
445-
* The handler can also manipulate the forms current values. For instance a fields value
446-
* could be pulled from context.userData if not already specified on the form.
447-
*/
448-
onPrompt?: IFieldPromptHandler;
449422
}
450423

451424
/** A recognized intent. */
@@ -1149,9 +1122,9 @@ export class Message implements IMessage {
11491122

11501123
/**
11511124
* Selects a prompt at random.
1152-
* @param prompts Array of prompts to choose from.
1125+
* @param prompts Array of prompts to choose from. When prompts is type _string_ the prompt will simply be returned unmodified.
11531126
*/
1154-
static randomPrompt(prompts: string[]): string;
1127+
static randomPrompt(prompts: string|string[]): string;
11551128

11561129
/**
11571130
* Combines an array of prompts into a single localized prompt and then optionally fills the
@@ -1389,84 +1362,17 @@ export class Prompts extends Dialog {
13891362
* @param options Optional parameters to control the behaviour of the prompt.
13901363
*/
13911364
static time(session: Session, prompt: string|string[]|IMessage, options?: IPromptOptions): void;
1392-
}
13931365

1394-
/**
1395-
*
1396-
*/
1397-
export class Fields {
13981366
/**
1399-
* Captures from the user a raw string of text and saves it to a field on a form.
1400-
* @param field Name of the field to save the users response to.
1401-
* @param prompt
1402-
* * __prompt:__ _{string}_ - Initial message to send the user.
1403-
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1404-
* @param options Optional parameters to control the behaviour of the field.
1405-
*/
1406-
static text(field: string, prompt: string|string[], options?: IFieldOptions): IDialogWaterfallStep;
1407-
1408-
/**
1409-
* Prompts the user to enter a number and saves it to a field on a form.
1410-
* @param field Name of the field to save the users response to.
1411-
* @param prompt
1412-
* * __prompt:__ _{string}_ - Initial message to send the user.
1413-
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1414-
* @param options Optional parameters to control the behaviour of the field.
1415-
*/
1416-
static number(field: string, prompt: string|string[], options?: IFieldOptions): IDialogWaterfallStep;
1417-
1418-
/**
1419-
* Prompts the user to enter a boolean yes/no response and saves their answer to a field on a form.
1420-
* @param field Name of the field to save the users response to.
1421-
* @param prompt
1422-
* * __prompt:__ _{string}_ - Initial message to send the user.
1423-
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1424-
* @param options Optional parameters to control the behaviour of the field.
1425-
*/
1426-
static confirm(field: string, prompt: string|string[], options?: IFieldOptions): IDialogWaterfallStep;
1427-
1428-
/**
1429-
* Prompts the user to choose from a list of options and saves their selection to a field on a form.
1430-
* @param field Name of the field to save the users response to.
1431-
* @param prompt
1432-
* * __prompt:__ _{string}_ - Initial message to send the user.
1433-
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1434-
* @param choices
1435-
* * __choices:__ _{string}_ - List of choices as a pipe ('|') delimted string.
1436-
* * __choices:__ _{Object}_ - List of choices expressed as an Object map. The objects field names will be used to build the list of values.
1437-
* * __choices:__ _{string[]}_ - List of choices as an array of strings.
1438-
* @param options Optional parameters to control the behaviour of the field.
1439-
*/
1440-
static choice(field: string, prompt: string|string[], choices: string|Object|string[], options?: IFieldOptions): IDialogWaterfallStep;
1441-
1442-
/**
1443-
* Prompts the user to enter a time saves it to a field on a form as a timestamp.
1444-
* @param field Name of the field to save the users response to.
1367+
* Prompts the user to upload a file attachment.
1368+
* @param session Session object for the current conversation.
14451369
* @param prompt
14461370
* * __prompt:__ _{string}_ - Initial message to send the user.
14471371
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1448-
* @param options Optional parameters to control the behaviour of the field.
1449-
*/
1450-
static time(field: string, prompt: string|string[], options?: IPromptOptions): IDialogWaterfallStep;
1451-
1452-
/**
1453-
* Finalizes the form by saving the response from the last prompt and then passes the completed
1454-
* form to the next step of the waterfall for processing.
1455-
*/
1456-
static endForm(): IDialogWaterfallStep;
1457-
1458-
/**
1459-
* Finalizes the form by saving the response from the last prompt and then returns the completed
1460-
* form to the parent dialog by calling [endDialog()](http://docs.botframework.com/sdkreference/nodejs/classes/_botbuilder_d_.session.html#enddialog).
1461-
*/
1462-
static returnForm(): IDialogWaterfallStep;
1463-
1464-
/**
1465-
* Handler for IFieldOptions.onPrompt that will copy a default value from Session.userData if
1466-
* a field is empty. The default value must be in a property with the same name as the field.
1467-
* If successfully copied the prompt will be skipped.
1372+
* * __prompt:__ _{IMessage}_ - Initial message to send the user. Message can contain attachments.
1373+
* @param options Optional parameters to control the behaviour of the prompt.
14681374
*/
1469-
static onPromptUseDefault(): IFieldPromptHandler
1375+
static attachment(session: Session, prompt: string|string[]|IMessage, options?: IPromptOptions): void;
14701376
}
14711377

14721378
/**

Node/lib/bots/BotConnectorBot.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,30 @@ var BotConnectorBot = (function (_super) {
169169
reply.channelMessageId = ses.message.channelMessageId;
170170
reply.participants = ses.message.participants;
171171
reply.totalParticipants = ses.message.totalParticipants;
172+
if (!reply.language && ses.message.language) {
173+
reply.language = ses.message.language;
174+
}
172175
_this.emit('reply', reply);
173-
post(_this.options, endpoint, '/bot/v1.0/messages', reply, function (err) {
176+
post(_this.options, endpoint, '/bot/v1.0/messages', reply, function (err, response) {
174177
if (err) {
175178
_this.emit('error', err);
176179
}
180+
else if (response.statusCode >= 400) {
181+
console.error(response.statusMessage);
182+
}
177183
});
178184
}
179185
else {
180186
reply.from = ses.message.from;
181187
reply.to = ses.message.to;
182188
_this.emit('send', reply);
183-
post(_this.options, endpoint, '/bot/v1.0/messages', reply, function (err) {
189+
post(_this.options, endpoint, '/bot/v1.0/messages', reply, function (err, response) {
184190
if (err) {
185191
_this.emit('error', err);
186192
}
193+
else if (response.statusCode >= 400) {
194+
console.error(response.statusMessage);
195+
}
187196
});
188197
}
189198
});

Node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "botbuilder",
33
"author": "Microsoft Corp.",
44
"description": "Bot Builder is a dialog system for building rich bots on virtually any platform.",
5-
"version": "0.11.0",
5+
"version": "0.11.1",
66
"license": "MIT",
77
"keywords": [
88
"botbuilder",

Node/src/bots/BotConnectorBot.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import request = require('request');
3939
import storage = require('../storage/Storage');
4040
import bcStorage = require('../storage/BotConnectorStorage');
4141
import uuid = require('node-uuid');
42+
import http = require('http');
4243

4344
export interface IBotConnectorOptions {
4445
endpoint?: string;
@@ -313,20 +314,27 @@ export class BotConnectorBot extends collection.DialogCollection {
313314
reply.channelMessageId = ses.message.channelMessageId;
314315
reply.participants = ses.message.participants;
315316
reply.totalParticipants = ses.message.totalParticipants;
317+
if (!reply.language && ses.message.language) {
318+
reply.language = ses.message.language;
319+
}
316320
this.emit('reply', reply);
317-
post(this.options, endpoint, '/bot/v1.0/messages', reply, (err) => {
321+
post(this.options, endpoint, '/bot/v1.0/messages', reply, (err, response) => {
318322
if (err) {
319323
this.emit('error', err);
324+
} else if (response.statusCode >= 400) {
325+
console.error(response.statusMessage);
320326
}
321327
});
322328
} else {
323329
// Start a new conversation
324330
reply.from = ses.message.from;
325331
reply.to = ses.message.to;
326332
this.emit('send', reply);
327-
post(this.options, endpoint, '/bot/v1.0/messages', reply, (err) => {
333+
post(this.options, endpoint, '/bot/v1.0/messages', reply, (err, response) => {
328334
if (err) {
329335
this.emit('error', err);
336+
} else if (response.statusCode >= 400) {
337+
console.error(response.statusMessage);
330338
}
331339
});
332340
}
@@ -463,7 +471,7 @@ export class BotConnectorSession extends session.Session {
463471
public perUserInConversationData: any;
464472
}
465473

466-
function post(settings: IBotConnectorOptions, endpoint: string, path: string, body: any, callback?: (error: any) => void): void {
474+
function post(settings: IBotConnectorOptions, endpoint: string, path: string, body: any, callback?: (error: any, response?: http.IncomingMessage, body?: any) => void): void {
467475
var options: request.Options = {
468476
method: 'POST',
469477
url: endpoint + path,

0 commit comments

Comments
 (0)