本文整理汇总了TypeScript中botbuilder.UniversalBot类的典型用法代码示例。如果您正苦于以下问题:TypeScript UniversalBot类的具体用法?TypeScript UniversalBot怎么用?TypeScript UniversalBot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UniversalBot类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createServer
import { createServer } from 'restify';
import { ChatConnector, IEvent, IntentDialog, Message, Prompts, UniversalBot } from 'botbuilder';
const server = createServer();
server.listen(process.env.PORT || 3978, () => console.log('%s listening to %s', server.name, server.url));
let connector = new ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
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')
]);
开发者ID:duncanmak,项目名称:mr-robot,代码行数:30,代码来源:app.ts
示例2: require
var restify = require('restify');
var builder = require('botbuilder');
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function() {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat bot
var connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());
//
// Main methods
//
function getCounter(session): string {
if (!session.dialogData.hasOwnProperty('counter')) {
session.dialogData.counter = 0;
}
session.dialogData.counter++;
return `Message #${session.dialogData.counter}`;
}
//
// Bots Dialogs
开发者ID:kpreeti096,项目名称:BotFramework-Emulator,代码行数:31,代码来源:testBot.ts
示例3: Message
bot.on('installationUpdate', (activity: IEvent) => {
let token = activity.sourceEvent.token;
let message = new Message()
.address(activity.address)
.text(token);
bot.send(message);
});
开发者ID:duncanmak,项目名称:mr-robot,代码行数:9,代码来源:app.ts
示例4: switch
connector.getData(storageCtx, (err, data) => {
switch (invoke.name) {
case 'payments/update/shippingAddress':
case 'payments/update/shippingOption':
console.log("updatedshipping info");
callback(null, {}, 200);
break;
case 'payments/complete':
console.log("completed payment request");
callback(null, {result: "success"}, 200);
bot.beginDialog(invoke.relatesTo, 'checkout_receipt');
break;
}
});
开发者ID:kpreeti096,项目名称:BotFramework-Emulator,代码行数:15,代码来源:testBot.ts
示例5:
message.membersAdded.forEach((identity: IIdentity) => {
if (identity.id !== message.address.bot.id) {
bot.beginDialog(message.address, "greetings:start");
}
});
开发者ID:LucasChies,项目名称:Medication-Helper-idtpoa,代码行数:5,代码来源:app.ts
注:本文中的botbuilder.UniversalBot类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论