How to detect if a Digital Form was submitted or canceled?

I have a dialog task that presents a digital form to the user. My form has a SUBMIT and a CANCEL button. If the user SUBMITs the form, the remainder of the dialog task completes as expected. However if the user CANCELs the form or uses the X button in the top right corner to close the form without submitting, the entire dialog task is discarded. Ideally I would like to know within the Dialog Task whether the user submitted the form or canceled or X’d out of the form without submitting, so that my dialog task can execute an alternate flow. How do I achieve that?

1 Like

@harshal.mulherkar1
I tested the scenario. Ideally, we should populate the context object context.endOfTask (refer to this documentation) with a proper reason.
As of now, I see endOfTask event is not being populated for any reason as such. This should be enhanced. I am creating a ticket on your behalf to track this.
As a dirty work-around, you can probably try to tap the bot response for discarding the task if the immediately preceding bot context has a form link present. Something like:

  "Form10001": {
        "formLink": "https://bots.kore.ai/api/1.1/UIFlow/forms/token?hash=0132bdfafb778e7b71f3a8df467505e3"
    }

@swagata.sengupta if we try to implement the workaround that you propose, would that be within a botkit onEvent method? Also, please share the ticket number so that we can track it with Pankaj and Ramya. Thanks, Harshal

@harshal.mulherkar1
I would rather suggest using on Bot Message.
The context object is available in both but on event and on bot message are asynchronously/prarallelly triggered. So any change OR calling a particular intent etc. is better handled through on user/bot messages.