1
votes

I'm using the C# SDK for Bot Framework to develop a bot and i want my bot send a satisfaction message after a time without activity from the client.

I tried with Task but at first Task are not serializable so i can't store the task to Dispose it if i recieve a new message, and second PrompChoice throw a 'Microsoft.Bot.Builder.Internals.Fibers.InvalidNeedException' with the message : " invalid need: expected Call, have Wait"

I tried to replace my PromptChoice with just a context.sendAsync("Hi"), no exception here but message never be sent to the emulator.

If somebody have an idea on the way to do this, i would be grateful.

EDIT:

i use this sample to do the job:

            using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
            {
                var botData = scope.Resolve<IBotData>();
                await botData.LoadAsync(CancellationToken.None);
                IDialogTask task = scope.Resolve<IDialogTask>();

                //interrupt the stack
                var dialog = new InactivityDialog();
                task.Call(dialog.Void<object, IMessageActivity>(), null);
                //stack.Post<InactivityDialog>(dialog, (c, item) => { return Task.CompletedTask; });
                await task.PollAsync(CancellationToken.None);

                //flush dialog stack
                await botData.FlushAsync(CancellationToken.None);

            }

and this in my static messageController:

    var builder = new ContainerBuilder();
builder.Register(c => ((ClaimsIdentity)HttpContext.Current.User.Identity).GetCredentialsFromClaims())
           .AsSelf()
           .InstancePerLifetimeScope();
builder.Update(Conversation.Container);

But the HttpContext.Current is null when it try to resolve IBotData from the scope

1
Would a timer work? - MickyD
nop , The context can be in wait more or in call mode, in wait mode it's waiting for message from client in call mode he's able to psot message to client. But here i need to be waiting message during the timer before i send the satisfaction diaglog ... - Dashell_J

1 Answers

0
votes

That functionality isn't in the bot framework right now. You would have to create your own custom code where you save the conversation information & update your own timer if there's been activity.

https://github.com/Microsoft/BotBuilder/issues/837