{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4507","repository_url":"https://api.github.com/repos/Microsoft/BotBuilder","labels_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4507/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4507/comments","events_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4507/events","html_url":"https://github.com/Microsoft/BotBuilder/issues/4507","id":316480324,"number":4507,"title":"FormFlow string options as buttons","user":{"login":"MichalDurista","id":14805195,"avatar_url":"https://avatars1.githubusercontent.com/u/14805195?v=4","gravatar_id":"","url":"https://api.github.com/users/MichalDurista","html_url":"https://github.com/MichalDurista","followers_url":"https://api.github.com/users/MichalDurista/followers","following_url":"https://api.github.com/users/MichalDurista/following{/other_user}","gists_url":"https://api.github.com/users/MichalDurista/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalDurista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalDurista/subscriptions","organizations_url":"https://api.github.com/users/MichalDurista/orgs","repos_url":"https://api.github.com/users/MichalDurista/repos","events_url":"https://api.github.com/users/MichalDurista/events{/privacy}","received_events_url":"https://api.github.com/users/MichalDurista/received_events","type":"User","site_admin":false},"labels":[{"id":429202671,"url":"https://api.github.com/repos/Microsoft/BotBuilder/labels/.NET%20SDK","name":".NET SDK","color":"1d76db","default":false},{"id":603140070,"url":"https://api.github.com/repos/Microsoft/BotBuilder/labels/FormFlow","name":"FormFlow","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-21T10:26:07Z","updated_at":"2018-04-24T07:35:51Z","closed_at":null,"author_association":"NONE","body":"## Bot Info\r\n* Deployment Environment: local development with Emulator\r\n\r\n## Issue Description\r\nI am using bot framework and I am trying to define a form dynamically using FormFlow. I have a problem with one specific field (see the code).\r\nThe problem is that ProductPlatform depends on ProductName, therefore it is a string. This works fine, however, this way, the bot does not show the options of possible platforms (although there is {||} in SetPrompt).\r\n\r\nWhen I set type to null SetType(null), the bot now shows possible platforms as buttons, however, it never goes to ValidateProductPlatform when user decides to type a wrong platform instead of clicking on the correct one (I guess the validation itself is done already on SetDefine level). The only reason I need to validate user input through ValidateProductPlatform is that I want to cancel the form after 3 unsuccessful attempts.\r\n\r\nSo, is there any way to achieve this?: User has options (as buttons) for ProductPlaftorm based on ProductName, but instead of clicking, they (might) type a wrong platform, and after 3 wrong attempts, the form ends.\r\n\r\n## Code Example\r\n    .Field(new FieldReflector<IssueFormModel>(nameof(IssueFormModel.ProductPlatform))\r\n    .SetType(typeof(string))\r\n    .SetDefine(async (issue, field) =>\r\n    {\r\n        if (issue.ProductName != null)\r\n        {\r\n            foreach (var platform in productsWithPlatforms[issue.ProductName])\r\n            {\r\n                            field.AddDescription(platform, platform).AddTerms(platform, platform);\r\n            }\r\n        }\r\n\r\n       return await Task.FromResult(true);\r\n       })\r\n    .SetPrompt(new PromptAttribute(\"Which platform of {ProductName}{||}?\"))\r\n    .SetAllowsMultiple(false)\r\n    .SetValidate(async (state, value) => await ValidateProductPlatform(value, state)))\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/comments/383833550","html_url":"https://github.com/Microsoft/BotBuilder/issues/4507#issuecomment-383833550","issue_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4507","id":383833550,"user":{"login":"MichalDurista","id":14805195,"avatar_url":"https://avatars1.githubusercontent.com/u/14805195?v=4","gravatar_id":"","url":"https://api.github.com/users/MichalDurista","html_url":"https://github.com/MichalDurista","followers_url":"https://api.github.com/users/MichalDurista/followers","following_url":"https://api.github.com/users/MichalDurista/following{/other_user}","gists_url":"https://api.github.com/users/MichalDurista/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalDurista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalDurista/subscriptions","organizations_url":"https://api.github.com/users/MichalDurista/orgs","repos_url":"https://api.github.com/users/MichalDurista/repos","events_url":"https://api.github.com/users/MichalDurista/events{/privacy}","received_events_url":"https://api.github.com/users/MichalDurista/received_events","type":"User","site_admin":false},"created_at":"2018-04-24T07:35:51Z","updated_at":"2018-04-24T07:35:51Z","author_association":"NONE","body":"Hello. I don't see how that might be helpful since as I tried to describe, the problem is that it either gets into ValidateProductPlatform but platform options were not shown (as buttons), or it doesn't get there at all (when SetType(null)). Anyway, here it is:\r\n\r\n    [Serializable]\r\n    public class IssueFormModel\r\n    {\r\n        public string Description { get; set; }\r\n        public string ProductName { get; set; }\r\n        public string ProductPlatform { get; set; }\r\n\t}\r\n\r\nAnd here is Validation:\r\n\r\n    private async Task<ValidateResult> ValidateProductPlatform(object value, IssueFormModel state)\r\n    {\r\n        var match = await _luisProvider.GetFromUtterance(value as string);\r\n        if (match.topScoringIntent.intent == Resource.Intent_AnswerEnd && match.topScoringIntent.score > .75)\r\n        {\r\n            throw new FormCanceledException(\"You have canceled the form\", null);\r\n        }\r\n\r\n        var validPlatform = FindValidProductPlatform(match.entities.FirstOrDefault(e => e.type == Resource.Entity_ProductPlatform)?.entity);\r\n        var isValidPlatform = validPlatform != null;\r\n        var validateResult = new ValidateResult\r\n        {\r\n            Value = validPlatform,\r\n            IsValid = isValidPlatform\r\n        };\r\n        if (!isValidPlatform)\r\n        {\r\n            validateResult.Feedback = $\"\\\"{value as string}\\\" is not a valid platform\";\r\n            if (++platformAttempts == 3)\r\n            {\r\n                throw new TooManyAttemptsException(\"Too many attempts in platform\");\r\n            }\r\n        }\r\n\r\n        return await Task.FromResult(validateResult);\r\n    }"}}
{"actor":{"display_login":"MichalDurista"}}