0.0.1 • Published 5 months ago
botbye-client v0.0.1
Install
npm i botbye-client
or
yarn add botbye-client
Usage
1. Import initChallenges
from botbye-client
module:
import {initChallenges} from "botbye-client";
2. Call init
with SITE_KEY:
/**
* @param {String} siteKey - Your site key
* @return {Promise} - Promise with runChallenge function
*/
const runChallenge = await initChallenges('MY_SITE_KEY');
3. To run challenge and generate CHALLENGE_TOKEN call runChallenge
/**
* @return {Promise} Promise with String
*/
const botByeToken = await runChallenge();
4. Send this token in any convenient way to the backend. For example in Challenge-Token
header
fetch('https://domain.com', {
method: "POST",
headers: {
"BotBye-Token": botByeToken
}
})
5. runChallenge
Package also exports runChallenge
function.
Before call it, make sure that initChallenges
was called earlier.
import {initChallenges, runChallenge} from "botbye-client";
initChallenges('MY_SITE_KEY');
...
runChallenge()
.then((botByeToken) =>
fetch('https://domain.com', {
method: "POST",
headers: {
"BotBye-Token": botByeToken
}
}))