Getting started with JavaScript

1. Install and import the @botpoison/browser library.
npm install @botpoison/browser
2. Create a new Botpoison instance with your public key.
3. Process a challenge using the challenge() function.
4. Forward the solution to your server for verification.
javascript
import axios from "axios";
// 1. Import the library
import Botpoison from "@botpoison/browser";
// 2. Create a new instance with your public key
const botpoison = new Botpoison({
publicKey: 'pk_xxxxxxxx'
});
const sendMessage = async (message) => {
// 3. Process a challenge
const { solution } = await botpoison.challenge();
await axios.post("https://example.demo", {
message,
// 4. Forward the solution
_botpoison: solution,
});
}