本文整理汇总了TypeScript中botbuilder.ChatConnector类的典型用法代码示例。如果您正苦于以下问题:TypeScript ChatConnector类的具体用法?TypeScript ChatConnector怎么用?TypeScript ChatConnector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChatConnector类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: function
bot.setup().then(() => {
// Listen to activities sent to the bot
const server = restify.createServer();
server.use(restify.plugins.queryParser());
server.listen(process.env.port || process.env.PORT || 3977, function () {
console.log('%s listening to %s', server.name, server.url);
});
server.post('/api/messages', connector.listen());
});
开发者ID:magencio,项目名称:UberBotNode_V3,代码行数:10,代码来源:app.ts
示例3: switch
connector.onInvoke((invoke, callback) => {
let storageCtx = {
address: invoke.relatesTo,
persistConversationData: true,
conversationId: invoke.relatesTo.conversation.id
};
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,代码行数:23,代码来源:testBot.ts
注:本文中的botbuilder.ChatConnector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论