Ejemplo n.º 1
0
 public asBot(ConversationState conversationState, UserState userState, T dialog, ILogger <asBot <T> > logger)
 {
     ConversationState = conversationState;
     UserState         = userState;
     Dialog            = dialog;
     Logger            = logger;
 }
Ejemplo n.º 2
0
 public QnABot(ConversationState conversationState, UserState userState, T dialog, IConfiguration configuration)
 {
     _conversationState = conversationState;
     this._userState    = userState;
     Dialog             = dialog;
     _configuration     = configuration;
 }
Ejemplo n.º 3
0
 public QnABot(ConversationState conversationState, UserState userState, T dialog, IBotServices botServices, ILogger <QnABot <T> > logger)
 {
     ConversationState = conversationState;
     UserState         = userState;
     Dialog            = dialog;
     _botServices      = botServices;
 }
Ejemplo n.º 4
0
 public DialogBot(ConversationState conversationState, UserState userState, T dialog)
 {
     Dialog            = dialog;
     ConversationState = conversationState;
     UserState         = userState;
     _dialogManager    = new DialogManager(Dialog);
 }
Ejemplo n.º 5
0
 public QnABot(ConversationState conversationState, UserState userState, T dialog, IBotTelemetryClient telemetryClient)
 {
     ConversationState = conversationState;
     UserState         = userState;
     Dialog            = dialog;
     TelemetryClient   = telemetryClient;
 }
Ejemplo n.º 6
0
 public QnABot(IConfiguration configuration, ConversationState conversationState, UserState userState, T dialog, ConcurrentDictionary <string, ConversationReference> conversationReferences, IStorage storage)
 {
     ConversationState       = conversationState;
     UserState               = userState;
     Dialog                  = dialog;
     _conversationReferences = conversationReferences;
     _storage                = storage;
     _greeting               = configuration.GetValue <string>("GreetingValue");
 }
Ejemplo n.º 7
0
 public static async Task <DialogTurnResult> Call <T>(this DialogContext context, FormDialog <T> form, object entities = null, object options = null, CancellationToken cancellationToken = default)
     where T : class
 {
     Microsoft.Bot.Builder.Dialogs.Dialog diag = context.Dialogs.Find(typeof(T).Name);
     if (diag != null)
     {
         return(await context.Call <T>(entities, options, cancellationToken));
     }
     else
     {
         context.Dialogs.Add(form);
         DialogFormCaching._dialogs.Add(context.Context.Activity.Conversation.Id, form);
         return(await context.Call <T>(entities, options, cancellationToken));
     }
 }
Ejemplo n.º 8
0
        public static async Task Run(this Microsoft.Bot.Builder.Dialogs.Dialog dialog,
                                     ITurnContext turnContext, IStatePropertyAccessor <DialogState> dlgState,
                                     CancellationToken cancellationToken = default(CancellationToken))

        {
            var dialogSet = new DialogSet(dlgState);

            dialogSet.Add(dialog);

            var dlgContext = await dialogSet.CreateContextAsync(turnContext, cancellationToken);

            var results = await dlgContext.ContinueDialogAsync((cancellationToken));

            if (results.Status == DialogTurnStatus.Empty)
            {
                await dlgContext.BeginDialogAsync(dialog.Id, null, cancellationToken);
            }
        }
Ejemplo n.º 9
0
        public QnABot(ConversationState conversationState, UserState userState, T dialog)
        {
            ConversationState = conversationState;
            UserState         = userState;
            Dialog            = dialog;

            list_note.Add(new Pair()
            {
                Name = "user1", Picture = "https://mycleantownimages.blob.core.windows.net/mycleantownimagesmaterial/20191109_123944.jpg"
            });
            list_note.Add(new Pair()
            {
                Name = "user2", Picture = "https://mycleantownimages.blob.core.windows.net/mycleantownimagesmaterial/20191109_123957.jpg"
            });
            list_note.Add(new Pair()
            {
                Name = "user3", Picture = "https://mycleantownimages.blob.core.windows.net/mycleantownimagesmaterial/20191109_124007.jpg"
            });
        }
Ejemplo n.º 10
0
        public static async Task <DialogTurnResult> Call <T>(this DialogContext context, object entities = null, object options = null, CancellationToken cancellationToken = default)
            where T : class
        {
            Microsoft.Bot.Builder.Dialogs.Dialog diag = context.Dialogs.Find(typeof(T).Name);
            if (diag == null)
            {
                return(new DialogTurnResult(DialogTurnStatus.Cancelled));
            }

            if (diag is FormDialog <T> )
            {
                FormDialog <T> formDialog = diag as FormDialog <T>;
                var            field      = formDialog.GetType().GetField("_entities", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                if (field != null)
                {
                    entities = ConvertToLuisModels(entities) ?? Enumerable.Empty <EntityRecommendation>();
                    field.SetValue(formDialog, entities);
                }
            }

            return(await context.BeginDialogAsync(typeof(T).Name, options, cancellationToken));
        }
Ejemplo n.º 11
0
 public QnABot(ConversationState conversationState, UserState userState, T dialog)
 {
     ConversationState = conversationState;
     UserState         = userState;
     Dialog            = dialog;
 }
        /// <summary>
        /// Creates a dialog stack and starts a dialog, pushing it onto the stack.
        /// </summary>
        /// <param name="dialog">The dialog to start.</param>
        /// <param name="turnContext">The context for the current turn of the conversation.</param>
        /// <param name="accessor">The <see cref="IStatePropertyAccessor{DialogState}"/> accessor
        /// with which to manage the state of the dialog stack.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects
        /// or threads to receive notice of cancellation.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task RunAsync(this Dialog dialog, ITurnContext turnContext, IStatePropertyAccessor <DialogState> accessor, CancellationToken cancellationToken)
        {
            var dialogSet = new DialogSet(accessor)
            {
                TelemetryClient = dialog.TelemetryClient
            };

            dialogSet.Add(dialog);

            var dialogContext = await dialogSet.CreateContextAsync(turnContext, cancellationToken).ConfigureAwait(false);

            // Handle EoC and Reprompt event from a parent bot (can be root bot to skill or skill to skill)
            if (IsFromParentToSkill(turnContext))
            {
                // Handle remote cancellation request from parent.
                if (turnContext.Activity.Type == ActivityTypes.EndOfConversation)
                {
                    if (!dialogContext.Stack.Any())
                    {
                        // No dialogs to cancel, just return.
                        return;
                    }

                    var activeDialogContext = GetActiveDialogContext(dialogContext);

                    // Send cancellation message to the top dialog in the stack to ensure all the parents are canceled in the right order.
                    await activeDialogContext.CancelAllDialogsAsync(true, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return;
                }

                // Handle a reprompt event sent from the parent.
                if (turnContext.Activity.Type == ActivityTypes.Event && turnContext.Activity.Name == DialogEvents.RepromptDialog)
                {
                    if (!dialogContext.Stack.Any())
                    {
                        // No dialogs to reprompt, just return.
                        return;
                    }

                    await dialogContext.RepromptDialogAsync(cancellationToken).ConfigureAwait(false);

                    return;
                }
            }

            // Continue or start the dialog.
            var result = await dialogContext.ContinueDialogAsync(cancellationToken).ConfigureAwait(false);

            if (result.Status == DialogTurnStatus.Empty)
            {
                result = await dialogContext.BeginDialogAsync(dialog.Id, null, cancellationToken).ConfigureAwait(false);
            }

            // Skills should send EoC when the dialog completes.
            if (result.Status == DialogTurnStatus.Complete || result.Status == DialogTurnStatus.Cancelled)
            {
                if (SendEoCToParent(turnContext))
                {
                    // Send End of conversation at the end.
                    var code     = result.Status == DialogTurnStatus.Complete ? EndOfConversationCodes.CompletedSuccessfully : EndOfConversationCodes.UserCancelled;
                    var activity = new Activity(ActivityTypes.EndOfConversation)
                    {
                        Value = result.Result, Locale = turnContext.Activity.Locale, Code = code
                    };
                    await turnContext.SendActivityAsync(activity, cancellationToken).ConfigureAwait(false);
                }
            }
        }
 private async Task BeginDialog(Microsoft.Bot.Builder.Dialogs.Dialog dialog, BotState conversationState, ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
 {
 }