Here's what I used in storing data from Google She...
# đź’»developers
q
Here's what I used in storing data from Google Sheets to Botpress KB tables
Copy code
js
async function createNewRecords(sheetsData) {
  try {
    await GoogleSheetsTable.createRecords(sheetsData)
  } catch (error) {
    console.log(error)
  }
}
Full example code from there
Copy code
js
async function makeAsyncRequest() {
  const webhookUrl = 'https://hook.eu2.make.com/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
// REPLACE xxxxxxxx WITH YOUR MAKE.COM WEBHOOK ADDRESS
  try {
    const response = await axios.post(webhookUrl)
    const webhookResponse = JSON.stringify(response.data)
    console.log('Log response: ' + webhookResponse)
    await deleteAllRecords()
    return webhookResponse
  } catch (error) {
    console.log(error)
  }
}

const newString = await makeAsyncRequest()
console.log("newString: " + newString)

const data = JSON.parse(newString)
await createNewRecords(data)

async function deleteAllRecords() {
  try {
    const data = await GoogleSheetsTable.findRecords({ selectorName: 'allRecords' })

    if (!Array.isArray(data)) {
      console.log('No records found.')
      return
    }

    const recordIDs = data.map((record) => record.id)

    if (recordIDs.length > 0) {
      await GoogleSheetsTable.deleteRecords(recordIDs)
      console.log('Old records deleted.')
    } else {
      console.log('No records to delete.')
    }
  } catch (error) {
    console.log(error)
  }
}

async function createNewRecords(sheetsData) {
  try {
    await GoogleSheetsTable.createRecords(sheetsData)
  } catch (error) {
    console.log(error)
  }
}
https://discord.com/channels/1108396290624213082/1181662097046786118