当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript DialogAction.send方法代码示例

本文整理汇总了TypeScript中botbuilder.DialogAction.send方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DialogAction.send方法的具体用法?TypeScript DialogAction.send怎么用?TypeScript DialogAction.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botbuilder.DialogAction的用法示例。


在下文中一共展示了DialogAction.send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: addDialogs

    addDialogs() {
        let dialog = new LuisDialog(this.luisUrl);
		console.log('dialog is ', dialog);
        this.bot.add('/', dialog);
        
        dialog.on('FindItemLevel', [
            this.processLanguage,
            this.getCharacterName,
            this.getRealm,
            this.getIlvl
        ]);
        
        dialog.onDefault(DialogAction.send("I could not understand your request."));
    }
开发者ID:DHainzl,项目名称:ILvlBot,代码行数:14,代码来源:ILvlBot.ts

示例2: function

    function (session, results, next) {
        if (results.response && !session.userData.zipCode) {
            var zipAndState = "";
            var zipCode = "";

            var userResponse = results.response;

            var zipAndStatePattern = "\\w{2}\\s\\d{5}";
            var regExpZipAndStatePattern = new RegExp(zipAndStatePattern);
            if (regExpZipAndStatePattern.test(userResponse)) {
                var zipAndStateArr = regExpZipAndStatePattern.exec(userResponse);
                if (null != zipAndStateArr) {
                    zipAndState = zipAndStateArr[0];

                    var zipCodePattern = new RegExp("\\d{5}");
                    var zipCodeArr = zipCodePattern.exec(zipAndState);
                    if (null != zipCodeArr) {
                        zipCode = zipCodeArr[0];
                    }
                }
                if (null != zipCode && zipCode.trim().length > 0) {
                    session.userData.zipCode = zipCode;
                    builder.DialogAction.send("Please wait while checking the service availability...");
                    var Client = require('node-rest-client').Client;
                    var client = new Client();
                    // set content-type header and data as json in args parameter 
                    var args = {
                        headers: { "Content-Type": "application/json" }
                    };
                    client.get("http://fiosserviceavailabilityapp.azurewebsites.net/zipcode/" + zipCode, args, function (data, response) {
                        // parsed response body as js object 
                        var result = data["status"];
                        if (result) {
                            session.userData.serviceAvailable = true;
                            var msg = "Great! " + session.userData.selectedOffer + " is available in your address with the zip code:" + zipCode + "\n\n" +
                                "To recommend best plan, can u tell me your usage..like do u use internet more or tv...etc.";
                            builder.Prompts.text(session, msg);
                        }
                        else {
                            session.userData.serviceAvailable = false;
                            session.send("Sorry! " + session.userData.selectedOffer + " is unavailable in your address with the zip code:" + zipCode);
                        }
                    });
                }
            }
            else {
                //Pl. provide the valid zip code.
                //session.userData.zipCode = null;
                session.send("Sorry! " + "I dont see the zip code in the address you provided...\nPlease provide me the address with zip code.");
                //session.replaceDialog("/showOffer");
            }
        }
        else {
            if (!session.userData.serviceAvailable) {
                session.send("Sorry! " + session.userData.selectedOffer + " is unavailable in your address with the zip code:" + session.userData.zipCode);
            }
            else {
                next({ response: session.message.text });
            }            
        }
    },
开发者ID:giriganapathy,项目名称:VZChatBotApp,代码行数:61,代码来源:server.ts

示例3: QueryStockPrice

    }
]);

function QueryStockPrice(sclient: stockClient.StockClient, symbol: string, callBack: any) {
    sclient.getStockPrice(symbol, (error, data) => {
        if (error) console.log(error);
        if (data) {
            data.forEach((stockInfo) => {
                console.log(`${stockInfo.t} : ${stockInfo.l}`);
                callBack(`Here is the current stock value : "${stockInfo.t} ${stockInfo.l}" from ${stockInfo.e}.`);
            })
        };
    });
}

dialog.on("GetVersion", builder.DialogAction.send('StockBot version 0.1a'));

// Create bot and add dialogs
botService.on('contactRemoved', (bot, event) => {
    console.log(`We lost user ${event.from}.`);
});

botService.on('contactAdded', (bot, data) => {
    console.log("Contact Added");
    bot.reply(`Hello ${data.fromDisplayName}!`, true);
});

botService.on('message', (bot, data) => {
    console.log("message received ");
});
开发者ID:plkumar,项目名称:StockBot,代码行数:30,代码来源:server.ts

示例4: init

        public init(bot: any) {
            bot.dialog('/', this._dialog);

             bot.use({
                botbuilder: function (session: any, next:any) {
                    console.log('Message Received: ', session.message.text);
                    if(session.message.text === "--reset"){
                        session.endConversation();
                    }
                    else {
                        next();
                    }
                }
            });

            this._dialog.onDefault(builder.DialogAction.send("I'm sorry I didn't understand."));

            this._dialog.matches('BuyPC', [
                 (session: any, args: any, next: any) => {
                    var brand = builder.EntityRecognizer.findEntity(args.entities, 'PcBrand');
                    var type = builder.EntityRecognizer.findEntity(args.entities, 'PcType');
                    var price: any = {
                        'price' :  builder.EntityRecognizer.findEntity(args.entities, 'PcPrice'),
                        'startPrice' : builder.EntityRecognizer.findEntity(args.entities, 'PcPrice::startPrice'),
                        'endPrice' : builder.EntityRecognizer.findEntity(args.entities, 'PcPrice::endPrice')
                    };

                    var cam: any = null;

                    if (builder.EntityRecognizer.findEntity(args.entities, 'PcCam::With')) {
                        cam = true;
                    } else if (builder.EntityRecognizer.findEntity(args.entities, 'PcCam::Without')) {
                        cam = false;
                    }

                    var got_price: any = null;

                    for (var key in price) {
                        if (price[key]) {
                            got_price = true;
                            price[key] = price[key].entity;
                        }
                    }

                    session.userData.profile = {
                        brand: brand ? brand.entity : null,
                        type: type ? type.entity : null,
                        price: got_price ? price : null,
                        cam: cam
                    };

                    next();
                },
                this.criteria
            ]);

            this.set_dialogs(bot);

            this._dialog.matches('Hello', [
                (session: any, args: any, next: any) => {
                    session.send('Hello ! What can i do for you ?');
                }
            ]);

            bot.dialog('/productChoice', [
                 (session: any) => {
                    var msg = new builder.Message(session)
                    .textFormat(builder.TextFormat.xml)
                    .attachmentLayout(builder.AttachmentLayout.carousel)
                    .attachments([
                        new builder.HeroCard(session)
                            .title("Acer Swift 3")
                            .text("Ultra-Thin & Light")
                            .images([
                                builder.CardImage.create(session, "http://static.acer.com/up/Resource/Acer/Notebooks/Swift%203/Photogallery/20160823/Swift-3_Fingerprint_gold_gallery_04.png")
                                    .tap(builder.CardAction.showImage(session, "http://www.acer.com/ac/en/US/content/series/swift3"))
                            ])
                            .buttons([
                                builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
                                builder.CardAction.imBack(session, "Acer Swift 3", "Real store")
                            ]),
                        new builder.HeroCard(session)
                            .title("ASUS UX 360")
                            .text("360° of Freedom. 100% ZenBook.")
                            .images([
                                builder.CardImage.create(session, "http://www.ultrabookreview.com/wp-content/uploads/2016/06/asus-zenbook-ux360-3.jpg")
                                    .tap(builder.CardAction.showImage(session, "https://www.asus.com/us/Notebooks/ASUS-ZenBook-Flip-UX360CA/"))
                            ])
                            .buttons([
                                builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
                                builder.CardAction.imBack(session, "ASUS UX 360", "Real store")
                            ]),
                        new builder.HeroCard(session)
                            .title("LENOVO YOGA 900")
                            .text("The Yoga 900 is unbelievably thin and elegant.")
                            .images([
                                builder.CardImage.create(session, "http://winsupersite.com/site-files/winsupersite.com/files/gallery_images/02_Hero_Shot_VIDEO_Gold.jpg?1445276665")
                                    .tap(builder.CardAction.showImage(session, "http://winsupersite.com/site-files/winsupersite.com/files/gallery_images/02_Hero_Shot_VIDEO_Gold.jpg?1445276665"))
                            ])
                            .buttons([
//.........这里部分代码省略.........
开发者ID:DXFrance,项目名称:botretail,代码行数:101,代码来源:retailbot.dialogsManager.ts


注:本文中的botbuilder.DialogAction.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。