Witted
Witted

Reputation: 504

Post a message to the user based on bool answer - FormFlow/Bot Framework

I can't seem to find a way to post a message to the user in the FormFlow based on how the user answers a bool. To post Fields based a previous answer you can use:

 .Field(new FieldReflector<GetQuoteDialog>(nameof(Dothis))
            .SetActive((state) => state.isDone== true))

However I haven't found a way to do the same with the .Message(). So say if I want to just send the message "Congrats!", then post the next question in the formflow.

So the dialog I would like to play out would be like:

  1. true/false question
  2. user answers true
  3. post message "Congrats" if user answers true
  4. ask next true/false question

Is there a way that I am just missing?

Upvotes: 0

Views: 319

Answers (1)

Gary Liu
Gary Liu

Reputation: 13918

You can leverage the second parameter of .Message() which is condition delegate function, from source code:

    // Summary:
    //     Show a message that does not require a response.
    //
    // Parameters:
    //   message:
    //     A \ref patterns string to fill in and send.
    //
    //   condition:
    //     Whether or not this step is active.
    //
    //   dependencies:
    //     Fields message depends on.
    //
    // Returns:
    //     Modified IFormBuilder.
    IFormBuilder<T> Message(string message, ActiveDelegate<T> condition = null, IEnumerable<string> dependencies = null);

So, please try:

.Message("Congrats", condition: (form) => form.boolField == true)

Upvotes: 1

Related Questions