gentle-lunch-37811
04/30/2024, 12:35 PMcold-jewelry-54343
04/30/2024, 4:09 PMfilterjs
try {
  const clientNumbers = await Data1Table.findRecords({
    filter: {"Phone":{"$regex":"^\\+55"}},
    limit: 30,
    offset: 0
  })
  workflow.phonearray = clientNumbers.map((product) => {
    return {
      name: product.name,
      phone: product.Phone 
    }
  })
} catch (error) {
  console.log('Something went wrong: ', error)
}QueryKnowledgeBasegentle-lunch-37811
04/30/2024, 6:03 PMTitle: ${sermon.Title}, Preacher: ${sermon.Preacher}, DownloadLinks: ${sermon.DownloadLinks}gentle-lunch-37811
04/30/2024, 6:06 PMbumpy-butcher-41910
04/30/2024, 7:32 PMbumpy-butcher-41910
04/30/2024, 7:32 PMbumpy-butcher-41910
04/30/2024, 7:33 PMcold-jewelry-54343
04/30/2024, 7:47 PMhandleSearch() and it works well. however the problem i am having is that the result is **displaying in the console **and not as a text card. in the code i told it to display result in workflow.userdownload. its not doing this. i know its some minor thing left but i dont know what it is.js
async function searchSermons(keyword) {
  try {
    // Assuming Botpress provides a method to query data from the TcnSermonTable
    const tableData = await TcnSermonTable.findRecords({
      filter: {
        Title: { $regex: keyword, $options: 'i' }
      }
    });
    const results = tableData.map((row) => ({
      Title: row.Title,
      Preacher: row.Preacher,
      DownloadLinks: row.DownloadLinks
    }));
    return results;
  } catch (error) {
    console.error('Error retrieving data from TcnSermonTable:', error);
    return []; // Return an empty array if there's an error
  }
}
// Function to display matching sermons
function displayMatchingSermons(matchingSermons) {
  if (matchingSermons.length === 0) {
    workflow.matchingSermonsMessage = 'No sermons found matching the keyword.';
  } else {
    let message = "";
    for (const sermon of matchingSermons) {
      message += `Title: ${sermon.Title}, Preacher: ${sermon.Preacher}, Download Links: ${sermon.DownloadLinks}\n`;
    }
    workflow.matchingSermonsMessage = message;
  }
}
// Perform search based on user input
async function handleSearch() {
  const keyword = workflow.SermonQuery; // Get user input from workflow variable
  try {
    const matchingSermons = await searchSermons(keyword);
    workflow.userdownload = matchingSermons; // Store the result in workflow variable
    displayMatchingSermons(matchingSermons);
  } catch (error) {
    console.error('Error searching for sermons:', error);
    workflow.matchingSermonsMessage = 'An error occurred while searching for sermons.';
  }
}cold-jewelry-54343
04/30/2024, 7:47 PMworkflowworkflow.userdownloadworkflowgentle-lunch-37811
04/30/2024, 8:12 PMgentle-lunch-37811
05/01/2024, 11:06 AMgentle-lunch-37811
05/01/2024, 10:04 PMcareful-shoe-96396
05/10/2024, 5:48 AMgentle-lunch-37811
05/10/2024, 6:56 AM