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


TypeScript BotConnectorBot.add方法代码示例

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


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

示例1: function

});

bot.add("/userProfile", [
    function (session, args, next) {
        if (!session.userData.nameAlreadyAsked) {
            builder.Prompts.text(session, "May i know your name please?");
        }
        else {
            next();
        }
    },
    function (session, results) {
        builder.LuisDialog.recognize(session.message.text, modelUri, function (err, intents, entities) {
            if (null != err) {
                session.endDialog("Unexpected error while parsing your answer. Try again after sometime!");
                return;
            }
            session.userData.nameAlreadyAsked = true;
            var entity = builder.EntityRecognizer.findEntity(entities, 'name');
            if (null != entity) {
                session.userData.name = entity.entity;
                session.beginDialog("/showOffer");
            }
            else {
                session.send("I am sorry, i did not understand your answser. Please provide your name again.");
                //session.replaceDialog("/userProfile");
            }
        });
    }
]);

//bot.add("/", dialog);
开发者ID:giriganapathy,项目名称:VZChatBotApp,代码行数:32,代码来源:server.ts

示例2: if

bot.add("/", [
    function (session, args, next) {
        if (session.message.text.indexOf("set tv package") == -1) {
            if (!session.userData.channelSearchResultsShown) {
                if (null == session.userData.selectedPackageName || session.userData.selectedPackageName.length == 0) {
                    session.userData.selectedPackageName = fiosTVPackages["custom_tv_essentials"];
                }
                var packageInfo = "Your current TV package selection is  " + session.userData.selectedPackageName;
                
                builder.Prompts.confirm(session, packageInfo + "<br/>Are you looking for any specific channels in your package?");
            }
            else {
                if (session.userData.channelSearchResultsShown) {
                    var packageInfo = "Your current TV package selection is  " + session.userData.selectedPackageName;
                    builder.Prompts.confirm(session, packageInfo + "<br/>Are you still looking for any specific channels in your package?");
                }
                else {
                    next({ "response": true });
                }
            }
        }
        else if(session.message.text.indexOf("set tv package") != -1) {
            session.replaceDialog('/query-package-luis');
        }
    },
    function (session, results, next) {
        if (true === results.response) {
            if (!session.userData.channelSearchResultsShown || true == session.userData.channelSearchResultsShown) {
                session.userData.channelSearchResultsShown = false;
                builder.Prompts.text(session, "Hey .. that’s cool.. Can i have the channel names which you are looking for?");
            }
            else {
                session.beginDialog('/query-package-luis');
            }
        }
        else {
            delete session.userData.channelSearchResultsShown;
            session.replaceDialog('/ask-user');
            //session.endDialog("Thanks");
        }
    },
    function (session, results, next) {
        if (results.response) {
            session.beginDialog('/query-package-luis');
        }
        else {
            session.send("Sorry! i did not understand. Could you please provide me the channel name again 1?");
        }
    }

]);
开发者ID:giriganapathy,项目名称:FiOSPackageHelper,代码行数:51,代码来源:server.ts

示例3: function

bot.add("/", [
    function (session) {
        builder.Prompts.text(session, "Hello...What is your name?");
    },
    function (session, results) {
        session.userData.name = results.response;
        builder.Prompts.choice(session, "Hello " + session.userData.name + " Which product do you like to know the bundle availability?", ["FiOS", "FiOS - Triple Play", "FiOS - Double Play", "Standalone"]);
    },
    function (session, results) {
        session.userData.product = results.response.entity;
        builder.Prompts.number(session, "Can you please tell me your Zip Code?");
    },
    function (session, results) {
        session.userData.zipCode = results.response;
        builder.Prompts.text(session, "Can i have your address please");
    },
    function (session, results) {
        session.userData.address = results.response;
        builder.Prompts.text(session, "Can i tell your country code (2 Letter)");
    },
    function (session, results) {
        session.userData.countryCode = results.response;
        var stateInfo = "";
        var Client = require('node-rest-client').Client;
        var client = new Client();
        // set content-type header and data as json in args parameter 
        var args = {
            data: { test: "hello" },
            headers: { "Content-Type": "application/json" }
        };
        client.get("http://services.groupkt.com/state/get/" + session.userData.countryCode + "/all", args, function (data, response) {
            // parsed response body as js object 
            var result = data["RestResponse"]["result"];
            for (var idx = 0; idx < result.length; idx++) {
                var info = result[idx];
                stateInfo = stateInfo + info["country"] + "-" + info["name"] + ",";
                console.log(info["country"] + "-" + info["name"]);	
                //console.log(stateInfo);
            }
            session.send("Hello " + session.userData.name + "! I am going to check the " + session.userData.product +
                " availability for the address:" + session.userData.address + ", ZipCode:" + session.userData.zipCode +
                "\nList of States for your country code:" + session.userData.countryCode + "\n" + stateInfo);

        });
    }
]);
开发者ID:giriganapathy,项目名称:CheckServiceAvailabilityApp,代码行数:46,代码来源:server.ts

示例4: require

ďťż/*-----------------------------------------------------------------------------
This is a sample bot.
 
@author: giriganapathy
@since: May 5, 2016 01:32 PM
-----------------------------------------------------------------------------*/
var restify = require("restify");
var builder = require("botbuilder");

var model = process.env.model || "https://api.projectoxford.ai/luis/v1/application?id=83b0d263-bcb7-4ded-b197-95b25ee68030&subscription-key=b27a7109bc1046fb9cc7cfa874e3f819&q=";
var key = "embct6154";
var dialog = new builder.LuisDialog(model);

var bot = new builder.BotConnectorBot();//new builder.TextBot();

bot.add("/", dialog);

dialog.on("intent.pnr.enquiry", [
    function (session, args, next) {
        var entity = builder.EntityRecognizer.findEntity(args.entities, 'pnr-number');
        if (null != entity) {
            var pnrNumber = entity.entity;
            if (null != pnrNumber) {
                session.userData.pnrNumber = pnrNumber;
                var Client = require('node-rest-client').Client;
                var client = new Client();
                // set content-type header and data as json in args parameter 
                var options = {
                    headers: { "Content-Type": "application/json" }
                };
开发者ID:giriganapathy,项目名称:TrainStatusApp,代码行数:30,代码来源:server.ts


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