The BitteWidgetChat component is a React component that enables AI-powered chat interactions in your application. It supports both NEAR Protocol and EVM blockchain interactions through wallet integrations, allowing users to interact with smart contracts and perform transactions directly through the chat interface.
🔑 Before you begin, make sure you have:
A Bitte API Key - Get your beta BITTE_API_KEY
Quick Start (<10min)
Install package
Add the Chat Component
Setup API Route
Wallet Connection
2. Install Package
pnpm install @bitte-ai/chat
2. Add the Widget Component
import { BitteWidgetChat } from "@bitte-ai/chat";
<BitteWidgetChat
agentId="your-agent-id"
apiUrl="/api/chat"
historyApiUrl="/api/history"
widget={{
widgetWelcomePrompts: {
questions: [
'What is the price of the NFT?',
'Latest activity of a specific wallet',
'Which tokens are trending?'
],
actions: ['Buy NFT', 'Sell NFT', 'Swap NFT'],
},
}}
/>
3. Setup API Route
Create an API route in your Next.js application to proxy requests to the Bitte API to not expose your key
At this point the chat should already work but to be able to send transactions you will need to add a wallet connection
4. Add wallet connection
NEAR Integration
You can integrate with NEAR using either the NEAR Wallet Selector or a direct account connection. If you want to be able to send near transacitons through the chat you will need to define at least one of these
import { Account } from "near-api-js";
// get near account instance from near-api-js by instantiating a keypair
<BitteWidgetChat
agentId="your-agent-id"
apiUrl="/api/chat"
wallet={{ near: { account: nearAccount } }}
/>
EVM Integration
EVM integration uses WalletConnect with wagmi hooks:
Here's how you might configure the BitteAiChat component, including some optional props and custom components:
<BitteWidgetChat
options={{
agentImage: bitteAgent?.image,
agentName: bitteAgent?.name,
colors: chatColors,
}}
wallet={{
near: {
wallet: wallet,
},
evm: evmAdapter,
}}
agentId={searchParams.get('agentId') || bitteAgent?.id || 'bitte-assistant'}
apiUrl="/api/chat"
historyApiUrl="api/history"
widget={{
widgetWelcomePrompts: {
questions: [
'What is the price of the NFT?',
'Latest activity of a specific wallet',
'Which tokens are trending?',
],
actions: ['Buy NFT', 'Sell NFT', 'Swap NFT'],
},
}}
/>
Import and use WidgetChat in your react app and select the agent that you would like to use, browse the available agents and their respective ids on the
The apiUrl corresponds to a proxy to not expose your api key on the client.
The historyApiUrl is needed to keep context and state of the chat.