Hi, I posted the below in help 5 days ago but have...
# 🌎general
c
Hi, I posted the below in help 5 days ago but haven't received any guidance so I'm hoping to find some answers here: 💥How can I set this up so that the carousel results ONLY show the correct records based on the user's budget? In this example, the user is taken into a workflow about packages and prices. They are asked for their budget and then a find records search is performed and then presented in a carousel format. There are three tiers of pricing 499, 999, and 2499. I enter 1500 as the budget and the results should be the first two only in the carousel but it's showing a third result in a wonky format. See screenshot. I want to set this up so that if the user says their budget is $550, then only Package 1 would show but if they said something like $1500 then it shows both the 499 and 999 packages. If they answered $3000 then it would show all three and their details. Is there a way to set this up so that only the matching records show in the carousel? Merci
b
Which part of the flow is the problem? The code to extract the price, to set the price point and tiers, to construct the right carousel or the styling of the carousel?
If picking the tiers for your clients you should always have an extra margin. If my budget is 900 I probably still want to see the 999 package.
Something like:
Copy code
//setting the range (above and below budget) as a bot variable so you don't have to go back in the code and can use it everywhere
cont maxRange = bot.maxRange
filter = { Price: { $lte: user.budget + bot.maxRange } }
const records = await yourTable.findRecords({
    filter
  })
s
i think the main problem is he sometimes needs 1 card and sometimes 2 or 3
@clean-xylophone-13519 if statements would be the only way here
or setting up 3 different flows for each option doesnt have to be an if statement i think
c
That is exactly what I need. It sometimes shows 1 card and sometimes 2 - 3 depending on the budget entered. I do have a 'Records Filter' in place see the last screenshot.
Hi Frederik, a little technical for where I'm at in Botpress but a fast learner nonetheless. The part of the flow that is the problem is the carousel gives me a 3rd option Package 3 for $2499 when I only need $499 and $999 to show up when a budget of $1000 is entered. My goal is to set this up so that if the budget entered is $550, it shows only the $499 option in the carousel. If $1500 is entered, only the $499 and $999 options are shown WITHOUT the $2499 option popping up as it does now. I do see that you are a developer and a Botbassador, do you work freelance?
b
The higher the price the more cards. If you populate the cards like the example I shared, you can use the budget to get the records. The lower the budget the less records will be shown. I do not work freelance, but I do have companies. I am not here for work, but just like you to learn (and teach a little bit). Export your bot and I'll have a look.
Hope my solution works!
s
solved? would be interested in the final solution aswell
b
The solution offered was based on the "for each amount of records a different node" option. The trouble is not dynamically making a carousel in code, but Botpress does not have an option to post it. `let num = +workflow.userBudget; const filter = { Prices: { $lte: num } } const records = await Packages_and_PricesTable.findRecords({ filter }) console.log('records length: ', records.length) const newCarousel = { type: 'carousel', elements: [] } // Define the function to generate the cards for the carousel const generateCards = () => { newCarousel.elements = records.map((tier) => { const titleValue =
${tier.Packages} | $${tier.Prices}
const subtitleValue = tier.Included return { type: 'card', title: titleValue, subtitle: subtitleValue, actions: [ { action: 'url', label: 'View Package', value: tier.Link } ] } }) } if (records.length !== 0) { generateCards() console.log(newCarousel) workflow.carousel = newCarousel } `
j
ok thanks
r
how to get data into get record card from an external api? i've integrated the bot into my java web applications using configurable script. Now i want to get user's queries into javascript and based on their queries i want to pass information to bot into cards like get record and others.
3 Views