https://discord.gg/botpress logo
I would like only clients of my Google
# 💻developers
h
I would like only clients of my Google sheets to be able to use the bot.
w
Hi, there are different solutions to verify a user: * You can use a Google Sheets extension to search for users. * Use Make.com to search Google; there's an extension workflow for that. * Create a Botpress table and import your Google Sheets users. Inside the bot, you need: * A user variable to store whether the user is logged in/verified. * The first step is to check the user variable. If it is false, the bot should ask for the information needed to verify if the user is in your list: * Username and password, or * Email, or * Mobile phone number. The bot will search for the user, and if it finds the user, it will proceed with your flow. Otherwise, it will show a message and end the conversation.
h
Copy code
javascript
/**
 * Valida se user.username está cadastrado em alguma clínica
 * no seu Firebase Realtime Database, corrigindo a URL de fetch.
 */
const rootUrl = `${env.firebaseURL.replace(/\/$/, '')}/.json?auth=${env.firebaseSecrets}`

async function validarClinicas() {
  try {
    // 1) Busca todas as clínicas
    const response = await fetch(rootUrl)
    if (!response.ok) throw new Error(`HTTP ${response.status}`)
    const data = await response.json()

    // 2) Pega o username atual
    const username = user.username?.toString().trim()
    if (!username) {
      user.bloqueado = true
      return
    }

    // 3) Percorre cada clínica procurando pelo usuário
    let autorizado = false
    for (const clinic in data) {
      const clinicData = data[clinic]
      if (
        clinicData &&
        typeof clinicData === 'object' &&
        Object.prototype.hasOwnProperty.call(clinicData, username)
      ) {
        autorizado = true
        break
      }
    }

    // 4) Seta bloqueio conforme o resultado
    user.bloqueado = !autorizado

  } catch (err) {
    user.bloqueado = true
    console.error("validarClinicas erro:", err.message || err)
  }
}

await validarClinicas()
### I ended up using Firebase Realtime to validate my clients.
w
Happy to help you