botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

FormFlow functionality: Executing custom logic, sending custom reply and accessing bot state

Open jigneshs123 opened this issue 10 years ago • 4 comments

I'm trying to see if I could run some custom business logic after certain field input is provided by the user, access context object, get/set Bot State (for e.g. PrivateConversationData), and send some custom message/attachments. Is it possible to do any of this while building Form?

It seems to have support for validating input and send text reply as message, but I'm looking to run some business logic to get/set state and therefore access context, and then send custom reply to user that could contain attachments etc. (basically reply). And possibly, use the bot state information to construct dynamic field?

Having something similar to what OnCompletionAsyncDelegate can do while user if filling the form would probably work but it seems like that is only fired OnCompletion.

jigneshs123 avatar Jul 22 '16 04:07 jigneshs123

ValidateAsync does allow you to get/set state, but does not allow you to send messages. (Or rather you can return a string as feedback, but it does not allow attachments--this is a good idea and I will look into expanding what you can return.)
You can dynamically construct fields, check out the documentation here: https://docs.botframework.com/en-us/csharp/builder/sdkreference/forms.html#dynamicFields

chrimc62 avatar Jul 26 '16 15:07 chrimc62

The new release out soon should allow you to return multiple choices which can generate one or more cards. You can also return feedback that is richer than just text.

chrimc62 avatar Aug 10 '16 01:08 chrimc62

Thanks @chrimc62 for reply and adding support for it. Looking forward to it. Btw, ValidateAsync only seem to give form state but not the context state (e.g. PrivateConversationData).

Is it possible to send attachment as part of form options or is that something going to be supported?

jigneshs123 avatar Aug 12 '16 23:08 jigneshs123

Hi @chrimc62, I'm trying to get values from the PrivateConversationData or UserData from the context in the ValidateAsync without success. It's possible access the context from ValidateAsync? or properties like ChannelId and From from the activity.

Hi @jigneshs123 , can you solve your issue?

dchumpitaz avatar Dec 05 '16 07:12 dchumpitaz