ripe-pilot-83749
07/19/2023, 9:47 AMacceptable-kangaroo-64719
07/19/2023, 11:27 AMjs
workflow.ddOptions = [
{
label: 'Option 1',
value: `https://en.wikipedia.org`
},{
label: 'Option 2',
value: 'https://google.com
]
Then you can pass that variable into the choice skill like thisrough-smartphone-28502
07/19/2023, 5:24 PMripe-pilot-83749
07/20/2023, 4:18 AMacceptable-kangaroo-64719
07/20/2023, 10:30 AMjs
const url = 'https://api.spoonacular.com/recipes/complexSearch'
const params = {
query: workflow.baseQuery,
diet: workflow.dietType,
apiKey: env.apiKey,
number: '3',
ignorePantry: 'false',
sort: 'popularity',
sortDirection: 'asc',
addRecipeInformation: 'true',
addRecipeNutrition: 'false'
}
try {
const response = await axios.get(url, { params })
if (response.status === 200) {
workflow.recipeInfo = response.data.results
}
} catch (error) {
console.error(error)
}
acceptable-kangaroo-64719
07/20/2023, 10:30 AMworkflow.recipeInfo
) and re-format them in a way that is acceptable for carousels. You would just skip all the bits about images/titles/subtitles and just focus on an array of buttons.
js
workflow.recipes = []
const myCards = workflow.recipeInfo.map((recipe) => {
workflow.recipes.push({
title: recipe.title,
vegetarian: recipe.vegetarian,
vegan: recipe.vegan,
glutenFree: recipe.glutenFree,
dairyFree: recipe.dairyFree,
veryHealthy: recipe.veryHealthy,
cheap: recipe.cheap,
veryPopular: recipe.veryPopular,
readyInMinutes: recipe.readyInMinutes,
servings: recipe.servings,
summary: recipe.summary
})
// create the card object
return {
type: 'card',
title: {
dynamicValue: `${recipe.title}`,
valueType: 'dynamic'
},
subtitle: {
dynamicValue: '',
valueType: 'dynamic'
},
imageUrl: {
dynamicValue: `${recipe.image}`,
valueType: 'dynamic'
},
actions: [
{
action: 'url',
label: 'View Recipe',
value: `${recipe.sourceUrl}`
}
]
}
})
workflow.cards = []
for (var card of myCards) {
workflow.cards.push({
//in order to render a card, we only need these three fields
title: card.title,
imageUrl: card.imageUrl,
actions: card.actions[0]
})
}
ripe-pilot-83749
07/20/2023, 12:53 PM