Start Dialog without prompt in bot (for C#) -
i'm building bot microsoft bot framework, v3, in c# , trying have dialog start , "welcome" user instructions before enter input. dialog repeat every time user completes form.
i'm attempting use formflow options: formoptions.promptinstart still having welcome message appear after enter input. not sure if deprecated v1 or i'm not doing right. advice??
my classes below:
messagescontroller:
internal static idialog<myclass> makerootdialog() { return chain.from(() => formdialog.fromform(myclass.buildform, options: formoptions.promptinstart)) .do(async (context, order) => {//some actions here } }); }
myclass.cs :
[serializable] public class myclassdialog : idialog<object> { public async task startasync(idialogcontext context) { context.wait(messagereceivedasync); } public async task messagereceivedasync(idialogcontext context, iawaitable<imessageactivity> argument) { var message = await argument; await context.postasync("you said: " + message.text); context.wait(messagereceivedasync); } }
myclassdialog.cs :
public class myclass { public static iform<myclass> buildform() { oncompletionasyncdelegate<myclass> processorder = async (context, state) => { await context.postasync("we filing order....."); }; return new formbuilder<myclass>() .message("welcome bot!") //some actions here .confirm(//more actions here) .addremainingfields() .message("thanks providing inputs") .oncompletion(processorder) .build(); } };
how implement post method? think dont have problem in form in post method.
this code work me.
public async task<httpresponsemessage> post([frombody] activity activity) { if (activity.type == activitytypes.message || activity.type == activitytypes.conversationupdate) { conversation.sendasync(activity, makerootdialog); { }
because if user connect, activitytype conversationupdate, no message. must call makerootdialog when activity.type == activitytypes.conversationupdate too.
Comments
Post a Comment