Search code examples
c#.netbotframeworkmicrosoft-teamsadaptive-cards

Is AdaptiveNumberInput not supported in Task-Module in bot framework?


I am using Task module to show the adaptive card, which contains AdaptiveNumberInput & Other AdaptiveTextBlocks. When the task module is opened, it throws an error "The bot did not respond correctly to the invoke request." and when i see in the console it is:"Error when processing invoke response: P…is incorrect, field is in the wrong format: value". And when i replace this with the AdaptiveTextInput, it works find, here i need to take input from the user as numeric. So i need AdaptiveNumberInput. My code is as below-

AdaptiveCard card = new AdaptiveCard("1.0");
var body = new List<AdaptiveElement>();
var mainContainer = new AdaptiveContainer();

#region Textboxes

var container2 = new AdaptiveContainer();
for (int j = 0; j < projects.Count; j++)
{
    var columnSetWbse = new AdaptiveColumnSet();
    for (int i = 0; i < loop; i++)//Loop for no of days
    {
        var columnWbseinput = new AdaptiveColumn();
        AdaptiveNumberInput wbseInput = new AdaptiveNumberInput()
        {
            Id = "nos" + i + "-" + j,
            Min = 0,
            Max = 2,
            Placeholder = "number"
        };

        //AdaptiveTextInput wbseInput = new AdaptiveTextInput()
        //{ 
        //   MaxLength=2
        //};

        columnWbseinput.Items.Add(wbseInput);
        columnSetWbse.Columns.Add(columnWbseinput);
    }

    container2.Items.Add(columnSetWbse);
}

mainContainer.Items.Add(container2);

// mainContainer.Items.Add(container2);
#endregion

body.Add(mainContainer);

Tried implementing it in task module

Attachment attachment;

Actually it should work for both the type of Text-inputs, not sure what's the issue here.


Solution

  • Its because in the AdaptiveNumberInput we have to give the initial value. Please find the code below-

    AdaptiveNumberInput wbseInput = new AdaptiveNumberInput()
    {
      Id = "nos" + i + "-" + j,
      Min = 0,
      Max = 2,        
      Value=0
    };