Can i add dynamic input in Input.ChoiceSet in msteams adaptive card? I am getting values from an api call and want to list as an input - adaptive-cards

I am getting some data from an API call and I want to display them in an adaptive card as a choice set, then the user will be able to choose one or more choices to do action on them. The problem is that the array of choices is dynamic. My question is how to pass an array to the choice set in the adaptive card. Statically i can do. Since its dynamic, I tried via choices.data, but in vain

That is not possible as such, the card is static and can't "retrieve" data.
You have to pass all available choices into the JSON payload of the card.
In MS Teams however you can do this in multiple steps.
In the first card the user selects the first option and submits the card.
Then you can send a second card with choices according to the first card.
To my knowledge that's the only way to achieve what you want currently

Related

Dynamic data Binding in Adaptive cards

I am looking for a way where I can bind the dropdowns used in adaptive cards with the data that I will get from my API.
Anyone know how to use https get calls in adaptive cards to prefill data.
Thanks
I'm pretty sure you can't do -inside- the card itself (i.e. from the user's bot client), but it's easy enough to dynamically create the card -before- you send it to the user. There are 3 ways I know of to do this:
1) you can compose the json string for the card yourself, and build up the dynamic options
2) you can using a strongly-typed library to create the card, and build the options dynamically in code (e.g. if you're using C#, you can use this nuget package.
3) you can look at the new adaptive card templating (currently in preview).
I discuss these options more over here: Display number in adaptive card

Print Table In Bot emulator whose fields contain class object values

I want to print a table in Bot Emulator. The table contains values from a class object. What is the best way to do it?
I tried to do it using Adaptive card but I am stuck in printing variable values( class objects) as I cannot pass the objects parameter to my Json file made for adaptive card.
Two-column tables can be included in Adaptive Cards as fact sets.
If you need more than two columns, just make each row in your table its own column set.
Pretty sure your best approach might be using Adaptive cards, it shouldn't be that hard to load your card's properties before sending it as attachment as it's shown in MBF docs:
.NET: Add rich cards: Adaptive card
Node.js: Send rich cards: Send an Adaptive Card
Both links shows you how to send an adaptive card, using that, you may be able to create methods that parse your object to card's properties

How to collect data from two different routes/urls then at the end use the collected data to post a request to the server?

Lets assume that i have a URL http://localhost:3000/choose1 which will provide the user with different choices to choose from, after the user choose he will be redirected to http://localhost:3000/choose2 to choose another thing and then at the end i want to collect these choices upon it i will do a post request to the server.
So my question is what are the approaches to store these choices and forward it to the next URLs?
I am using expressJS
there are multiple ways to achieve what you want:
using functions as middleware for example: app.get('/custom/route/',functions1(req,res,next),function2(req,res,next),function3(req,res,next),..);
using request library you can combine as many you want
personally, i will prefer the first one
You can put all the the options on a multi step form (where the options are separated by JS on thefrontend). Then you only make need to make one submission at the end. This also means you only need one route to handle everything. Here is an example: https://www.w3schools.com/howto/howto_js_form_steps.asp

How to fill initial values for select on HTML form from database?

I'm new here. Can you help me with a newbie question, please? Maybe provide a link to solution.
I have a RESTful service and a web form for editing a model (e.g. user preferences). I want to prepare initial values on form. I request "new" model from the service and it sends me a JSON that contains object with initial values set (for example gender or birth date). It is easy to fill text inputs with those values. But also form has several select elements which should be filled with options from a database. And then I can set appropriate initial options (id) from the model for those select elements.
What is the way to do this?
I see couple ways:
Service might send options together with the model in JSON;
Form can request options itself before getting initial values (but it is another request and if form has several selects it is several requests).
Is there any conventional or best practice way?

Populating grid and form with same json?

Is it possible to populate grid with some of the JSON data and a form with other, from the same JSON? Two stores or two models or both? simple example... ;-)
Yes, the best way to do this would be to manipulate the reader, which as well as returning records, also stores whatever the raw json sent from the server is.
The easiest solution would be to specify the reader parameters for your grid, but then have a listener on the store, which then processed the rawData property from the reader to get the additional values for your form.
Of course if your form data is related to the grid data, you may do better to rely on nested loading and form.loadRecord in the store's load event handler. See the Ext samples (form and grid data binding example) for wasy of doing this.
Depending on the circumstances, another approach similar to the Ext FAQ would be to handle the Ajax through a simple Ext.Ajax.Request, and this process the json through two stores with local proxies, but this doesn't seem quite so Ext4 data model friendly to me.