Code help
# 🤝help
w
Please, can anyone help me with processing code to display the RapidAPI response on Botpress card? I have tried severally without success. Please find the attach the JSON data https://cdn.discordapp.com/attachments/1135506802637807616/1135506802734272542/SupportatBotpressDicourt.txt
a
Hey @white-spoon-79644 cards need this kind of schema:
Copy code
js
return {
    type: 'card',
    title: {
      dynamicValue: `your-title-from-api`,
      valueType: 'dynamic'
    },
    subtitle: {
      dynamicValue: 'your-subtitle-from-api',
      valueType: 'dynamic'
    },
    imageUrl: {
      dynamicValue: `your-image-url-from-api`,
      valueType: 'dynamic'
    },
    actions: [
      {
        action: 'url',
        label: 'View Recipe',
        value: `your-url-from-api`
      }
    ]
  }
w
Please which means RapidAPI data cannot be used in Botpress? This JSON data is Spooncular API data format. I have used it before, is there a way to convert other API response data to look like it?
a
yeah, you can write code to do it. I'm not going to write the code for you, but to break it down you'll need to: 1. Fetch your API response in JSON format 2. Parse the API data and find your card's title, subtitle, and image URL 3. If you want buttons, you'll need to find your buttons' labels and URL values in the API response, too 4. Write code to map those values from the API into the schema I provided 5. Save this to a workflow variable 6. In your card, put the appropriate variable values into the boxes in your card
w
Thank you so much I appreciate you
It have being able to do it now. Thanks to @acceptable-kangaroo-64719 for your input