コード例 #1
0
ファイル: BotDialogs.cs プロジェクト: wmeints/betty
        /// <summary>
        /// Creates a dialog to check the weight of the placed luggage.
        /// </summary>
        /// <returns>Returns the dialog structure.</returns>
        private Dialog CreateHeavyLuggageCheckDialog(ILuggageScale scale)
        {
            var steps = new WaterfallStep[]
            {
                async(stepContext, cancellationToken) =>
                {
                    var weight = await scale.GetWeight();

                    if (weight > 20.0)
                    {
                        return(await stepContext.ReplaceDialogAsync(DialogNames.PaymentDialog));
                    }
                    else
                    {
                        return(await stepContext.ReplaceDialogAsync(DialogNames.ThanksDialog));
                    }
                },
            };

            return(new WaterfallDialog(DialogNames.CheckHeavyLuggageDialog, steps));
        }
コード例 #2
0
ファイル: BotDialogs.cs プロジェクト: wmeints/betty
        /// <summary>
        /// Initializes a new instance of the <see cref="BotDialogs"/> class.
        /// </summary>
        /// <param name="dialogState">The dialog state to use.</param>
        /// <param name="conversationData">The conversation data.</param>
        /// <param name="botServices">Bot services needed by the dialogs.</param>
        /// <param name="scale">The luggage scale.</param>
        public BotDialogs(
            IStatePropertyAccessor <DialogState> dialogState,
            IStatePropertyAccessor <ConversationData> conversationData,
            BotServices botServices,
            ILuggageScale scale)
            : base(dialogState)
        {
            _botServices      = botServices;
            _conversationData = conversationData;

            Add(CreateRootDialog());
            Add(CreateMenuDialog());
            Add(CreateCheckinDialog());
            Add(CreateSecurityQuestionDialog());
            Add(CreateHeavyLuggageCheckDialog(scale));
            Add(CreateThanksDialog());
            Add(CreatePaymentDialog());
            Add(CreateExtendedSecurityCheckDialog());

            Add(new TextPrompt(PromptNames.MenuItem));
            Add(new TextPrompt(PromptNames.SecurityQuestion));
            Add(new TextPrompt(PromptNames.PaymentConfirmation));
            Add(new TextPrompt(PromptNames.BoardingInformation));
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BettyBot"/> class.
        /// </summary>
        /// <param name="conversationState">The conversation state for the bot.</param>
        /// <param name="botServices">Bot services to use.</param>
        /// <param name="scale">Scale to weigh the luggage.</param>
        public BettyBot(ConversationState conversationState, BotServices botServices, ILuggageScale scale)
        {
            var dialogStateProperty = conversationState.CreateProperty <DialogState>(nameof(DialogState));

            _conversationDataProperty = conversationState.CreateProperty <ConversationData>(nameof(ConversationData));

            _dialogs = new BotDialogs(
                dialogStateProperty,
                _conversationDataProperty,
                botServices,
                scale);

            _conversationState = conversationState;
            _botServices       = botServices;
        }