botbuilder
Advanced tools
Comparing version 4.0.0-m1.4 to 4.0.0-m1.5
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
/** | ||
@@ -26,3 +26,3 @@ * Implemented by activity adapters | ||
*/ | ||
post(activities: Partial<Activity>[]): Promise<ConversationResourceResponse[] | undefined>; | ||
post(activities: Partial<Activity>[]): Promise<ResourceResponse[] | undefined>; | ||
} |
@@ -9,3 +9,3 @@ /** | ||
import { MiddlewareSet } from './middlewareSet'; | ||
import { Activity, ConversationReference } from './activity'; | ||
import { Activity, ConversationReference, ResourceResponse } from 'botbuilder-schema'; | ||
import { ActivityAdapter } from './activityAdapter'; | ||
@@ -21,3 +21,3 @@ import { Promiseable } from './middleware'; | ||
* ```js | ||
* import { Bot } from 'botbuilder-core'; // typescript | ||
* import { Bot } from 'botbuilder'; // typescript | ||
* | ||
@@ -96,3 +96,3 @@ * const bot = new Bot(adapter); // init bot and bind to adapter | ||
*/ | ||
post(context: BotContext, ...activities: Partial<Activity>[]): Promise<ConversationReference[]>; | ||
post(context: BotContext, ...activities: Partial<Activity>[]): Promise<ResourceResponse[]>; | ||
/** | ||
@@ -99,0 +99,0 @@ * Dispatches an incoming set of activities. This method can be used to dispatch an activity |
@@ -11,3 +11,3 @@ "use strict"; | ||
const middlewareSet_1 = require("./middlewareSet"); | ||
const activity_1 = require("./activity"); | ||
const botbuilder_schema_1 = require("botbuilder-schema"); | ||
const botContext_1 = require("./botContext"); | ||
@@ -22,3 +22,3 @@ const templateManager_1 = require("./templateManager"); | ||
* ```js | ||
* import { Bot } from 'botbuilder-core'; // typescript | ||
* import { Bot } from 'botbuilder'; // typescript | ||
* | ||
@@ -150,5 +150,5 @@ * const bot = new Bot(adapter); // init bot and bind to adapter | ||
if (!activity.type) { | ||
activity.type = activity_1.ActivityTypes.message; | ||
activity.type = botbuilder_schema_1.ActivityTypes.Message; | ||
} | ||
activity_1.applyConversationReference(activity, context.conversationReference); | ||
botContext_1.applyConversationReference(activity, context.conversationReference); | ||
} | ||
@@ -163,6 +163,7 @@ // Run post activity pipeline | ||
if (!Array.isArray(responses)) { | ||
responses = []; | ||
let mockResponses = []; | ||
for (let i = 0; i < activities.length; i++) { | ||
responses.push({}); | ||
mockResponses.push({}); | ||
} | ||
return mockResponses; | ||
} | ||
@@ -169,0 +170,0 @@ return responses; |
@@ -8,3 +8,2 @@ /** | ||
*/ | ||
export * from './activity'; | ||
export * from './attachmentRecognizer'; | ||
@@ -33,4 +32,5 @@ export * from './bot'; | ||
export * from './testAdapter'; | ||
export * from 'botbuilder-schema'; | ||
import { Bot } from './bot'; | ||
import { Activity, ConversationReference, ConversationResourceResponse } from './activity'; | ||
import { Activity, ConversationReference, ResourceResponse } from 'botbuilder-schema'; | ||
import { Intent } from './intentRecognizer'; | ||
@@ -47,3 +47,3 @@ import { StoreItem, Storage } from './storage'; | ||
/** The received activity. */ | ||
request: Activity; | ||
request: Partial<Activity>; | ||
/** Queue of responses to send to the user. */ | ||
@@ -54,3 +54,3 @@ responses: Partial<Activity>[]; | ||
/** The calculated conversation reference for this request. */ | ||
conversationReference: ConversationReference; | ||
conversationReference: Partial<ConversationReference>; | ||
/** | ||
@@ -166,3 +166,3 @@ * Persisted state related to the request. | ||
*/ | ||
flushResponses(): Promise<ConversationResourceResponse[]>; | ||
flushResponses(): Promise<ResourceResponse[]>; | ||
/** | ||
@@ -169,0 +169,0 @@ * Queues a new "typing" activity to the [responses](#responses) array. On supported |
@@ -13,3 +13,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./activity")); | ||
__export(require("./attachmentRecognizer")); | ||
@@ -35,2 +34,3 @@ __export(require("./bot")); | ||
__export(require("./testAdapter")); | ||
__export(require("botbuilder-schema")); | ||
//# sourceMappingURL=botbuilder.js.map |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Activity } from './activity'; | ||
import { Activity, ConversationReference } from 'botbuilder-schema'; | ||
import { Bot } from './bot'; | ||
@@ -17,2 +17,4 @@ /** | ||
*/ | ||
export declare function createBotContext(bot: Bot, request?: Activity): BotContext; | ||
export declare function createBotContext(bot: Bot, request?: Activity | ConversationReference): BotContext; | ||
export declare function getConversationReference(activity: Partial<Activity>): Partial<ConversationReference>; | ||
export declare function applyConversationReference(activity: Partial<Activity>, reference: Partial<ConversationReference>): void; |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
const activity_1 = require("./activity"); | ||
const botbuilder_schema_1 = require("botbuilder-schema"); | ||
const bot_1 = require("./bot"); | ||
@@ -29,3 +29,3 @@ /** | ||
if (request) { | ||
context.conversationReference = activity_1.getConversationReference(request); | ||
context.conversationReference = getConversationReference(request); | ||
} | ||
@@ -52,4 +52,4 @@ // Add methods | ||
const activity = { | ||
type: activity_1.ActivityTypes.endOfConversation, | ||
code: code || activity_1.EndOfConversationCodes.completedSuccessfully | ||
type: botbuilder_schema_1.ActivityTypes.EndOfConversation, | ||
code: code || botbuilder_schema_1.EndOfConversationCodes.CompletedSuccessfully | ||
}; | ||
@@ -68,3 +68,3 @@ this.responses.push(activity); | ||
if (!textOrActivity.type) { | ||
textOrActivity.type = activity_1.ActivityTypes.message; | ||
textOrActivity.type = botbuilder_schema_1.ActivityTypes.Message; | ||
} | ||
@@ -75,3 +75,3 @@ this.responses.push(textOrActivity); | ||
const activity = Object.assign({ | ||
type: activity_1.ActivityTypes.message, | ||
type: botbuilder_schema_1.ActivityTypes.Message, | ||
text: textOrActivity || '', | ||
@@ -114,3 +114,3 @@ }, additional || {}); | ||
throwIfDisposed('showTyping'); | ||
this.responses.push({ type: activity_1.ActivityTypes.typing }); | ||
this.responses.push({ type: botbuilder_schema_1.ActivityTypes.Typing }); | ||
return this; | ||
@@ -126,2 +126,22 @@ }; | ||
exports.createBotContext = createBotContext; | ||
function getConversationReference(activity) { | ||
return { | ||
activityId: activity.id, | ||
user: activity.from, | ||
bot: activity.recipient, | ||
conversation: activity.conversation, | ||
channelId: activity.channelId, | ||
serviceUrl: activity.serviceUrl | ||
}; | ||
} | ||
exports.getConversationReference = getConversationReference; | ||
function applyConversationReference(activity, reference) { | ||
activity.channelId = reference.channelId; | ||
activity.serviceUrl = reference.serviceUrl; | ||
activity.conversation = reference.conversation; | ||
activity.from = reference.bot; | ||
activity.recipient = reference.user; | ||
activity.replyToId = reference.activityId; | ||
} | ||
exports.applyConversationReference = applyConversationReference; | ||
//# sourceMappingURL=botContext.js.map |
@@ -9,3 +9,3 @@ /** | ||
import { Middleware } from './middleware'; | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
import { StoreItems } from './storage'; | ||
@@ -53,3 +53,3 @@ /** Optional settings used to configure a BotStateManager instance. */ | ||
contextCreated(context: BotContext, next: () => Promise<void>): Promise<void>; | ||
postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]>; | ||
postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ResourceResponse[]>): Promise<ResourceResponse[]>; | ||
contextDone(context: BotContext, next: () => Promise<void>): Promise<void>; | ||
@@ -56,0 +56,0 @@ protected read(context: BotContext, keys: string[]): Promise<StoreItems>; |
@@ -44,3 +44,3 @@ "use strict"; | ||
if (this.settings.writeBeforePost) { | ||
// save state | ||
// save state | ||
return this.write(context, {}).then(() => next()); | ||
@@ -53,3 +53,3 @@ } | ||
contextDone(context, next) { | ||
// save state | ||
// save state | ||
return this.write(context, {}).then(() => next()); | ||
@@ -56,0 +56,0 @@ } |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import * as activity from './activity'; | ||
import { Attachment, MediaUrl, CardAction, AnimationCard, CardImage, HeroCard, ReceiptCard, ThumbnailCard } from "botbuilder-schema"; | ||
/** | ||
@@ -52,3 +52,3 @@ * A set of utility functions designed to assist with the formatting of the various card types a | ||
*/ | ||
static adaptiveCard(card: any): activity.Attachment; | ||
static adaptiveCard(card: any): Attachment; | ||
/** | ||
@@ -62,3 +62,3 @@ * Returns an attachment for an animation card. | ||
*/ | ||
static animationCard(title: string, media: (activity.MediaUrl | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.AnimationCard>): activity.Attachment; | ||
static animationCard(title: string, media: (MediaUrl | string)[], buttons?: (CardAction | string)[], other?: Partial<AnimationCard>): Attachment; | ||
/** | ||
@@ -72,3 +72,3 @@ * Returns an attachment for an audio card. | ||
*/ | ||
static audioCard(title: string, media: (activity.MediaUrl | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.AnimationCard>): activity.Attachment; | ||
static audioCard(title: string, media: (MediaUrl | string)[], buttons?: (CardAction | string)[], other?: Partial<AnimationCard>): Attachment; | ||
/** | ||
@@ -84,4 +84,4 @@ * Returns an attachment for a hero card. Hero cards tend to have one dominant full width image | ||
*/ | ||
static heroCard(title: string, images?: (activity.CardImage | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.HeroCard>): activity.Attachment; | ||
static heroCard(title: string, text: string, images?: (activity.CardImage | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.HeroCard>): activity.Attachment; | ||
static heroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Attachment; | ||
static heroCard(title: string, text: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Attachment; | ||
/** | ||
@@ -93,3 +93,3 @@ * Returns an attachment for a receipt card. The attachment will contain the card and the | ||
*/ | ||
static receiptCard(card: activity.ReceiptCard): activity.Attachment; | ||
static receiptCard(card: ReceiptCard): Attachment; | ||
/** | ||
@@ -103,3 +103,3 @@ * Returns an attachment for a signin card. For channels that don't natively support signin | ||
*/ | ||
static signinCard(title: string, url: string, text?: string): activity.Attachment; | ||
static signinCard(title: string, url: string, text?: string): Attachment; | ||
/** | ||
@@ -117,4 +117,4 @@ * Returns an attachment for a thumbnail card. Thumbnail cards are similar to [hero cards](#herocard) | ||
*/ | ||
static thumbnailCard(title: string, images?: (activity.CardImage | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.ThumbnailCard>): activity.Attachment; | ||
static thumbnailCard(title: string, text: string, images?: (activity.CardImage | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.ThumbnailCard>): activity.Attachment; | ||
static thumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Attachment; | ||
static thumbnailCard(title: string, text: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Attachment; | ||
/** | ||
@@ -128,3 +128,3 @@ * Returns an attachment for a video card. | ||
*/ | ||
static videoCard(title: string, media: (activity.MediaUrl | string)[], buttons?: (activity.CardAction | string)[], other?: Partial<activity.AnimationCard>): activity.Attachment; | ||
static videoCard(title: string, media: (MediaUrl | string)[], buttons?: (CardAction | string)[], other?: Partial<AnimationCard>): Attachment; | ||
/** | ||
@@ -136,3 +136,3 @@ * Returns a properly formatted array of actions. Supports converting strings to `messageBack` | ||
*/ | ||
static actions(actions: (activity.CardAction | string)[] | undefined): activity.CardAction[]; | ||
static actions(actions: (CardAction | string)[] | undefined): CardAction[]; | ||
/** | ||
@@ -143,3 +143,3 @@ * Returns a properly formatted array of card images. | ||
*/ | ||
static images(images: (activity.CardImage | string)[] | undefined): activity.CardImage[]; | ||
static images(images: (CardImage | string)[] | undefined): CardImage[]; | ||
/** | ||
@@ -150,3 +150,3 @@ * Returns a properly formatted array of media url objects. | ||
*/ | ||
static media(links: (activity.MediaUrl | string)[] | undefined): activity.MediaUrl[]; | ||
static media(links: (MediaUrl | string)[] | undefined): MediaUrl[]; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
const botbuilder_schema_1 = require("botbuilder-schema"); | ||
/** | ||
* A set of utility functions designed to assist with the formatting of the various card types a | ||
@@ -82,3 +90,3 @@ * bot can return. All of these functions return an `Attachment` which can be added to an `Activity` | ||
static signinCard(title, url, text) { | ||
const card = { buttons: [{ type: 'signin', title: title, value: url }] }; | ||
const card = { buttons: [{ type: botbuilder_schema_1.ActionTypes.Signin, title: title, value: url }] }; | ||
if (text) { | ||
@@ -135,3 +143,3 @@ card.text = text; | ||
else { | ||
list.push({ type: 'imBack', value: a.toString(), title: a.toString() }); | ||
list.push({ type: botbuilder_schema_1.ActionTypes.ImBack, value: a.toString(), title: a.toString() }); | ||
} | ||
@@ -138,0 +146,0 @@ }); |
@@ -10,3 +10,3 @@ /** | ||
import { Middleware } from './middleware'; | ||
import { Activity } from './activity'; | ||
import { Activity } from 'botbuilder-schema'; | ||
export declare type SimpleTemplateFunction = (context: BotContext, data: Object) => Partial<Activity> | string | undefined; | ||
@@ -13,0 +13,0 @@ /** |
@@ -5,3 +5,3 @@ /** | ||
/** second comment block */ | ||
import { Entity } from './activity'; | ||
import { Entity } from 'botbuilder-schema'; | ||
/** | ||
@@ -8,0 +8,0 @@ * A strongly typed entity. |
@@ -123,8 +123,3 @@ "use strict"; | ||
hasExactMatch(intents) { | ||
intents.forEach((intent) => { | ||
if (intent.score >= 1.0) { | ||
return true; | ||
} | ||
}); | ||
return false; | ||
return intents.filter((intent) => intent.score >= 1.0).length > 0; | ||
} | ||
@@ -131,0 +126,0 @@ } |
@@ -10,3 +10,3 @@ /** | ||
import { Middleware } from './middleware'; | ||
import { Activity } from './activity'; | ||
import { Activity } from 'botbuilder-schema'; | ||
/** | ||
@@ -13,0 +13,0 @@ * A template function that can return a stringified value from a given data object. |
@@ -106,3 +106,3 @@ "use strict"; | ||
// - Templates can be executed as children of other templates so the path | ||
// specifies the property off the parent to execute the template for. | ||
// specifies the property off the parent to execute the template for. | ||
let obj = ''; | ||
@@ -109,0 +109,0 @@ if (path) { |
@@ -0,10 +1,3 @@ | ||
import { Activity, CardAction, Attachment, InputHints } from 'botbuilder-schema'; | ||
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import * as activity from './activity'; | ||
/** | ||
* A set of utility functions to assist with the formatting of the various message types a bot can | ||
@@ -43,4 +36,5 @@ * return. | ||
* @param speak (Optional) SSML to include in the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static text(text: string, speak?: string): Partial<activity.Activity>; | ||
static text(text: string, speak?: string, inputHint?: InputHints | string): Partial<Activity>; | ||
/** | ||
@@ -52,4 +46,5 @@ * Returns a message that includes a set of suggested actions and optional text. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static suggestedActions(actions: (activity.CardAction | string)[], text?: string, speak?: string): Partial<activity.Activity>; | ||
static suggestedActions(actions: (CardAction | string)[], text?: string, speak?: string, inputHint?: InputHints | string): Partial<Activity>; | ||
/** | ||
@@ -61,4 +56,5 @@ * Returns a single message activity containing an attachment. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static attachment(attachment: activity.Attachment, text?: string, speak?: string): Partial<activity.Activity>; | ||
static attachment(attachment: Attachment, text?: string, speak?: string, inputHint?: InputHints | string): Partial<Activity>; | ||
/** | ||
@@ -70,4 +66,5 @@ * Returns a message that will display a set of attachments in list form. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static list(attachments: activity.Attachment[], text?: string, speak?: string): Partial<activity.Activity>; | ||
static list(attachments: Attachment[], text?: string, speak?: string, inputHint?: InputHints | string): Partial<Activity>; | ||
/** | ||
@@ -92,4 +89,5 @@ * Returns a message that will display a set of attachments using a carousel layout. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static carousel(attachments: activity.Attachment[], text?: string, speak?: string): Partial<activity.Activity>; | ||
static carousel(attachments: Attachment[], text?: string, speak?: string, inputHint?: InputHints | string): Partial<Activity>; | ||
/** | ||
@@ -112,4 +110,5 @@ * Returns a message that will display a single image or video to a user. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static contentUrl(url: string, contentType: string, name?: string, text?: string, speak?: string): Partial<activity.Activity>; | ||
static contentUrl(url: string, contentType: string, name?: string, text?: string, speak?: string, inputHint?: InputHints | string): Partial<Activity>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -9,5 +10,4 @@ * @module botbuilder | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const activity = require("./activity"); | ||
const cardStyler_1 = require("./cardStyler"); | ||
const botbuilder_schema_1 = require("botbuilder-schema"); | ||
/** | ||
@@ -47,6 +47,7 @@ * A set of utility functions to assist with the formatting of the various message types a bot can | ||
* @param speak (Optional) SSML to include in the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static text(text, speak) { | ||
static text(text, speak, inputHint) { | ||
const msg = { | ||
type: activity.ActivityTypes.message, | ||
type: botbuilder_schema_1.ActivityTypes.Message, | ||
text: text || '' | ||
@@ -57,2 +58,5 @@ }; | ||
} | ||
if (inputHint) { | ||
msg.inputHint = inputHint; | ||
} | ||
return msg; | ||
@@ -66,6 +70,7 @@ } | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static suggestedActions(actions, text, speak) { | ||
static suggestedActions(actions, text, speak, inputHint) { | ||
const msg = { | ||
type: activity.ActivityTypes.message, | ||
type: botbuilder_schema_1.ActivityTypes.Message, | ||
suggestedActions: { | ||
@@ -81,2 +86,5 @@ actions: cardStyler_1.CardStyler.actions(actions) | ||
} | ||
if (inputHint) { | ||
msg.inputHint = inputHint; | ||
} | ||
return msg; | ||
@@ -90,5 +98,6 @@ } | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static attachment(attachment, text, speak) { | ||
return attachmentActivity(activity.AttachmentLayouts.list, [attachment], text, speak); | ||
static attachment(attachment, text, speak, inputHint) { | ||
return attachmentActivity(botbuilder_schema_1.AttachmentLayoutTypes.List, [attachment], text, speak, inputHint); | ||
} | ||
@@ -101,5 +110,6 @@ /** | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static list(attachments, text, speak) { | ||
return attachmentActivity(activity.AttachmentLayouts.list, attachments, text, speak); | ||
static list(attachments, text, speak, inputHint) { | ||
return attachmentActivity(botbuilder_schema_1.AttachmentLayoutTypes.List, attachments, text, speak, inputHint); | ||
} | ||
@@ -125,5 +135,6 @@ /** | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static carousel(attachments, text, speak) { | ||
return attachmentActivity(activity.AttachmentLayouts.carousel, attachments, text, speak); | ||
static carousel(attachments, text, speak, inputHint) { | ||
return attachmentActivity(botbuilder_schema_1.AttachmentLayoutTypes.Carousel, attachments, text, speak, inputHint); | ||
} | ||
@@ -147,4 +158,5 @@ /** | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static contentUrl(url, contentType, name, text, speak) { | ||
static contentUrl(url, contentType, name, text, speak, inputHint) { | ||
const a = { contentType: contentType, contentUrl: url }; | ||
@@ -154,9 +166,9 @@ if (name) { | ||
} | ||
return attachmentActivity(activity.AttachmentLayouts.list, [a], text, speak); | ||
return attachmentActivity(botbuilder_schema_1.AttachmentLayoutTypes.List, [a], text, speak, inputHint); | ||
} | ||
} | ||
exports.MessageStyler = MessageStyler; | ||
function attachmentActivity(attachmentLayout, attachments, text, speak) { | ||
function attachmentActivity(attachmentLayout, attachments, text, speak, inputHint) { | ||
const msg = { | ||
type: activity.ActivityTypes.message, | ||
type: botbuilder_schema_1.ActivityTypes.Message, | ||
attachmentLayout: attachmentLayout, | ||
@@ -171,4 +183,7 @@ attachments: attachments | ||
} | ||
if (inputHint) { | ||
msg.inputHint = inputHint; | ||
} | ||
return msg; | ||
} | ||
//# sourceMappingURL=messageStyler.js.map |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
/** | ||
@@ -58,3 +58,3 @@ * Type signature for a return value that can (Optionally) return its value | ||
*/ | ||
postActivity?(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]>; | ||
postActivity?(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ResourceResponse[]>): Promise<ResourceResponse[]>; | ||
} |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
import { Middleware } from './middleware'; | ||
@@ -30,3 +30,3 @@ /** | ||
receiveActivity(context: BotContext, next: () => Promise<void>): Promise<void>; | ||
postActivity(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]>; | ||
postActivity(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ResourceResponse[]>): Promise<ResourceResponse[]>; | ||
} |
@@ -33,3 +33,3 @@ /** | ||
* ```js | ||
* import { RegExpRecognizer } from 'botbuilder-core'; | ||
* import { RegExpRecognizer } from 'botbuilder'; | ||
* | ||
@@ -36,0 +36,0 @@ * // Define RegExp's for well known commands. |
@@ -25,3 +25,3 @@ "use strict"; | ||
* ```js | ||
* import { RegExpRecognizer } from 'botbuilder-core'; | ||
* import { RegExpRecognizer } from 'botbuilder'; | ||
* | ||
@@ -28,0 +28,0 @@ * // Define RegExp's for well known commands. |
@@ -9,3 +9,3 @@ /** | ||
import { Middleware } from './middleware'; | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
/** Interface for a template renderer which provides the ability | ||
@@ -28,3 +28,3 @@ * to create a text reply or activity reply from the language, templateid and data object | ||
contextCreated(context: BotContext, next: () => Promise<void>): Promise<void>; | ||
postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]>; | ||
postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ResourceResponse[]>): Promise<ResourceResponse[]>; | ||
/** | ||
@@ -31,0 +31,0 @@ * register template renderer |
@@ -11,3 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const activity_1 = require("./activity"); | ||
const botbuilder_schema_1 = require("botbuilder-schema"); | ||
class TemplateManager { | ||
@@ -68,3 +68,3 @@ constructor() { | ||
if (!templateOutput.type) { | ||
templateOutput.type = activity_1.ActivityTypes.message; | ||
templateOutput.type = botbuilder_schema_1.ActivityTypes.Message; | ||
} | ||
@@ -75,3 +75,3 @@ return templateOutput; | ||
const activity = { | ||
type: activity_1.ActivityTypes.message, | ||
type: botbuilder_schema_1.ActivityTypes.Message, | ||
text: templateOutput || '', | ||
@@ -78,0 +78,0 @@ }; |
@@ -9,3 +9,3 @@ /** | ||
import { ActivityAdapter } from './activityAdapter'; | ||
import { Activity, ConversationReference } from './activity'; | ||
import { Activity, ConversationReference } from 'botbuilder-schema'; | ||
/** | ||
@@ -33,3 +33,3 @@ * Test adapter used for unit tests. | ||
reference: ConversationReference; | ||
botReplies: Activity[]; | ||
botReplies: Partial<Activity>[]; | ||
/** INTERNAL implementation of `Adapter.onReceive`. */ | ||
@@ -63,3 +63,3 @@ onReceive: (activity: Activity) => Promise<void>; | ||
*/ | ||
test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
/** | ||
@@ -71,3 +71,3 @@ * Throws if the bot's response doesn't match the expected text/activity | ||
*/ | ||
assertReply(expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
assertReply(expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
/** | ||
@@ -93,3 +93,3 @@ * throws if the bot's response is not one of the candidate strings | ||
*/ | ||
test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
/** | ||
@@ -106,3 +106,3 @@ * Send something to the bot | ||
*/ | ||
assertReply(expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
assertReply(expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow; | ||
/** | ||
@@ -109,0 +109,0 @@ * throws if the bot's response is not one of the candidate strings |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const activity_1 = require("./activity"); | ||
const botbuilder_schema_1 = require("botbuilder-schema"); | ||
const assert = require("assert"); | ||
@@ -50,3 +50,3 @@ /** | ||
// ready for next reply | ||
let activity = (typeof userSays === 'string' ? { type: activity_1.ActivityTypes.message, text: userSays } : userSays); | ||
let activity = (typeof userSays === 'string' ? { type: botbuilder_schema_1.ActivityTypes.Message, text: userSays } : userSays); | ||
if (!activity.type) | ||
@@ -153,3 +153,3 @@ throw new Error("Missing activity.type"); | ||
if ((current - start) > timeout) { | ||
let expectedActivity = (typeof expected === 'string' ? { type: activity_1.ActivityTypes.message, text: expected } : expected); | ||
let expectedActivity = (typeof expected === 'string' ? { type: botbuilder_schema_1.ActivityTypes.Message, text: expected } : expected); | ||
throw new Error(`${timeout}ms Timed out waiting for:${description || expectedActivity.text}`); | ||
@@ -166,3 +166,3 @@ } | ||
else if (typeof expected === 'string') { | ||
assert.equal(botReply.type, activity_1.ActivityTypes.message, (description || '') + ` type === '${botReply.type}'. `); | ||
assert.equal(botReply.type, botbuilder_schema_1.ActivityTypes.Message, (description || '') + ` type === '${botReply.type}'. `); | ||
assert.equal(botReply.text, expected, (description || '') + ` text === "${botReply.text}"`); | ||
@@ -169,0 +169,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "Bot Builder core library. Bot Builder is a toolkit for building rich bots on virtually any platform.", | ||
"version": "4.0.0-m1.4", | ||
"version": "4.0.0-m1.5", | ||
"license": "MIT", | ||
@@ -23,2 +23,6 @@ "keywords": [ | ||
"typings": "./lib/botbuilder.d.ts", | ||
"dependencies": { | ||
"botframework-schema": "^4.0.0-m1.5", | ||
"assert": "^1.4.1" | ||
}, | ||
"devDependencies": { | ||
@@ -37,6 +41,3 @@ "@types/mocha": "^2.2.47", | ||
"clean": "erase /q lib\\*.*" | ||
}, | ||
"dependencies": { | ||
"assert": "^1.4.1" | ||
} | ||
} |
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { Activity, ConversationReference, ConversationResourceResponse } from './activity'; | ||
import { Activity, ConversationReference, ResourceResponse } from 'botbuilder-schema'; | ||
@@ -15,4 +15,4 @@ /** | ||
/** | ||
* Handler that returns incoming activities to a single consumer. The `Bot` will set this | ||
* when the adapter is passed to its constructor. Just keep in mind that should the bots | ||
* Handler that returns incoming activities to a single consumer. The `Bot` will set this | ||
* when the adapter is passed to its constructor. Just keep in mind that should the bots | ||
* adapter be replaced (like when running unit tests) this handler can end up being set | ||
@@ -22,3 +22,3 @@ * back to undefined. | ||
onReceive: (activity: Activity) => Promise<void>; | ||
/** | ||
@@ -29,4 +29,4 @@ * Called by a consumer to send outgoing set of activities to a user. | ||
*/ | ||
post(activities: Partial<Activity>[]): Promise<ConversationResourceResponse[]|undefined>; | ||
post(activities: Partial<Activity>[]): Promise<ResourceResponse[]|undefined>; | ||
} | ||
/* istanbul ignore file */ |
@@ -5,3 +5,3 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
@@ -11,12 +11,12 @@ */ | ||
import { EntityObject, EntityTypes } from './entityObject'; | ||
import { Attachment } from './index'; | ||
import { Attachment } from 'botbuilder-schema'; | ||
/** Optional settings for an `AttachmentRecognizer`. */ | ||
export interface AttachmentRecognizerSettings { | ||
/** | ||
* Name of the intent to return when an attachment is detected. This defaults to | ||
/** | ||
* Name of the intent to return when an attachment is detected. This defaults to | ||
* a value of "Intents.AttachmentReceived". | ||
* | ||
* | ||
* Developers can also adjust the name of the intent returned by adding content filters to | ||
* the recognizer. This setting will be ignored when content filters are active. | ||
* the recognizer. This setting will be ignored when content filters are active. | ||
*/ | ||
@@ -63,6 +63,6 @@ intentName: string; | ||
const entities: EntityObject<Attachment>[] = []; | ||
context.request.attachments.forEach((a) => entities.push({ | ||
type: a.contentType || EntityTypes.attachment, | ||
score: 1.0, | ||
value: a | ||
context.request.attachments.forEach((a) => entities.push({ | ||
type: a.contentType || EntityTypes.attachment, | ||
score: 1.0, | ||
value: a | ||
})); | ||
@@ -103,4 +103,4 @@ | ||
// Return a single intent for all attachments | ||
intents.push({ | ||
score: 1.0, | ||
intents.push({ | ||
score: 1.0, | ||
name: <string>this.settings.intentName, | ||
@@ -115,3 +115,3 @@ entities: entities | ||
/** | ||
/** | ||
* Add a new content type filter to the recognizer. Adding one or more `contentType()` filters | ||
@@ -121,3 +121,3 @@ * will result in only attachments of the specified type(s) being recognized. | ||
* @param contentType The `Attachment.contentType` to look for. | ||
* @param intentName Name of the intent to return when the given type is matched. | ||
* @param intentName Name of the intent to return when the given type is matched. | ||
*/ | ||
@@ -124,0 +124,0 @@ public contentType(contentType: string|RegExp, intentName: string): this { |
@@ -5,10 +5,10 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { MiddlewareSet } from './middlewareSet'; | ||
import { Activity, ConversationReference, ActivityTypes, ConversationResourceResponse, applyConversationReference } from './activity'; | ||
import { ActivityTypes, Activity, ConversationReference, ResourceResponse, } from 'botbuilder-schema'; | ||
import { ActivityAdapter } from './activityAdapter'; | ||
import { Promiseable } from './middleware'; | ||
import { createBotContext } from './botContext'; | ||
import { createBotContext, applyConversationReference } from './botContext'; | ||
import { TemplateManager, TemplateRenderer } from './templateManager'; | ||
@@ -23,3 +23,3 @@ import { DictionaryRenderer, TemplateDictionary } from './botbuilder'; | ||
* ```js | ||
* import { Bot } from 'botbuilder-core'; // typescript | ||
* import { Bot } from 'botbuilder'; // typescript | ||
* | ||
@@ -60,4 +60,4 @@ * const bot = new Bot(adapter); // init bot and bind to adapter | ||
/** | ||
* Creates a new context object given an activity or conversation reference. The context object | ||
* will be disposed of automatically once the callback completes or the promise it returns | ||
* Creates a new context object given an activity or conversation reference. The context object | ||
* will be disposed of automatically once the callback completes or the promise it returns | ||
* completes. | ||
@@ -83,6 +83,6 @@ * | ||
if ((activityOrReference as Activity).type) { | ||
context = createBotContext(this, activityOrReference); | ||
context = createBotContext(this, <Activity>activityOrReference); | ||
} else { | ||
context = createBotContext(this); | ||
context.conversationReference = activityOrReference; | ||
context.conversationReference = <ConversationReference>activityOrReference; | ||
} | ||
@@ -105,3 +105,3 @@ | ||
* Registers a new receiver with the bot. All incoming activities are routed to receivers in | ||
* the order they're registered. The first receiver to return `{ handled: true }` prevents | ||
* the order they're registered. The first receiver to return `{ handled: true }` prevents | ||
* the receivers after it from being called. | ||
@@ -114,3 +114,3 @@ * | ||
* .onReceive((context) => { | ||
* context.reply(`Hello World`); | ||
* context.reply(`Hello World`); | ||
* }); | ||
@@ -154,3 +154,3 @@ * ``` | ||
/** | ||
* INTERNAL sends an outgoing set of activities to the user. Calling `context.flushResponses()` achieves the same | ||
* INTERNAL sends an outgoing set of activities to the user. Calling `context.flushResponses()` achieves the same | ||
* effect and is the preferred way of sending activities to the user. | ||
@@ -161,3 +161,3 @@ * | ||
*/ | ||
public post(context: BotContext, ...activities: Partial<Activity>[]): Promise<ConversationReference[]> { | ||
public post(context: BotContext, ...activities: Partial<Activity>[]): Promise<ResourceResponse[]> { | ||
// Ensure activities are well formed. | ||
@@ -167,3 +167,3 @@ for (let i = 0; i < activities.length; i++) { | ||
if (!activity.type) { | ||
activity.type = ActivityTypes.message | ||
activity.type = ActivityTypes.Message | ||
} | ||
@@ -181,4 +181,8 @@ applyConversationReference(activity, context.conversationReference); | ||
if (!Array.isArray(responses)) { | ||
responses = []; | ||
for (let i = 0; i < activities.length; i++) { responses.push({}) } | ||
let mockResponses: ResourceResponse[] = []; | ||
for (let i = 0; i < activities.length; i++) { | ||
mockResponses.push({} as ResourceResponse) | ||
} | ||
return mockResponses; | ||
} | ||
@@ -199,6 +203,6 @@ return responses; | ||
// Create context and run receive activity pipeline | ||
return this.createContext(activity, | ||
(context) => this.receiveActivity(context, | ||
return this.createContext(activity, | ||
(context) => this.receiveActivity(context, | ||
() => Promise.resolve())); | ||
} | ||
} |
@@ -9,3 +9,2 @@ /** | ||
export * from './activity'; | ||
export * from './attachmentRecognizer'; | ||
@@ -34,5 +33,6 @@ export * from './bot'; | ||
export * from './testAdapter'; | ||
export * from 'botbuilder-schema'; | ||
import { Bot } from './bot'; | ||
import { Activity, ConversationReference, ConversationResourceResponse } from './activity'; | ||
import { Activity, ConversationReference, ResourceResponse } from 'botbuilder-schema'; | ||
import { Intent } from './intentRecognizer'; | ||
@@ -52,3 +52,3 @@ import { EntityObject } from './entityObject'; | ||
/** The received activity. */ | ||
request: Activity; | ||
request: Partial<Activity>; | ||
@@ -62,3 +62,3 @@ /** Queue of responses to send to the user. */ | ||
/** The calculated conversation reference for this request. */ | ||
conversationReference: ConversationReference; | ||
conversationReference: Partial<ConversationReference>; | ||
@@ -185,3 +185,3 @@ /** | ||
*/ | ||
flushResponses(): Promise<ConversationResourceResponse[]>; | ||
flushResponses(): Promise<ResourceResponse[]>; | ||
@@ -188,0 +188,0 @@ /** |
@@ -5,6 +5,6 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { Activity, ActivityTypes, EndOfConversationCodes, ConversationReference, getConversationReference } from './activity'; | ||
import { ActivityTypes, EndOfConversationCodes, Activity, ConversationReference } from 'botbuilder-schema'; | ||
import { Bot } from './bot'; | ||
@@ -22,3 +22,3 @@ import { Intent } from './intentRecognizer'; | ||
*/ | ||
export function createBotContext(bot: Bot, request?: Activity): BotContext { | ||
export function createBotContext(bot: Bot, request?: Activity|ConversationReference): BotContext { | ||
const context = <BotContext>{}; | ||
@@ -49,3 +49,3 @@ context.bot = bot; | ||
throwIfDisposed('delay'); | ||
this.responses.push({ type: 'delay', value: duration }); | ||
this.responses.push({ type: <ActivityTypes>'delay', value: duration }); | ||
return this; | ||
@@ -58,7 +58,7 @@ }; | ||
context.endOfConversation = function endOfConversation(code?: string) { | ||
context.endOfConversation = function endOfConversation(code?: EndOfConversationCodes) { | ||
throwIfDisposed('endOfConversation'); | ||
const activity: Partial<Activity> = { | ||
type: ActivityTypes.endOfConversation, | ||
code: code || EndOfConversationCodes.completedSuccessfully | ||
type: ActivityTypes.EndOfConversation, | ||
code: code || EndOfConversationCodes.CompletedSuccessfully | ||
}; | ||
@@ -78,7 +78,7 @@ this.responses.push(activity); | ||
if (typeof textOrActivity === 'object') { | ||
if (!(textOrActivity as Activity).type) { textOrActivity.type = ActivityTypes.message; } | ||
if (!(textOrActivity as Activity).type) { textOrActivity.type = ActivityTypes.Message; } | ||
this.responses.push(textOrActivity); | ||
} else { | ||
const activity: Partial<Activity> = Object.assign(<Partial<Activity>>{ | ||
type: ActivityTypes.message, | ||
type: ActivityTypes.Message, | ||
text: textOrActivity || '', | ||
@@ -99,3 +99,3 @@ }, additional || {}); | ||
const activity: Partial<Activity> = <Partial<Activity>>{ | ||
type: "template", | ||
type: <ActivityTypes>"template", | ||
}; | ||
@@ -117,5 +117,5 @@ activity.text = templateId; | ||
.then((results: ConversationReference[]) => { | ||
if (cnt > 0) { | ||
if (cnt > 0) { | ||
this.responses.splice(0, cnt); | ||
responded = true; | ||
responded = true; | ||
} | ||
@@ -128,3 +128,3 @@ return results; | ||
throwIfDisposed('showTyping'); | ||
this.responses.push({ type: ActivityTypes.typing }); | ||
this.responses.push({ type: ActivityTypes.Typing }); | ||
return this; | ||
@@ -135,3 +135,3 @@ }; | ||
get: function () { | ||
return (this as BotContext).responses.length > 0 || responded; | ||
return (this as BotContext).responses.length > 0 || responded; | ||
} | ||
@@ -142,1 +142,21 @@ }); | ||
} | ||
export function getConversationReference(activity: Partial<Activity>): Partial<ConversationReference> { | ||
return { | ||
activityId: activity.id, | ||
user: activity.from, | ||
bot: activity.recipient, | ||
conversation: activity.conversation, | ||
channelId: activity.channelId, | ||
serviceUrl: activity.serviceUrl | ||
}; | ||
} | ||
export function applyConversationReference(activity: Partial<Activity>, reference: Partial<ConversationReference>): void { | ||
activity.channelId = reference.channelId; | ||
activity.serviceUrl = reference.serviceUrl; | ||
activity.conversation = reference.conversation; | ||
activity.from = reference.bot; | ||
activity.recipient = reference.user; | ||
activity.replyToId = reference.activityId; | ||
} |
@@ -5,7 +5,7 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { Middleware } from './middleware'; | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
import { StoreItem, StoreItems } from './storage'; | ||
@@ -29,12 +29,12 @@ | ||
/** | ||
/** | ||
* Middleware for tracking conversation and user state using the `context.storage` provider. | ||
* | ||
* | ||
* __Extends BotContext:__ | ||
* * context.state.user - User persisted state | ||
* * context.state.conversation - Conversation persisted data | ||
* | ||
* | ||
* __Depends on:__ | ||
* * context.storage - Storage provider for storing and retrieving objects | ||
* | ||
* | ||
* **Usage Example** | ||
@@ -57,6 +57,6 @@ * | ||
* | ||
* @param settings (Optional) settings to adjust the behavior of the state manager. | ||
* @param settings (Optional) settings to adjust the behavior of the state manager. | ||
*/ | ||
public constructor(settings?: Partial<BotStateManagerSettings>) { | ||
this.settings = Object.assign(<BotStateManagerSettings>{ | ||
this.settings = Object.assign(<BotStateManagerSettings>{ | ||
persistUserState: true, | ||
@@ -74,5 +74,5 @@ persistConversationState: true, | ||
public postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]> { | ||
public postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ResourceResponse[]>): Promise<ResourceResponse[]> { | ||
if (this.settings.writeBeforePost) { | ||
// save state | ||
// save state | ||
return this.write(context, {}).then(() => next()); | ||
@@ -85,3 +85,3 @@ } else { | ||
public contextDone(context: BotContext, next: () => Promise<void>): Promise<void> { | ||
// save state | ||
// save state | ||
return this.write(context, {}).then(() => next()); | ||
@@ -132,3 +132,3 @@ } | ||
// Update eTags | ||
if (this.settings.lastWriterWins) { | ||
if (this.settings.lastWriterWins) { | ||
for (const key in changes) { | ||
@@ -135,0 +135,0 @@ changes[key].eTag = '*'; |
@@ -5,6 +5,6 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import * as activity from './activity'; | ||
import { Attachment, MediaUrl, CardAction, AnimationCard, CardImage, HeroCard, ReceiptCard, SigninCard, ThumbnailCard, VideoCard, ActionTypes } from "botbuilder-schema"; | ||
@@ -42,10 +42,10 @@ /** | ||
* appropriate `contentType`. | ||
* | ||
* | ||
* Adaptive Cards are a new way for bots to send interactive and immersive card content to | ||
* users. For channels that don't yet support Adaptive Cards natively, the Bot Framework will | ||
* down render the card to an image that's been styled to look good on the target channel. For | ||
* channels that support [hero cards](#herocards) you can continue to include Adaptive Card | ||
* channels that support [hero cards](#herocards) you can continue to include Adaptive Card | ||
* actions and they will be sent as buttons along with the rendered version of the card. | ||
* | ||
* For more information about Adaptive Cards and to download the latest SDK, visit | ||
* | ||
* For more information about Adaptive Cards and to download the latest SDK, visit | ||
* [adaptivecards.io](http://adaptivecards.io/). | ||
@@ -55,3 +55,3 @@ * | ||
*/ | ||
static adaptiveCard(card: any): activity.Attachment | ||
static adaptiveCard(card: any): Attachment | ||
{ | ||
@@ -69,6 +69,6 @@ return { contentType: CardStyler.contentTypes.adaptiveCard, content: card }; | ||
*/ | ||
static animationCard(title: string, | ||
media: (activity.MediaUrl|string)[], | ||
buttons?: (activity.CardAction|string)[], | ||
other?: Partial<activity.AnimationCard>): activity.Attachment | ||
static animationCard(title: string, | ||
media: (MediaUrl|string)[], | ||
buttons?: (CardAction|string)[], | ||
other?: Partial<AnimationCard>): Attachment | ||
{ | ||
@@ -86,10 +86,10 @@ return mediaCard(CardStyler.contentTypes.animationCard, title, media, buttons, other); | ||
*/ | ||
static audioCard(title: string, | ||
media: (activity.MediaUrl|string)[], | ||
buttons?: (activity.CardAction|string)[], | ||
other?: Partial<activity.AnimationCard>): activity.Attachment | ||
static audioCard(title: string, | ||
media: (MediaUrl|string)[], | ||
buttons?: (CardAction|string)[], | ||
other?: Partial<AnimationCard>): Attachment | ||
{ | ||
return mediaCard(CardStyler.contentTypes.audioCard, title, media, buttons, other); | ||
} | ||
/** | ||
@@ -101,13 +101,13 @@ * Returns an attachment for a hero card. Hero cards tend to have one dominant full width image | ||
* @param text (Optional) text field for the card. | ||
* @param images (Optional) set of images to include on the card. | ||
* @param images (Optional) set of images to include on the card. | ||
* @param buttons (Optional) set of buttons to include on the card. | ||
* @param other (Optional) additional properties to include on the card. | ||
*/ | ||
static heroCard(title: string, images?: (activity.CardImage|string)[], buttons?: (activity.CardAction|string)[], other?: Partial<activity.HeroCard>): activity.Attachment; | ||
static heroCard(title: string, text: string, images?: (activity.CardImage|string)[], buttons?: (activity.CardAction|string)[], other?: Partial<activity.HeroCard>): activity.Attachment; | ||
static heroCard(title: string, text?: any, images?: any, buttons?: any, other?: Partial<activity.HeroCard>): activity.Attachment { | ||
static heroCard(title: string, images?: (CardImage|string)[], buttons?: (CardAction|string)[], other?: Partial<HeroCard>): Attachment; | ||
static heroCard(title: string, text: string, images?: (CardImage|string)[], buttons?: (CardAction|string)[], other?: Partial<HeroCard>): Attachment; | ||
static heroCard(title: string, text?: any, images?: any, buttons?: any, other?: Partial<HeroCard>): Attachment { | ||
const a = CardStyler.thumbnailCard(title, text, images, buttons, other); | ||
a.contentType = CardStyler.contentTypes.heroCard; | ||
return a; | ||
} | ||
} | ||
@@ -120,3 +120,3 @@ /** | ||
*/ | ||
static receiptCard(card: activity.ReceiptCard): activity.Attachment | ||
static receiptCard(card: ReceiptCard): Attachment | ||
{ | ||
@@ -134,12 +134,12 @@ return { contentType: CardStyler.contentTypes.receiptCard, content: card }; | ||
*/ | ||
static signinCard(title: string, url: string, text?: string): activity.Attachment { | ||
const card: activity.SigninCard = { buttons: [{ type: 'signin', title: title, value: url }] }; | ||
static signinCard(title: string, url: string, text?: string): Attachment { | ||
const card: SigninCard = { buttons: [{ type: ActionTypes.Signin, title: title, value: url }] }; | ||
if (text) { card.text = text; } | ||
return { contentType: CardStyler.contentTypes.signinCard, content: card }; | ||
return { contentType: CardStyler.contentTypes.signinCard, content: card }; | ||
} | ||
/** | ||
* Returns an attachment for a thumbnail card. Thumbnail cards are similar to [hero cards](#herocard) | ||
* but instead of a full width image, they're typically rendered with a smaller thumbnail version of | ||
* the image on either side and the text will be rendered in column next to the image. Any buttons | ||
* the image on either side and the text will be rendered in column next to the image. Any buttons | ||
* will typically show up under the card. | ||
@@ -149,9 +149,9 @@ * | ||
* @param text (Optional) text field for the card. | ||
* @param images (Optional) set of images to include on the card. | ||
* @param images (Optional) set of images to include on the card. | ||
* @param buttons (Optional) set of buttons to include on the card. | ||
* @param other (Optional) additional properties to include on the card. | ||
*/ | ||
static thumbnailCard(title: string, images?: (activity.CardImage|string)[], buttons?: (activity.CardAction|string)[], other?: Partial<activity.ThumbnailCard>): activity.Attachment; | ||
static thumbnailCard(title: string, text: string, images?: (activity.CardImage|string)[], buttons?: (activity.CardAction|string)[], other?: Partial<activity.ThumbnailCard>): activity.Attachment; | ||
static thumbnailCard(title: string, text?: any, images?: any, buttons?: any, other?: Partial<activity.ThumbnailCard>): activity.Attachment { | ||
static thumbnailCard(title: string, images?: (CardImage|string)[], buttons?: (CardAction|string)[], other?: Partial<ThumbnailCard>): Attachment; | ||
static thumbnailCard(title: string, text: string, images?: (CardImage|string)[], buttons?: (CardAction|string)[], other?: Partial<ThumbnailCard>): Attachment; | ||
static thumbnailCard(title: string, text?: any, images?: any, buttons?: any, other?: Partial<ThumbnailCard>): Attachment { | ||
if (typeof text !== 'string') { | ||
@@ -163,3 +163,3 @@ other = buttons; | ||
} | ||
const card: activity.ThumbnailCard = Object.assign({}, other); | ||
const card: Partial<ThumbnailCard> = Object.assign({}, other); | ||
if (title) { card.title = title; } | ||
@@ -170,3 +170,3 @@ if (text) { card.text = text; } | ||
return { contentType: CardStyler.contentTypes.thumbnailCard, content: card }; | ||
} | ||
} | ||
@@ -181,12 +181,12 @@ /** | ||
*/ | ||
static videoCard(title: string, | ||
media: (activity.MediaUrl|string)[], | ||
buttons?: (activity.CardAction|string)[], | ||
other?: Partial<activity.AnimationCard>): activity.Attachment | ||
static videoCard(title: string, | ||
media: (MediaUrl|string)[], | ||
buttons?: (CardAction|string)[], | ||
other?: Partial<AnimationCard>): Attachment | ||
{ | ||
return mediaCard(CardStyler.contentTypes.videoCard, title, media, buttons, other); | ||
} | ||
/** | ||
* Returns a properly formatted array of actions. Supports converting strings to `messageBack` | ||
* Returns a properly formatted array of actions. Supports converting strings to `messageBack` | ||
* actions (note: using 'imBack' for now as 'messageBack' doesn't work properly in emulator.) | ||
@@ -196,4 +196,4 @@ * | ||
*/ | ||
static actions(actions: (activity.CardAction|string)[]|undefined): activity.CardAction[] { | ||
const list: activity.CardAction[] = []; | ||
static actions(actions: (CardAction|string)[]|undefined): CardAction[] { | ||
const list: CardAction[] = []; | ||
(actions || []).forEach((a) => { | ||
@@ -203,3 +203,3 @@ if (typeof a === 'object') { | ||
} else { | ||
list.push({ type: 'imBack', value: a.toString(), title: a.toString() }); | ||
list.push({ type: ActionTypes.ImBack, value: a.toString(), title: a.toString() }); | ||
} | ||
@@ -215,4 +215,4 @@ }); | ||
*/ | ||
static images(images: (activity.CardImage|string)[]|undefined): activity.CardImage[] { | ||
const list: activity.CardImage[] = []; | ||
static images(images: (CardImage|string)[]|undefined): CardImage[] { | ||
const list: CardImage[] = []; | ||
(images || []).forEach((img) => { | ||
@@ -233,4 +233,4 @@ if (typeof img === 'object') { | ||
*/ | ||
static media(links: (activity.MediaUrl|string)[]|undefined): activity.MediaUrl[] { | ||
const list: activity.MediaUrl[] = []; | ||
static media(links: (MediaUrl|string)[]|undefined): MediaUrl[] { | ||
const list: MediaUrl[] = []; | ||
(links || []).forEach((lnk) => { | ||
@@ -247,9 +247,9 @@ if (typeof lnk === 'object') { | ||
function mediaCard(contentType: string, | ||
title: string, | ||
media: (activity.MediaUrl|string)[], | ||
buttons?: (activity.CardAction|string)[], | ||
other?: any): activity.Attachment | ||
function mediaCard(contentType: string, | ||
title: string, | ||
media: (MediaUrl|string)[], | ||
buttons?: (CardAction|string)[], | ||
other?: any): Attachment | ||
{ | ||
const card: activity.VideoCard = Object.assign({}, other); | ||
const card: VideoCard = Object.assign({}, other); | ||
if (title) { card.title = title; } | ||
@@ -256,0 +256,0 @@ if (media) { card.media = CardStyler.media(media); } |
@@ -5,3 +5,3 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
@@ -12,3 +12,3 @@ */ | ||
import { BotService } from './botService'; | ||
import { Activity } from './activity'; | ||
import { Activity } from 'botbuilder-schema'; | ||
@@ -35,6 +35,6 @@ export declare type SimpleTemplateFunction = (context: BotContext, data: Object) => Partial<Activity> | string | undefined; | ||
* "en" : { | ||
* "templateId": (context, data) => `your name is ${data.name}` | ||
* "templateId": (context, data) => `your name is ${data.name}` | ||
* } | ||
* } | ||
* | ||
* | ||
* To use, simply add to your pipeline | ||
@@ -41,0 +41,0 @@ * bot.use(new DictionaryRenderer(myTemplates)) |
@@ -5,3 +5,3 @@ /** | ||
/** second comment block */ | ||
import { Entity } from './activity'; | ||
import { Entity } from 'botbuilder-schema'; | ||
@@ -8,0 +8,0 @@ /** |
@@ -139,9 +139,4 @@ /** | ||
private hasExactMatch(intents: Intent[]): boolean { | ||
intents.forEach((intent) => { | ||
if (intent.score >= 1.0) { | ||
return true; | ||
} | ||
}); | ||
return false; | ||
return intents.filter((intent) => intent.score >= 1.0).length > 0; | ||
} | ||
} |
@@ -5,3 +5,3 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
@@ -12,3 +12,3 @@ */ | ||
import { BotService } from './botService'; | ||
import { Activity } from './activity'; | ||
import { Activity } from 'botbuilder-schema'; | ||
@@ -91,4 +91,4 @@ /** | ||
* @param data Data object to render template against. | ||
* @param postProcess (Optional) if `true` the rendered output object will be scanned looking | ||
* for any processing directives, such as @prune. The default value is `true`. | ||
* @param postProcess (Optional) if `true` the rendered output object will be scanned looking | ||
* for any processing directives, such as @prune. The default value is `true`. | ||
*/ | ||
@@ -109,3 +109,3 @@ public renderAsJSON(name: string, data: Object, postProcess?: boolean): any { | ||
* like @prune. | ||
* @param object Object to post process. | ||
* @param object Object to post process. | ||
*/ | ||
@@ -125,3 +125,3 @@ public postProcess(object: any): any { | ||
* @param json The JSON template to compile. | ||
* @param templates (Optional) map of template functions (and other compiled templates) that | ||
* @param templates (Optional) map of template functions (and other compiled templates) that | ||
* can be called at render time. | ||
@@ -143,3 +143,3 @@ */ | ||
// - Templates can be executed as children of other templates so the path | ||
// specifies the property off the parent to execute the template for. | ||
// specifies the property off the parent to execute the template for. | ||
let obj = ''; | ||
@@ -146,0 +146,0 @@ if (path) { |
@@ -5,8 +5,7 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import * as activity from './activity'; | ||
import { CardStyler } from './cardStyler'; | ||
import { ActivityTypes, AttachmentLayoutTypes, Activity, CardAction, SuggestedActions, Attachment, InputHints } from 'botbuilder-schema'; | ||
@@ -47,9 +46,11 @@ /** | ||
* @param speak (Optional) SSML to include in the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static text(text: string, speak?: string): Partial<activity.Activity> { | ||
const msg: Partial<activity.Activity> = { | ||
type: activity.ActivityTypes.message, | ||
static text(text: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
const msg: Partial<Activity> = { | ||
type: ActivityTypes.Message, | ||
text: text || '' | ||
}; | ||
if (speak) { msg.speak = speak; } | ||
if (speak) { msg.speak = speak } | ||
if (inputHint) { msg.inputHint = inputHint } | ||
return msg; | ||
@@ -62,9 +63,10 @@ } | ||
* @param actions Array of card actions or strings to include. Strings will be converted to `messageBack` actions. | ||
* @param text (Optional) text of the message. | ||
* @param text (Optional) text of the message. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static suggestedActions(actions: (activity.CardAction|string)[], text?: string, speak?: string): Partial<activity.Activity> { | ||
const msg: Partial<activity.Activity> = { | ||
type: activity.ActivityTypes.message, | ||
suggestedActions: <activity.SuggestedActions>{ | ||
static suggestedActions(actions: (CardAction|string)[], text?: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
const msg: Partial<Activity> = { | ||
type: ActivityTypes.Message, | ||
suggestedActions: <SuggestedActions>{ | ||
actions: CardStyler.actions(actions) | ||
@@ -74,3 +76,4 @@ } | ||
if (text) { msg.text = text; } | ||
if (speak) { msg.speak = speak; } | ||
if (speak) { msg.speak = speak } | ||
if (inputHint) { msg.inputHint = inputHint } | ||
return msg; | ||
@@ -83,8 +86,9 @@ } | ||
* @param attachment Adaptive card to include in the message. | ||
* @param text (Optional) text of the message. | ||
* @param text (Optional) text of the message. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static attachment(attachment: activity.Attachment, text?: string, speak?: string): Partial<activity.Activity> { | ||
return attachmentActivity(activity.AttachmentLayouts.list, [attachment], text, speak); | ||
} | ||
static attachment(attachment: Attachment, text?: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
return attachmentActivity(AttachmentLayoutTypes.List, [attachment], text, speak, inputHint); | ||
} | ||
@@ -95,7 +99,8 @@ /** | ||
* @param attachments Array of attachments to include in the message. | ||
* @param text (Optional) text of the message. | ||
* @param text (Optional) text of the message. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static list(attachments: activity.Attachment[], text?: string, speak?: string): Partial<activity.Activity> { | ||
return attachmentActivity(activity.AttachmentLayouts.list, attachments, text, speak); | ||
static list(attachments: Attachment[], text?: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
return attachmentActivity(AttachmentLayoutTypes.List, attachments, text, speak, inputHint); | ||
} | ||
@@ -120,7 +125,8 @@ | ||
* @param attachments Array of attachments to include in the message. | ||
* @param text (Optional) text of the message. | ||
* @param text (Optional) text of the message. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static carousel(attachments: activity.Attachment[], text?: string, speak?: string): Partial<activity.Activity> { | ||
return attachmentActivity(activity.AttachmentLayouts.carousel, attachments, text, speak); | ||
static carousel(attachments: Attachment[], text?: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
return attachmentActivity(AttachmentLayoutTypes.Carousel, attachments, text, speak, inputHint); | ||
} | ||
@@ -143,9 +149,10 @@ | ||
* @param name (Optional) Name of the image/video file. | ||
* @param text (Optional) text of the message. | ||
* @param text (Optional) text of the message. | ||
* @param speak (Optional) SSML to include with the message. | ||
* @param inputHint (Optional) input hint for the message. | ||
*/ | ||
static contentUrl(url: string, contentType: string, name?: string, text?: string, speak?: string): Partial<activity.Activity> { | ||
const a: activity.Attachment = { contentType: contentType, contentUrl: url }; | ||
static contentUrl(url: string, contentType: string, name?: string, text?: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
const a: Attachment = { contentType: contentType, contentUrl: url }; | ||
if (name) { a.name = name; } | ||
return attachmentActivity(activity.AttachmentLayouts.list, [a], text, speak); | ||
return attachmentActivity(AttachmentLayoutTypes.List, [a], text, speak, inputHint); | ||
} | ||
@@ -155,15 +162,12 @@ } | ||
function attachmentActivity(attachmentLayout: string, attachments: activity.Attachment[], text?: string, speak?: string): Partial<activity.Activity> { | ||
const msg: Partial<activity.Activity> = { | ||
type: activity.ActivityTypes.message, | ||
function attachmentActivity(attachmentLayout: AttachmentLayoutTypes, attachments: Attachment[], text?: string, speak?: string, inputHint?: InputHints|string): Partial<Activity> { | ||
const msg: Partial<Activity> = { | ||
type: ActivityTypes.Message, | ||
attachmentLayout: attachmentLayout, | ||
attachments: attachments | ||
}; | ||
if (text) { | ||
msg.text = text; | ||
} | ||
if (speak) { | ||
msg.speak = speak; | ||
} | ||
if (text) { msg.text = text } | ||
if (speak) { msg.speak = speak } | ||
if (inputHint) { msg.inputHint = inputHint } | ||
return msg; | ||
} |
@@ -5,9 +5,9 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
/** | ||
* Type signature for a return value that can (Optionally) return its value | ||
* Type signature for a return value that can (Optionally) return its value | ||
* asynchronously using a Promise. | ||
@@ -26,16 +26,16 @@ * @param T (Optional) type of value being returned. This defaults to `void`. | ||
/** | ||
/** | ||
* Implemented by middleware plugins. Plugins have four separate methods they can implement to tap | ||
* into the life cycle of a request. When an activity is received from a user, middleware plugins | ||
* into the life cycle of a request. When an activity is received from a user, middleware plugins | ||
* will have their methods invoked in the following sequence: | ||
* | ||
* >> [contextCreated()](#contextcreated) -> [receiveActivity()](#receiveactivity) -> (bots logic) | ||
* | ||
* >> [contextCreated()](#contextcreated) -> [receiveActivity()](#receiveactivity) -> (bots logic) | ||
* -> [postActivity()](#postactivity) -> [contextDone()](#contextdone) | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
*/ | ||
export interface Middleware { | ||
/** | ||
* (Optional) called when a new context object has been created. Plugins can extend the | ||
/** | ||
* (Optional) called when a new context object has been created. Plugins can extend the | ||
* context object in this call. | ||
@@ -49,4 +49,4 @@ * | ||
/** | ||
* (Optional) called after [contextCreated](#contextCreated) to route a received activity. | ||
* Plugins can return `{ handled: true }` to indicate that they have successfully routed | ||
* (Optional) called after [contextCreated](#contextCreated) to route a received activity. | ||
* Plugins can return `{ handled: true }` to indicate that they have successfully routed | ||
* the activity. This will prevent further calls to `receiveActivity()`. | ||
@@ -67,3 +67,3 @@ * | ||
*/ | ||
postActivity?(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]>; | ||
postActivity?(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ResourceResponse[]>): Promise<ResourceResponse[]>; | ||
} |
@@ -5,6 +5,6 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { Activity, ConversationResourceResponse } from './activity'; | ||
import { Activity, ResourceResponse } from 'botbuilder-schema'; | ||
import { Middleware } from './middleware'; | ||
@@ -26,3 +26,3 @@ | ||
} | ||
/** | ||
@@ -78,4 +78,4 @@ * Registers middleware plugin(s) with the bot or set. | ||
public postActivity(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]> { | ||
function callMiddleware(set: Middleware[], i: number): Promise<ConversationResourceResponse[]> { | ||
public postActivity(context: BotContext, activities: Partial<Activity>[], next: () => Promise<ResourceResponse[]>): Promise<ResourceResponse[]> { | ||
function callMiddleware(set: Middleware[], i: number): Promise<ResourceResponse[]> { | ||
try { | ||
@@ -82,0 +82,0 @@ if (i < set.length) { |
@@ -18,4 +18,4 @@ /** | ||
/** | ||
* Minimum score, on a scale from 0.0 to 1.0, that should be returned for a matched | ||
* expression. This defaults to a value of 0.0. | ||
* Minimum score, on a scale from 0.0 to 1.0, that should be returned for a matched | ||
* expression. This defaults to a value of 0.0. | ||
*/ | ||
@@ -26,8 +26,8 @@ minScore: number; | ||
/** | ||
* An intent recognizer for detecting the users intent using a series of regular expressions. | ||
* | ||
* One of the primary advantages of using a RegExpRecognizer is that you can easily switch between | ||
* An intent recognizer for detecting the users intent using a series of regular expressions. | ||
* | ||
* One of the primary advantages of using a RegExpRecognizer is that you can easily switch between | ||
* the use of regular expressions and a LUIS model. This could be useful for running unit tests | ||
* locally without having to make a cloud request. | ||
* | ||
* | ||
* The other advantage for non-LUIS bots is that it potentially lets your bot support multiple | ||
@@ -39,3 +39,3 @@ * languages by providing a unique set of expressions for each language. | ||
* ```js | ||
* import { RegExpRecognizer } from 'botbuilder-core'; | ||
* import { RegExpRecognizer } from 'botbuilder'; | ||
* | ||
@@ -46,3 +46,3 @@ * // Define RegExp's for well known commands. | ||
* .addIntent('CancelIntent', /^cancel/i); | ||
* | ||
* | ||
* // init bot and bind to adapter | ||
@@ -84,4 +84,4 @@ * const bot = new Bot(adapter); | ||
} | ||
this.onRecognize((context) => { | ||
this.onRecognize((context) => { | ||
const intents: Intent[] = []; | ||
@@ -172,4 +172,4 @@ const utterance = (context.request.text || '').trim(); | ||
* Matches a text string using the given expression. If matched, an `Intent` will be returned | ||
* containing a coverage score, from 0.0 to 1.0, indicating how much of the text matched | ||
* the expression. The more of the text the matched the greater the score. The name of | ||
* containing a coverage score, from 0.0 to 1.0, indicating how much of the text matched | ||
* the expression. The more of the text the matched the greater the score. The name of | ||
* the intent will be the value of `expression.toString()` and any capture groups will be | ||
@@ -180,6 +180,6 @@ * returned as individual entities of type `string`. | ||
* @param expression The expression to match. | ||
* @param entityTypes (Optional) array of types to assign to each entity returned for a numbered | ||
* @param entityTypes (Optional) array of types to assign to each entity returned for a numbered | ||
* capture group. As an example, for the expression `/flight from (.*) to (.*)/i` you could | ||
* pass a value of `['fromCity', 'toCity']`. The entity returned for the first capture group will | ||
* have a type of `fromCity` and the entity for the second capture group will have a type of | ||
* have a type of `fromCity` and the entity for the second capture group will have a type of | ||
* `toCity`. The default entity type returned when not specified is `string`. | ||
@@ -189,5 +189,5 @@ * @param minScore (Optional) minimum score to return for the coverage score. The default value | ||
* minScore and 1.0. For example, a expression that matches 50% of the text will result in a | ||
* base coverage score of 0.5. If the minScore supplied is also 0.5 the returned score will be | ||
* scaled to be 0.75 or 50% between 0.5 and 1.0. As another example, providing a minScore of 1.0 | ||
* will always result in a match returning a score of 1.0. | ||
* base coverage score of 0.5. If the minScore supplied is also 0.5 the returned score will be | ||
* scaled to be 0.75 or 50% between 0.5 and 1.0. As another example, providing a minScore of 1.0 | ||
* will always result in a match returning a score of 1.0. | ||
*/ | ||
@@ -204,3 +204,3 @@ static recognize(text: string, expression: RegExp, entityTypes: string[] = [], minScore = 0.0): Intent|undefined { | ||
const score = minScore + ((1.0 - minScore) * coverage); | ||
// Populate entities | ||
@@ -207,0 +207,0 @@ const entities: EntityObject<string>[] = []; |
@@ -5,16 +5,15 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { Middleware, Promiseable } from './middleware'; | ||
import { Activity, ConversationReference, ActivityTypes, ConversationResourceResponse, applyConversationReference } from './activity'; | ||
import { Activity, ConversationReference, ActivityTypes, ResourceResponse } from 'botbuilder-schema'; | ||
/** Interface for a template renderer which provides the ability | ||
/** Interface for a template renderer which provides the ability | ||
* to create a text reply or activity reply from the language, templateid and data object | ||
**/ | ||
export interface TemplateRenderer { | ||
/** | ||
* renders a template for the language/templateId | ||
* | ||
/** | ||
* renders a template for the language/templateId | ||
* | ||
* @param language id (such as 'en') | ||
@@ -36,7 +35,7 @@ * @param templateId id of the template to apply | ||
public async postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ConversationResourceResponse[]>): Promise<ConversationResourceResponse[]> { | ||
public async postActivity(context: BotContext, activities: Partial<Activity>[], next: (newActivities?: Partial<Activity>[]) => Promise<ResourceResponse[]>): Promise<ResourceResponse[]> { | ||
// Ensure activities are well formed. | ||
for (let i = 0; i < activities.length; i++) { | ||
let activity = activities[i]; | ||
if (activity.type == "template") { | ||
if (activity.type == <ActivityTypes>"template") { | ||
await this.bindActivityTemplate(context, activity); | ||
@@ -50,3 +49,3 @@ } | ||
* register template renderer | ||
* @param renderer | ||
* @param renderer | ||
*/ | ||
@@ -66,3 +65,3 @@ public register(renderer: TemplateRenderer): TemplateManager { | ||
/** | ||
* SetLanguagePolicy allows you to set the fallback strategy | ||
* SetLanguagePolicy allows you to set the fallback strategy | ||
* @param fallback array of languages to try when binding templates | ||
@@ -87,3 +86,3 @@ */ | ||
if (!(templateOutput as Activity).type) { | ||
templateOutput.type = ActivityTypes.message; | ||
templateOutput.type = ActivityTypes.Message; | ||
} | ||
@@ -93,3 +92,3 @@ return <Partial<Activity>>templateOutput; | ||
const activity: Partial<Activity> = { | ||
type: ActivityTypes.message, | ||
type: ActivityTypes.Message, | ||
text: templateOutput || '', | ||
@@ -110,6 +109,6 @@ }; | ||
fallbackLocales.push('default'); | ||
// Ensure activities are well formed. | ||
// bind any template activity | ||
if (activity.type == "template") { | ||
if (activity.type == <ActivityTypes>"template") { | ||
// try each locale until successful | ||
@@ -116,0 +115,0 @@ for (let locale of fallbackLocales) { |
@@ -5,7 +5,7 @@ /** | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { ActivityAdapter } from './activityAdapter'; | ||
import { Activity, ActivityTypes, ConversationReference } from './activity'; | ||
import { ActivityTypes, Activity, ConversationReference, ChannelAccount } from 'botbuilder-schema'; | ||
import { Promiseable } from './middleware'; | ||
@@ -37,3 +37,3 @@ import assert = require('assert'); | ||
public reference: ConversationReference; | ||
public botReplies: Activity[] = []; | ||
public botReplies: Partial<Activity>[] = []; | ||
@@ -45,3 +45,3 @@ /** INTERNAL implementation of `Adapter.onReceive`. */ | ||
* Creates a new instance of the test adapter. | ||
* @param reference (Optional) conversation reference that lets you customize the address | ||
* @param reference (Optional) conversation reference that lets you customize the address | ||
* information for messages sent during a test. | ||
@@ -69,7 +69,7 @@ */ | ||
// ready for next reply | ||
let activity = <Activity>(typeof userSays === 'string' ? { type:ActivityTypes.message, text: userSays } : userSays); | ||
if (!activity.type) | ||
let activity = <Activity>(typeof userSays === 'string' ? { type:ActivityTypes.Message, text: userSays } : userSays); | ||
if (!activity.type) | ||
throw new Error("Missing activity.type"); | ||
activity.channelId = this.reference.channelId; | ||
activity.from = this.reference.user; | ||
activity.from = <ChannelAccount>this.reference.user; | ||
activity.recipient = this.reference.bot; | ||
@@ -106,3 +106,3 @@ activity.conversation = this.reference.conversation; | ||
*/ | ||
public test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
public test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
return this.send(userSays) | ||
@@ -118,3 +118,3 @@ .assertReply(expected, description); | ||
*/ | ||
public assertReply(expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
public assertReply(expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
return new TestFlow(Promise.resolve(), this).assertReply(expected, description, timeout); | ||
@@ -149,3 +149,3 @@ } | ||
*/ | ||
public test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
public test(userSays: string | Partial<Activity>, expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
if (!expected) | ||
@@ -167,7 +167,7 @@ throw new Error(".test() Missing expected parameter"); | ||
* Throws if the bot's response doesn't match the expected text/activity | ||
* @param expected expected text or activity from the bot, or callback to inspect object | ||
* @param expected expected text or activity from the bot, or callback to inspect object | ||
* @param description description of test case | ||
* @param timeout (default 3000ms) time to wait for response from bot | ||
*/ | ||
public assertReply(expected: string | Partial<Activity> | ((activity: Activity, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
public assertReply(expected: string | Partial<Activity> | ((activity: Partial<Activity>, description?: string) => void), description?: string, timeout?: number): TestFlow { | ||
if (!expected) | ||
@@ -185,3 +185,3 @@ throw new Error(".assertReply() Missing expected parameter"); | ||
if ((current - start) > <number>timeout) { | ||
let expectedActivity = <Activity>(typeof expected === 'string' ? { type: ActivityTypes.message, text: expected } : expected); | ||
let expectedActivity = <Activity>(typeof expected === 'string' ? { type: ActivityTypes.Message, text: expected } : expected); | ||
throw new Error(`${timeout}ms Timed out waiting for:${description || expectedActivity.text}`); | ||
@@ -198,3 +198,3 @@ } | ||
} else if (typeof expected === 'string') { | ||
assert.equal(botReply.type, ActivityTypes.message, (description || '') + ` type === '${botReply.type}'. `); | ||
assert.equal(botReply.type, ActivityTypes.Message, (description || '') + ` type === '${botReply.type}'. `); | ||
assert.equal(botReply.text, expected, (description || '') + ` text === "${botReply.text}"`); | ||
@@ -201,0 +201,0 @@ } else { |
@@ -239,3 +239,3 @@ const assert = require('assert'); | ||
assert(a.type === 'endOfConversation'); | ||
assert(a.code === builder.EndOfConversationCodes.completedSuccessfully) | ||
assert(a.code === builder.EndOfConversationCodes.CompletedSuccessfully) | ||
}) | ||
@@ -246,3 +246,3 @@ .then(() => done()); | ||
it('should send endOfConversation() with a custom code', function (done) { | ||
const code = builder.EndOfConversationCodes.botTimedOut; | ||
const code = builder.EndOfConversationCodes.BotTimedOut; | ||
const testAdapter = new builder.TestAdapter(); | ||
@@ -311,3 +311,3 @@ const bot = new builder.Bot(testAdapter) | ||
return next(); | ||
} | ||
} | ||
}) | ||
@@ -314,0 +314,0 @@ .onReceive((context) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
391708
2
107
8187
+ Addedadaptivecards@1.2.3(transitive)
+ Addedbotframework-schema@4.23.1(transitive)
+ Addeduuid@10.0.0(transitive)
+ Addedzod@3.24.1(transitive)