Widget Component

Introduction

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 here

Quick Start (<10min)

  1. Install package

  2. Add the Chat Component

  3. Setup API Route

  4. Wallet Connection

2. Install Package

2. Add the Widget Component

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 registry 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. from @bitte-ai/[email protected] onwards we have now markdown rendering, you can keep rendering plaintext, or if you wanna markdown support just add format="markdown" to BitteWidgetChat Component

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

Create an history api route to keep the context of the widget chat.

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

Using Wallet Selector

Using Direct Account

EVM Integration

EVM integration uses WalletConnect with wagmi hooks:

SUI Integration

SUI integration uses WalletConnect with wagmi hooks:

Example Usage

Here's how you might configure the BitteWidgetChat component, including some optional props and custom components:

Last updated