NPM Module
NPM Module

Install

1
npm i botbye-client
or
1
yarn add botbye-client

Configuration

1. Import initChallenges from botbye-client module:

1
import { initChallenges } from "botbye-client";

2. Call initChallenges with your project client-key:

1
2
3
4
5
6
7
8
/**
* @param {Object} options - The options for BotBye init
* @return {Promise} - Promise with runChallenge function
*/
const runChallenge = await initChallenges({
  // Use your client-key
  clientKey: "00000000-0000-0000-0000-000000000000"
});

Usage

1. To run challenge and generate botbye token call runChallenge:

1
2
3
4
5
6
import { runChallenge } from "botbye-client";

/**
 * @return {Promise} Promise with BotBye token
 */
const botByeToken = await runChallenge();

2. Send this token in any convenient way to the backend. For example in x-botbye-token header:

1
2
3
4
5
6
7
8
9
fetch(
  'https://domain.com',
  {
    method: "POST",
    headers: {
        "x-botbye-token": botByeToken
    }
  }
)

Challenge runner

Package also exports runChallenge function. Before call it, make sure that initChallenges was called earlier.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { initChallenges, runChallenge } from "botbye-client";

initChallenges({
  // Use your client-key
  clientKey: "00000000-0000-0000-0000-000000000000"
});

...

const botByeToken = await runChallenge()

fetch(
  'https://domain.com',
  {
      method: "POST",
      headers: {
          "x-botbye-token": botByeToken
      }
  }
)