Helping users install the AiBrow extension

Once you've created a site that uses AiBrow, then you can automatically detect if the extension and on-device helper are installed using the Detect if AiBrow is installed example.

If you find that AiBrow isn't installed, we have some handy links that can help with installing the extension. The AiBrow install page accepts a redirect argument, that once the extension is installed, will redirect back to your page.

To use this, direct the user to the following url https://aibrow.ai/install?redirect_to=your_url

The flow that users will be taken through is...

  1. Install from the Chrome Web Store / Firefox Addon Store to install the extension

  2. Once extension installation is complete, they'll be asked to download the on-device helper

  3. After the on-device helper is installed, they'll either be taken to your provided redirect_to url or to the AiBrow examples page

AiBrow has two components, the browser extension and the helper binary. Users will need both installed to use a model. After the browser extension is installed, users are prompted to continue the installation and download the helper binary, but you should still be prepared to handle cases where this has not been completed. AiBrow provides some helper utilities to check the current installation state and direct users to download the helper binary when needed.

Detection & installation from a webpage

You can detect if AiBrow is installed and help the user install the extension from your website

async function checkInstalled () {
  if (!window.aibrow) {
    // The extension is not installed
    console.log(`Install the extension from https://aibrow.ai/install?redirect_to=${window.location.href}`)
    return false
  }
  
  const capabilities = await window.aibrow.capabilities()
  if (!capabilities.helper) {
    // The helper binary is not installed. We can fetch the direct link to the latest
    // version for the current platform
    const helperUrl = await window.aibrow.getHelperDownloadUrl()
    console.log(`Install the helper from ${helperUrl} or https://aibrow.ai/install?redirect_to=${window.location.href}`)
    return false
  }
  
  // We're all installed
  return true
}

checkInstalled()

Detection & installation from an extension

Your extension should pre-bundle the AiBrow library, but it still needs the AiBrow extension and native helper installed. You can help users install from your extension.

import aibrow from '@aibrow/extension'

async function checkInstalled () {  
  const capabilities = await aibrow.capabilities()
  if (!capabilities.extension) {
    // The extension is not installed
    console.log('Install the extension from https://chromewebstore.google.com/detail/aibrow/bbkbjiehfkggfkbampigbbakecijicdm')
    return false
  }
  if (!capabilities.helper) {
    // The helper binary is not installed. We can fetch the direct link to the latest
    // version for the current platform
    const helperUrl = await aibrow.getHelperDownloadUrl()
    console.log(`Install the helper from ${helperUrl}`)
    return false
  }
  
  // We're all installed
  return true
}

checkInstalled()

Detect if AiBrow is polyfilling window.ai

If window.ai is not available in the current browser, AiBrow will automatically polyfill the API. You can detect if this has happened

if (window.ai && window.ai.aibrow === true) {
  // AiBrow is polyfilling the window.AI API
  console.log('You\'re all set to go!')
}

Last updated