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