本文整理汇总了TypeScript中botbuilder.Prompts类的典型用法代码示例。如果您正苦于以下问题:TypeScript Prompts类的具体用法?TypeScript Prompts怎么用?TypeScript Prompts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Prompts类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
(session: builder.Session, args: any, next?: (results?: builder.IDialogResult<any>) => void) => {
let place: IStoredData;
let heathplace: boolean = false
if (args && args.intent) {
let intent = args.intent;
// Get Place.Type and Place.Location entities
let typeEntity: IEntityEx = builder.EntityRecognizer.findEntity(intent.entities, 'Place.Type') as IEntityEx;
let locationEntity: IEntityEx = builder.EntityRecognizer.findEntity(intent.entities, 'Place.Location') as IEntityEx;
place = session.dialogData.place = {
type: typeEntity ? typeEntity.resolution.values[0] : undefined,
location: locationEntity ? locationEntity.entity : undefined,
};
// We want to manage only medical places
heathplace = place.type == 'hospital' || place.type == 'pharmacy';
}
if (!heathplace) {
builder.Prompts.choice(session, "choice_prompt", "hospital|pharmacy", { listStyle: ListStyle.button });
}
else {
if (next) return next();
}
},
示例2: RegExp
(session: builder.Session, results: any, next?: (results?: builder.IDialogResult<any>) => void) => {
let userAnswer : string = results.response;
let pattern = new RegExp(/^unknown/i );
let matches = userAnswer.match(pattern);
if (matches) {
return session.endDialogWithResult({ response: "unknown" })
}
if (results && results.response) {
let searchLanguage = countrydata.getVisionLanguageByName(results.response);
if (searchLanguage && searchLanguage.length == 1) {
let result = {
language: searchLanguage[0].name,
languageCode: searchLanguage[0].code
};
return session.endDialogWithResult({ response: result });
} else if (searchLanguage && searchLanguage.length > 1) {
let choices = new Array<string>();
searchLanguage.forEach(element => {
choices.push(element.name);
});
return builder.Prompts.choice(session, "Please select an option:", choices, {listStyle : ListStyle.button})
}
}
session.send("image_default_language");
return session.replaceDialog("language-dialog");
},
示例3: function
function (session, args, next) {
if (!session.userData.nameAlreadyAsked) {
builder.Prompts.text(session, "May i know your name please?");
}
else {
next();
}
},
示例4:
(session, args, next) => {
const botName = '<%= botName %>';
const description = `<%= botDescription %>`;
session.send(`Hi there! I'm ${botName}`);
session.send(`In a nutshell, here's what I can do:\n\n${description}`);
builder.Prompts.text(session, `What's your name?`);
},
示例5: function
function(session, args, next) {
console.log("args :: \n" + JSON.stringify(args.entities));
var symbol = builder.EntityRecognizer.findEntity(args.entities, 'company');
if (!symbol) {
builder.Prompts.text(session, "Which company stock you are intrested in?");
} else {
next({ response: symbol.entity });
}
},
示例6: function
function (session, args) {
var qnaMakerResult = args as IQnAMakerResults;
session.dialogData.qnaMakerResult = qnaMakerResult;
var questionOptions: string[] = [];
qnaMakerResult.answers.forEach(function (qna: IQnAMakerResult) { questionOptions.push(qna.questions[0]); });
questionOptions.push("None of the above.");
var promptOptions: builder.IPromptOptions = {listStyle: builder.ListStyle.button, maxRetries: 0};
builder.Prompts.choice(session, "Did you mean:", questionOptions, promptOptions);
},
示例7: next
(session: Session, luisResults: IIntentRecognizerResult, next: (results?: IDialogResult<any>) => void) => {
const languageEntity = EntityRecognizer.findEntity(luisResults.entities, 'language');
const language = languageEntity && languageEntity.entity;
if (!language) {
Prompts.choice(session, 'master.languageSelection', Object.keys(languages),
{ listStyle: ListStyle.button, maxRetries: 3, retryPrompt: 'master.retryLanguageSelection' });
} else {
next({ response: { entity: language }});
}
},
示例8: function
function (session, results, next) {
if (true === results.response) {
session.userData.channelSearchResultsShown = false;
builder.Prompts.text(session, "Hey .. thatâs cool.. Can i have the channel names which you are looking for?");
}
else {
delete session.userData.channelSearchResultsShown;
session.endDialog("Thanks! Say 'Hi', if you want to chat with me again...");
}
},
示例9: function
function(session: any) {
if(this.criteria["type"] === "choice"){
var choices:any = [];
for(var choice of this.criteria["choices"]){
choices.push(choice.value);
}
builder.Prompts.choice(session, this.criteria["question"], choices);
}
//https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.luisrecognizer.html
else {
builder.Prompts[this.criteria["type"]](session, this.criteria["question"], null );
}
}, function(session: any, results: any) {