Using Enum in FormFlow. Error when deployed to Telegram and Facebook
Bot Info
- SDK Platform: .NET
- SDK Version: 3.14
- Active Channels: Telegram, Facebook, Web Chat, Emulator
- Deployment Environment: Azure
Issue Description
Everything works well in Emulator, Test in Web Chat and Web Chat (on the azurewebsites.net). Failed in Telegram and Facebook Messenger with codes :
Telegram error message
{"ok":false,"error_code":400,"description":"Bad Request: message must be non-empty"}
Facebook error message
{"error":{"message":"(#100) Param name_placeholder[elements][0][title] must be a non-empty UTF-8 encoded string","type":"OAuthException","code":100,"fbtrace_id":"CK5TPveI0SR"}}
Code snippet
return new FormBuilder<CrucialInfo>()
.Message(PromptSetImportantPersonalNFOAsk)
.Field(new FieldReflector<CrucialInfo>(nameof(AskContinue))
.SetPrompt(new PromptAttribute(PromptExistingDataOnRecord + " {||}") { ChoiceStyle = ChoiceStyleOptions.Auto })
.SetFieldDescription(new DescribeAttribute(DescribeSetImportantPersonalNFOAsk))
.SetNext((value, x) =>
{
x.AskContinue = (ContinueCommand)value;
if (x.AskContinue== ContinueCommand.Yes)
{
return new NextStep(new[] { nameof(Identity) });
}
else if (x.AskContinue == ContinueCommand.No)
{
return new NextStep(StepDirection.Quit); // Caller will handle the exception: FormCanceledException
}
else
{
return new NextStep(new[] { nameof(AskContinue) }); } //Todo: how to handle this? Or simply else and not else if above (and remove this)
}))
Did this
Looking at Nov. 2016 issue #1678, I played around with .Message, Describe-Title and test all possibility on ChoiceStyle = ChoiceStyleOptions.Auto
What works on both Telegram and Facebook
ChoiceStyle = ChoiceStyleOptions.PerLine
So, the option for Yes and No no more shown as buttons but in text 1 Yes 2 No
Note: PromptExistingDataOnRecord is some text and {*}
On Facebook Messenger, the option 1 Yes and 2 No shown as above (in rows) after the {*} content and include a CR/LF. On Telegram, the option presented in-line with the last entry of the {*} content and 1 Yes, 2 No in the same line.
Expected Behavior
Button to choose Yes or No
Actual Results
See the error reported in Azure - Web App Bot - Channels (above in Issue Description)
Ps. Apologize for the Code Snippet, edited multiple times to make it shows better code but failed. Edit: hah! now I know how to code and hilight code blocks.
How lucky I am, no one really took any action....yet. Else that someone will be pissed. Found out that same method works on other form. I must have done something different on the form that failed. Need to go into the code again and will share what's wrong with my code that renders the error.
My bad. Sorry.
Ok, got it. Should have read #1678 carefully.
[Prompt(" {||}")] also fails. [Prompt("X{||}")] does not.
The problem lies in
.SetPrompt(new PromptAttribute(PromptExistingDataOnRecord + " {||}") { ChoiceStyle = ChoiceStyleOptions.Auto }) Nothing got to do with using ChoiceStyleOptions.PerLine to make it works. Still, curious why ChoiceStyleOptions.PerLine works.
Its the space in " {||}". Everything works fine when using .SetPrompt with {||} provided that no blank space before the opening curly brace.
eg.
.SetPrompt("These are your current entry{||}") works.
.SetPrompt("These are your current entry {||}") will produce the error _something-something_ must be non-empty in Telegram and Facebook.
A reminder for me, be careful while coding or ask the development team to change something in the framework to take care of the issue.
@JasonSowers ?
Hi @MNHarun
I'm not sure what the issue is here. Please provide a code example, so we are able to assist you.
Issue is with FormFlow with prompt that is using {||} template. Failure in Telegram and Facebook Messenger.
Failed code: .SetPrompt(new PromptAttribute(ShowOptionButtons + "Pick one {||}") { ChoiceStyle = ChoiceStyleOptions.Auto })
Working code: .SetPrompt(new PromptAttribute(ShowOptionButtons + "Pick one{||}") { ChoiceStyle = ChoiceStyleOptions.Auto })
Issue solved and my finding: Cannot have a blank space before the first curly brace. If want to have a space before the first curly brace, need to use ChoiceStyleOptions.PerLine as the choice display type.