チャット
client.ai.chat.sendMessage() メソッドは、会話型アナリティクスを実現します。ユーザーが見たいものや理解したいことを自然言語で記述すると、AI がインサイト、説明、またはダッシュボードの生成・変更で応答します。
基本的な使い方
import { RevealSdkClient } from '@revealbi/api';
const client = RevealSdkClient.getInstance();
// Send a message and get the complete response
const response = await client.ai.chat.sendMessage({
message: 'Show me sales trends for the last quarter',
datasourceId: 'my-datasource',
});
console.log(response.explanation);
// "I've analyzed your sales data for Q4 2024..."
if (response.dashboard) {
// Load the generated dashboard
loadDashboard(response.dashboard);
}
会話の管理
AI はサーバー側で会話履歴を保持しており、文脈に沿ったフォローアップの質問が可能です。履歴をクリアして最初からやり直すことができます。
// Reset the conversation context
await client.ai.chat.resetContext();
console.log('Conversation history cleared');
以下の場合に使用します:
- 新しいトピックを開始するとき
- データソースを切り替えるとき
- ユーザーが明示的に「最初からやり直す」ことをリクエストしたとき