biz-agent-hub
v1.0.3
Published
The **Biz Agent Hub JavaScript SDK** provides a simple way to integrate Biz Agent Hub agents (such as Support Agent) into your Node.js or browser applications.
Readme
Biz Agent Hub – JavaScript SDK
The Biz Agent Hub JavaScript SDK provides a simple way to integrate Biz Agent Hub agents (such as Support Agent) into your Node.js or browser applications.
With this SDK, you can:
- Initialize a
BizAgentHubclient with your credentials - Interact with Support Agent via a simple
query()API - Send messages and optional files (for example, images) to the bot
- Use the SDK from both TypeScript and JavaScript
Installation
npm install biz-agent-hubor with Yarn:
yarn add biz-agent-hubQuick Start
ES Modules / TypeScript
import { BizAgentHub } from 'biz-agent-hub';
const userId = '<your_user_id>';
const apiKey = '<your_api_key>';
const client = new BizAgentHub(userId, apiKey);
async function run() {
const response = await client.supportAgent.query({
message: 'Hello Support Agent!',
file: undefined, // Optional: a File object (browser) or compatible type
sessionId: undefined // Optional: reuse a session ID for conversation continuity
});
console.log('Support Agent response:', response);
}
run().catch(console.error);CommonJS / JavaScript
const { BizAgentHub } = require('biz-agent-hub');
const userId = '<your_user_id>';
const apiKey = '<your_api_key>';
const client = new BizAgentHub(userId, apiKey);
(async () => {
const response = await client.supportAgent.query({
message: 'Hello Support Agent!',
file: undefined,
sessionId: undefined
});
console.log('Support Agent response:', response);
})();API Reference
BizAgentHub
new BizAgentHub(userId: string, apiKey: string)Creates an instance of the Biz Agent Hub client.
userId– Your Biz Agent Hub user identifier.apiKey– Your API key for authentication.
Properties
supportAgent: SupportAgentInterface for interacting with the Support agent.
SupportAgent
query(options: SupportAgentQuery): Promise<any>
Send a message (and optional file) to Support Agent.
interface SupportAgentQuery {
/** The user message or question for Support Agent. */
message: string;
/**
* - Optional file to send to the bot.
* - In the browser, this should be a `File` object.
* - In Node.js, you can use a compatible form-data file type depending on your setup.
*/
file?: File;
/**
* - Optional session ID.
* - Use this to maintain conversation context between multiple messages.
*/
sessionId?: string;
}Example:
const result = await client.supportAgent.query({
message: 'What is the main color in this image?',
file: imageFile, // e.g. from an <input type="file"> or Node.js equivalent
sessionId: 'my-session-id-123', // optional but recommended for multi-turn conversations
});
console.log(result);Error Handling
The query() method throws an error when the underlying HTTP request fails or the server responds with an error status.
try {
const response = await client.supportAgent.query({
message: 'Help me with my issue.',
file: undefined,
sessionId: undefined,
});
console.log('Response:', response);
} catch (err) {
console.error('Support Agent query failed:', err);
}TypeScript Support
This SDK is written in TypeScript and ships with type declarations:
Strong typing for
BizAgentHub,SupportAgent, andSupportAgentQueryWorks out of the box with TypeScript projects
No additional configuration is required; just import and use.
Building From Source
If you are working on the SDK locally:
# Install dependencies
npm install
# Build TypeScript -> dist/
npm run buildThe compiled JavaScript and type declarations will be emitted into the dist directory.
Support
If you encounter problems or have questions:
Open an issue in the GitHub repository
Include:
Your Node.js version
The
biz-agent-hubversionA minimal code sample that reproduces the issue
This helps us diagnose and resolve problems quickly.
