Show external content in card


#1

Hi,
I am a newbie and use latest version (11.4.2).I call our Solr server via axios to get a result string. So, it is no problem to show the result {{temp.result}} in content text, but this does not work in card (for exapmle in Title or in URL). Is it possible to use these content types like card or carousel for dynamic output?
Thanks
Martin


#2

You could try smth like this:

const payloads = await bp.cms.renderElement('card', { typing: true, items: [{ title: 'some title', subtitle: 'more text' }, ] }, event.channel)
await bp.events.replyToEvent(event, payloads)

#3

I made some changes, and now it works! Thanks
Who is interested, here is my code:

const getCardDyn = async () => { 
const userId = event.target;
const botId = event.botId;
const channelId  = event.channel
const eventDestination = {target:userId,botId:botId,channel:channelId}
try {   
    // temp.result is the result from Solr Server
    const payloads = await bp.cms.renderElement("builtin_card", { typing: true, items: [{ title: temp.result, subtitle: "Wonderful!" }, ] }, eventDestination)
    await bp.events.replyToEvent(eventDestination, payloads)
    console.log(eventDestination)
} catch (e) {
    console.log("error!")
} 
}
return getCardDyn(args);

How to reply with a dynamic multiple choice? (botpress.io V11.3)