Sending unknown number card sets

(The Niqabi Coder Mum) #1

Hi
I am trying to make a bot where I have to send a card set to the user. Problem is that I want to populate the card set with the data from a google sheet, and depending on the search query the number of results may be different each time. So for example I may want to send two cards to one user and four to other depending on their input, which will be searched in a google sheet.

For now I can make the card set manually. But I want something like a for loop, which reads the response from the google sheets and create (and populate) the card sets accordingly. Kind of like magic repeat for card sets.

Is it possible? IF yes then can you please guide me how?

Thanks

(Daniel Beckett) #2

Hi @nqcm

Unfortunately there’s no way to dynamically control how many cards should be sent but you can use a combination of Collection Outputs and Filters to send different cards with different content based on defined conditions being matched.

For example, you could have different card set actions setup based on the number of returned results and then use the filter to control which one should be sent out. e.g. send card set 3 if result count = 3.

(The Niqabi Coder Mum) #3

Ok thanks. But it won’t solve my problem. May be you can suggest another solution for my problem. Let’s say I am making a bot for a small restaurant. Users can see the specials for the day as well as the regular menu. Depending on what category a user chooses (entrees, desert, salad) the bot reads the item names, descriptions and the image URL from a Google Sheet and sends back the information as image cards. But of course each category has different number of items and I have to hard code the card sets for each category (let’s say the entrees have 10 items but salads have only 5, so I have to make different versions for all categories). It also doesn’t allow adding or subtracting items from the specials or menu by the staff of the restaurant as they may add more items than I have card set available currently. Therefore, I am looking for a more elegant solution where I don’t have to create cards manually for all different types of categories. What do you suggest would be the best possible solution?

Thanks

(Sarah Palombo) #4

Hi there :wave:

Unfortunately there isn’t a more elegant way to structure this. :flushed:

You would need to know that for instance the maximum number of results returned are 10. Complete the outputs in 10 cards so that result 1 goes to card 1, result 2 card 2 and so on

Don’t worry if there were only 4 items returned thats the number of cards that will be displayed

Hope that clarifies :relaxed:

Sarah

1 Like