公式パッケージ · フレームワーク
Node.js から Chat API・Live Chat・承認を使う
依存パッケージのないサーバー SDK で、pusher パッケージが扱わない Hibira の製品をカバーします:Chat API、Express・Fastify・Koa のミドルウェア付きの Live Chat 認証済み訪問者、そして Approvals です。
最速の方法:Hibira プラグインとプロンプト 1 つ
AI コーディングエージェントにプラグインを入れて、プロンプトを貼り付けるだけ。エージェントがサインインし、必要なら無料アプリを作成し、コードを書いてテストイベントを送ります。 GitHub ↗
プラグインをインストール
claude plugin marketplace add hibira-io/agent-plugin claude plugin install hibira@hibiraこのプロンプトを貼り付け
Add Hibira Node.js SDK (@hibira-io/node) to this project. Follow https://hibira.io/guides/node-sdk, adapted to how this project is already set up. If I have no Hibira app yet, create a Free one that allows http://localhost so I can test right away. Keep the app key and secret in environment variables, add placeholders to .env.example, and never commit real values or send the secret to a browser. When you are done, send a test event, show me it arriving, and list the files you changed.
- hibira.chat で会話の作成、メンバーとしての投稿、履歴の取得、既読の記録ができます。
- Express・Koa・Fastify のミドルウェアで、ログイン中のユーザーを認証済みにした Live Chat ウィジェットをページに追加します。
- hibira.approvals で人に判断を依頼して回答を待ち、verifyApprovalCallback() で署名付きのコールバックを検証します。
サインインすると、コード例にご自身のクラスターホストが入ります。 サインイン
インストール
npm install @hibira-io/node設定する
HIBIRA_APP_ID=YOUR_APP_ID HIBIRA_KEY=YOUR_APP_KEY HIBIRA_SECRET=YOUR_APP_SECRET HIBIRA_HOST=ws.hibira.io HIBIRA_LIVECHAT_WORKSPACE=YOUR_WORKSPACE_ID HIBIRA_LIVECHAT_IDENTITY_SECRET=YOUR_IDENTITY_SECRET使う
import { createHibira } from '@hibira-io/node'; const hibira = createHibira(); // Live Chat on every page, signed-in users verified: <%- hibiraLiveChat.scriptTag %> app.use(hibira.liveChat.express({ getUser: (req) => req.user && { id: req.user.id, name: req.user.name } })); await hibira.chat.putConversation('order-1042', { members: ['buyer-7', 'seller-3'] }); await hibira.chat.sendMessage('order-1042', 'seller-3', 'Shipped today!'); const ask = await hibira.approvals.request({ title: 'Refund order #1042 for $89?', options: ['Refund', 'Decline'] }); const answer = await hibira.approvals.wait(ask.approval_id, { timeout: 600 });
始める前に
- アプリのシークレットは、アプリの作成時とシークレットのローテーション時に一度だけ表示されます。サーバーにだけ置き、ブラウザやゲームのビルドには入れないでください。
- リアルタイムイベントとチャンネル認可には、{brand} のホストに向けた pusher npm パッケージを、待合室には @hibira-io/waiting-room を使います。
ダッシュボードのアプリキーを使ってください。シークレットはサーバー側だけに置きます。チャンネル、イベント、認可エンドポイントは Pusher とまったく同じように動作します。 無料でアカウントを作成 →