Search code examples
azurefile-uploadbotframeworkadaptive-cards

Bot builder : Upload file in a input form - adaptive cards


I'm trying to create a bot in which the user has to fill a form inside an adaptive card and then send in with a botton. I created this form exept uploading a file feature.

I have gone through the documentation but i haven't found much about adaptive cards especially about uploading file input.

Is it really possible ?

My code for this card is is there anything to add in order to have a botton for uploading a file ?

public Attachment CreateAdaptiveCardwithEntry()
        {
            var submitActionData = JObject.Parse("{ \"Type\": \"SaveFunction\" }");
            var card = new AdaptiveCard()
            {

                Body = new List<CardElement>()
                {  
                    // Hotels Search form  

                    new TextBlock() { Text = "Titre de la note des frais" },
                    new TextInput()
                    {
                        Id = "titre",
                        Speak = "<s>Veuillez saisir le titre</s>",
                        Placeholder = "Veuillez saisir le titre",
                        Style = TextInputStyle.Text
                    },
                    new TextBlock() { Text = "Date de la note des frais" },
                    new DateInput()
                    {
                        Id = "date",
                        Placeholder ="Veuillez saisir la Date de la note des frais"
                    },

                    new TextBlock() { Text = "Montant de la note de frais" },
                    new NumberInput()
                    {
                        Id = "montant",
                        Speak = "<s>Veuillez saisir le Montant en euros de la note de frais</s>",
                        Placeholder = "Veuillez saisir le Montant de la note de frais",

                    },

                },

                Actions = new List<ActionBase>()
                {
                    new SubmitAction()
                    {
                       Title = "Envoyer",
                       Speak = "<s>Envoyer</s>",
                       DataJson = submitActionData.ToString()

                    }
                }
            };

            Attachment attachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content = card
            };
            return attachment;
        }

Solution

  • Action.OpenUrl, Action.Submit and Action.ShowCard are currently the only Adaptive Card action types. There is no action type for file uploading. If you are targeting the webchat channel, you could download the repository and make custom modifications to enable some sort of file upload from an adaptive card.

    You can make a feature request for a new Action type here: https://github.com/Microsoft/AdaptiveCards/issues


    Please see this answer for WebChat: https://stackoverflow.com/a/55408977/86646