How to use the botbuilder-dialogs.TextPrompt function in botbuilder-dialogs

To help you get started, we’ve selected a few botbuilder-dialogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotFramework-Samples / docs-samples / V4 / JS / contosocafebot-luis-dialogs / lib / luisbot.js View on Github external
});
            }
        }
    }));
});
// Add dialogs
dialogs.add('default', [
    function (dc, args) {
        return __awaiter(this, void 0, void 0, function* () {
            const state = conversationState.get(dc.context);
            yield dc.context.sendActivity(`Hi! I'm the Contoso Cafe reservation bot. Say something like make a reservation."`);
            yield dc.end();
        });
    }
]);
dialogs.add('textPrompt', new botbuilder_dialogs_1.TextPrompt());
dialogs.add('dateTimePrompt', new botbuilder_dialogs_1.DatetimePrompt());
dialogs.add('reserveTable', [
    function (dc, args, next) {
        return __awaiter(this, void 0, void 0, function* () {
            var typedresult = args;
            // Call a helper function to save the entities in the LUIS result
            // to dialog state
            yield SaveEntities(dc, typedresult);
            yield dc.context.sendActivity("Welcome to the reservation service.");
            if (dc.activeDialog.state.dateTime) {
                yield next();
            }
            else {
                yield dc.prompt('dateTimePrompt', "Please provide a reservation date and time. We're open 4PM-8PM.");
            }
        });
github microsoft / BotBuilder-Samples / generators / generator-botbuilder / generators / app / templates / core / dialogs / greeting / greeting.js View on Github external
if (!dialogId) throw new Error('Missing parameter.  dialogId is required');
        if (!userProfileAccessor) throw new Error('Missing parameter.  userProfileAccessor is required');

        // Add a water fall dialog with 4 steps.
        // The order of step function registration is important
        // as a water fall dialog executes steps registered in order
        this.addDialog(new WaterfallDialog(PROFILE_DIALOG, [
            this.initializeStateStep.bind(this),
            this.promptForNameStep.bind(this),
            this.promptForCityStep.bind(this),
            this.displayGreetingStep.bind(this)
        ]));

        // Add text prompts for name and city
        this.addDialog(new TextPrompt(NAME_PROMPT, this.validateName));
        this.addDialog(new TextPrompt(CITY_PROMPT, this.validateCity));

        // Save off our state accessor for later use
        this.userProfileAccessor = userProfileAccessor;
    }
    /**
github microsoft / botbuilder-js / samples / dialogs / prompts-ts / lib / app.js View on Github external
// Continue the current dialog
            yield dc.continueDialog();
            // Show menu if no response sent
            if (!context.responded) {
                yield dc.beginDialog('mainMenu');
            }
        }
    }));
});
const dialogs = new botbuilder_dialogs_1.DialogSet();
// Add prompts
dialogs.add('choicePrompt', new botbuilder_dialogs_1.ChoicePrompt());
dialogs.add('confirmPrompt', new botbuilder_dialogs_1.ConfirmPrompt());
dialogs.add('datetimePrompt', new botbuilder_dialogs_1.DatetimePrompt());
dialogs.add('numberPrompt', new botbuilder_dialogs_1.NumberPrompt());
dialogs.add('textPrompt', new botbuilder_dialogs_1.TextPrompt());
dialogs.add('attachmentPrompt', new botbuilder_dialogs_1.AttachmentPrompt());
//-----------------------------------------------
// Main Menu
//-----------------------------------------------
dialogs.add('mainMenu', [
    function (dc) {
        return __awaiter(this, void 0, void 0, function* () {
            function choice(title, value) {
                return {
                    value: value,
                    action: { type: botbuilder_1.ActionTypes.ImBack, title: title, value: title }
                };
            }
            yield dc.prompt('choicePrompt', `Select a demo to run:`, [
                choice('choice', 'choiceDemo'),
                choice('confirm', 'confirmDemo'),
github hinojosachapel / CorePlus / javascript_nodejs / src / dialogs / greeting / index.js View on Github external
// validate what was passed in
        if (!userDataAccessor) throw new Error('Missing parameter. userDataAccessor is required');

        // Add a water fall dialog with 4 steps.
        // The order of step function registration is important
        // as a water fall dialog executes steps registered in order.
        this.addDialog(new WaterfallDialog(PROFILE_DIALOG, [
            this.initializeStateStep.bind(this),
            this.promptForNameStep.bind(this),
            this.promptForCityStep.bind(this),
            this.displayGreetingStep.bind(this)
        ]));

        // Add text prompts for name and city
        this.addDialog(new TextPrompt(NAME_PROMPT, this.validateName.bind(this)));
        this.addDialog(new TextPrompt(CITY_PROMPT, this.validateCity.bind(this)));

        // Save off our state accessor for later use
        this.userDataAccessor = userDataAccessor;
    }
github martinkearn / Bot-Banko / NodeJSPreview / app.js View on Github external
// // Helper function for finding a specified entity. entityResults are the results from LuisRecognizer.get(context)
// function findEntities(entityName, entityResults) {
//     let entities = []
//     if (entityName in entityResults) {
//         entityResults[entityName].forEach(entity => {
//             entities.push(entity);
//         });
//     }
//     return entities.length > 0 ? entities : undefined;
// }

// register some dialogs for usage with the intents detected by the LUIS app
const dialogs = new DialogSet();

dialogs.add('textPrompt', new TextPrompt());

dialogs.add('BalanceDialog', [
    async function(dc){
        let balance = Math.floor(Math.random() * Math.floor(100));
        await dc.context.sendActivity(`Your balance is £${balance}.`);
        await dc.continue();
    },
    async function(dc){
        await dc.context.sendActivity(`OK, we're done here. What is next?`);
        await dc.continue();
    },
    async function(dc){
        await dc.end();
    }
]);
github microsoft / BotBuilder-Samples / generators / generator-botbuilder / generators / app / templates / core / dialogs / greeting / greeting.ts View on Github external
if (!dialogId) { throw new Error('Missing parameter.  dialogId is required'); }
      if (!userProfileAccessor) { throw new Error('Missing parameter.  userProfileAccessor is required'); }

      // Add a water fall dialog with 4 steps.
      // The order of step function registration is important
      // as a water fall dialog executes steps registered in order
      this.addDialog(new WaterfallDialog(PROFILE_DIALOG, [
          this.initializeStateStep.bind(this),
          this.promptForNameStep.bind(this),
          this.promptForCityStep.bind(this),
          this.displayGreetingStateStep.bind(this),
      ]));

      // Add text prompts for name and city
      this.addDialog(new TextPrompt(NAME_PROMPT, this.validateName));
      this.addDialog(new TextPrompt(CITY_PROMPT, this.validateCity));

      // Save off our state accessor for later use
      this.userProfileAccessor = userProfileAccessor;
    }
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 05.multi-turn-prompt / bot.js View on Github external
constructor(conversationState, userState) {
        // Create a new state accessor property. See https://aka.ms/about-bot-state-accessors to learn more about bot state and state accessors.
        this.conversationState = conversationState;
        this.userState = userState;

        this.dialogState = this.conversationState.createProperty(DIALOG_STATE_PROPERTY);

        this.userProfile = this.userState.createProperty(USER_PROFILE_PROPERTY);

        this.dialogs = new DialogSet(this.dialogState);

        // Add prompts that will be used by the main dialogs.
        this.dialogs.add(new TextPrompt(NAME_PROMPT));
        this.dialogs.add(new ChoicePrompt(CONFIRM_PROMPT));
        this.dialogs.add(new NumberPrompt(AGE_PROMPT, async (prompt) => {
            if (prompt.recognized.succeeded) {
                if (prompt.recognized.value <= 0) {
                    await prompt.context.sendActivity(`Your age can't be less than zero.`);
                    return false;
                } else {
                    return true;
                }
            }

            return false;
        }));

        // Create a dialog that asks the user for their name.
        this.dialogs.add(new WaterfallDialog(WHO_ARE_YOU, [
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 25.logger / bot.js View on Github external
constructor(conversationState, userState) {
        // Create a new state accessor property. See https://aka.ms/about-bot-state-accessors to learn more about bot state and state accessors.
        this.conversationState = conversationState;
        this.userState = userState;

        this.dialogState = this.conversationState.createProperty(DIALOG_STATE_PROPERTY);

        this.userProfile = this.userState.createProperty(USER_PROFILE_PROPERTY);

        this.dialogs = new DialogSet(this.dialogState);

        // Add prompts that will be used by the main dialogs.
        this.dialogs.add(new TextPrompt(NAME_PROMPT));
        this.dialogs.add(new ChoicePrompt(CONFIRM_PROMPT));
        this.dialogs.add(new NumberPrompt(AGE_PROMPT, async (prompt) => {
            if (prompt.recognized.succeeded) {
                if (prompt.recognized.value <= 0) {
                    await prompt.context.sendActivity(`Your age can't be less than zero.`);
                    return false;
                } else {
                    return true;
                }
            }

            return false;
        }));

        // Create a dialog that asks the user for their name.
        this.dialogs.add(new WaterfallDialog(WHO_ARE_YOU, [
github howdyai / botkit / packages / botkit / lib / conversation.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            // Initialize the state
            const state = dc.activeDialog.state;
            state.options = options || {};
            state.values = Object.assign({}, options);
            // Add a prompt used for question turns
            if (!this._prompt) {
                this._prompt = this.id + '_default_prompt';
                dc.dialogs.add(new botbuilder_dialogs_1.TextPrompt(this._prompt));
            }
            // Run the first step
            return yield this.runStep(dc, 0, state.options.thread || 'default', botbuilder_dialogs_1.DialogReason.beginCalled);
        });
    }
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 13.core-bot / dialogs / bookingDialog.js View on Github external
constructor(id) {
        super(id || 'bookingDialog');

        this.addDialog(new TextPrompt(TEXT_PROMPT))
            .addDialog(new ConfirmPrompt(CONFIRM_PROMPT))
            .addDialog(new DateResolverDialog(DATE_RESOLVER_DIALOG))
            .addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
                this.destinationStep.bind(this),
                this.originStep.bind(this),
                this.travelDateStep.bind(this),
                this.confirmStep.bind(this),
                this.finalStep.bind(this)
            ]));

        this.initialDialogId = WATERFALL_DIALOG;
    }