本文整理汇总了TypeScript中botbuilder.UniversalBot.dialog方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UniversalBot.dialog方法的具体用法?TypeScript UniversalBot.dialog怎么用?TypeScript UniversalBot.dialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botbuilder.UniversalBot
的用法示例。
在下文中一共展示了UniversalBot.dialog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: UniversalBot
let bot = new UniversalBot(connector);
server.post('/api/messages', connector.listen());
bot.on('installationUpdate', (activity: IEvent) => {
let token = activity.sourceEvent.token;
let message = new Message()
.address(activity.address)
.text(token);
bot.send(message);
});
let intents = new IntentDialog();
bot.dialog('/', intents);
intents.matches(/^hello/, [
(session) => session.beginDialog('/hello')
]);
intents.onDefault([
(session, args, next) => {
if (!session.userData.address)
session.beginDialog("/hello");
else
next();
},
(session) => {
session.send("Hello %s", session.userData.address);
}
示例2: function
//
// Bots Dialogs
//
var mainDialog = new builder.IntentDialog();
mainDialog.matches(/\bspam\b/i, function(session, args, next) {
let splt = session.message.text.split(' ');
let spamAmount = Number(splt[1]) || 100;
for (var i = 0; i < spamAmount; i++) {
session.send(getCounter(session));
}
});
mainDialog.onDefault(function(session, args, next) {
session.send("%s, you said %s", getCounter(session), session.message.text);
});
bot.dialog('/', mainDialog);
//
// Payments
//
mainDialog.matches(/\bpayment\b/i, function(session, args, next) {
let buyCard = new builder.HeroCard(session);
buyCard.title("Product card")
.text("Press button to open payment window.")
.buttons([
{
"title": "Buy",
"type": "payment",
"value": paymentRequest
}
]);