メインコンテンツへスキップ
Topics APIは、会話トピック(複数のEpisodeをグループ化・サマリーしたもの)を取得・検索するためのインターフェースです。Slackでの議論や会議中の会話など、まとまりのある対話を管理できます。

概要

const client = new NdxClient({
  apiKey: process.env.NEURADEX_API_KEY,
  projectId: 'your-project-id',
});

// Topics APIにアクセス
const topics = await client.topics.list();
const result = await client.topics.search('プロジェクト進捗');

メソッド一覧

メソッド説明
list(options?)トピック一覧を取得
get(topicId)特定のトピックを取得
search(query, options?)トピックをベクトル検索

list()

トピック一覧をページネーション付きで取得します。

パラメータ

options.page
number
デフォルト:"1"
ページ番号
options.limit
number
デフォルト:"20"
1ページあたりの取得件数

戻り値

interface TopicListResponse {
  data: Topic[];
  total: number;
  page: number;
  limit: number;
  totalPages: number;
}

interface Topic {
  id: string;
  projectId: string;
  integrationId: string | null;
  channelId: string | null;
  title: string;
  summary: string | null;
  messageCount: number | null;
  participants: string[] | null;
  startedAt: string | null;
  endedAt: string | null;
  createdAt: string;
  updatedAt: string;
}

使用例

// 最初のページを取得
const result = await client.topics.list();

for (const topic of result.data) {
  console.log(`${topic.title} (メッセージ数: ${topic.messageCount})`);
}

// ページネーション
const page2 = await client.topics.list({ page: 2, limit: 10 });

get()

特定のトピックの詳細を取得します。

パラメータ

topicId
string
必須
トピックID

使用例

const topic = await client.topics.get('topic-123');

console.log(topic.title);
console.log(topic.summary);
console.log(`参加者: ${topic.participants?.join(', ')}`);

ベクトル検索でトピックを検索します。「あの議論」「プロジェクト進捗の話」など、あいまいなクエリでも関連するトピックを発見できます。

パラメータ

query
string
必須
検索クエリ
options.limit
number
結果の最大件数

戻り値

interface TopicSearchResponse {
  results: TopicSearchResult[];
  query: string;
}

interface TopicSearchResult {
  id: string;
  title: string;
  summary: string | null;
  messageCount: number | null;
  participants: string[] | null;
  startedAt: string | null;
  score: number;
}

使用例

// トピックを検索
const result = await client.topics.search('プロジェクト進捗');

for (const topic of result.results) {
  console.log(`${topic.title} (スコア: ${topic.score})`);
}

// 件数を指定
const result = await client.topics.search('認証方式の議論', { limit: 5 });

ユースケース

過去の議論を探す

async function findDiscussion(keyword: string) {
  const result = await client.topics.search(keyword);

  if (result.results.length === 0) {
    console.log('関連するトピックが見つかりませんでした');
    return;
  }

  // 最も関連性の高いトピックの詳細を取得
  const topTopic = await client.topics.get(result.results[0].id);

  console.log(`トピック: ${topTopic.title}`);
  console.log(`サマリー: ${topTopic.summary}`);
  console.log(`参加者: ${topTopic.participants?.join(', ')}`);
  console.log(`期間: ${topTopic.startedAt}${topTopic.endedAt}`);
}

await findDiscussion('デプロイフローの変更');

次のステップ

Episodes API

イベント履歴の管理

Knowledge API

ナレッジの管理