@butlerbot/sdk 0.0.1-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +11 -0
- package/dist/config.js +12 -0
- package/dist/examples/simple_message.js +10 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +41 -0
- package/dist/modules/conversation.d.ts +36 -0
- package/dist/modules/conversation.js +65 -0
- package/dist/src/config.js +11 -0
- package/dist/src/index.js +37 -0
- package/dist/src/modules/conversation.js +43 -0
- package/dist/src/types/ai_response_v3.js +2 -0
- package/dist/src/types/dialogue_response_v3.js +2 -0
- package/dist/src/types/error.js +2 -0
- package/dist/types/ai_response_v3.d.ts +59 -0
- package/dist/types/ai_response_v3.js +2 -0
- package/dist/types/dialogue_response_v3.d.ts +28 -0
- package/dist/types/dialogue_response_v3.js +2 -0
- package/dist/types/error.d.ts +1 -0
- package/dist/types/error.js +2 -0
- package/package.json +44 -0
- package/readme.md +26 -0
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG = void 0;
|
|
4
|
+
exports.CONFIG = {
|
|
5
|
+
server: "https://core.butlerbot.net",
|
|
6
|
+
healthcheckPath: "/api/healthcheck",
|
|
7
|
+
paths: {
|
|
8
|
+
conversation: {
|
|
9
|
+
v3: { base: "/api/alfred/v3/chat" }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const src_1 = require("../src");
|
|
4
|
+
const client = new src_1.ButlerBotClient({
|
|
5
|
+
apiKey: "your_api_key_here"
|
|
6
|
+
});
|
|
7
|
+
const convo = client.createConversation();
|
|
8
|
+
convo.send("Hello, world!", (response) => {
|
|
9
|
+
console.log(response);
|
|
10
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Conversation, ConversationOptions } from "./modules/conversation";
|
|
2
|
+
type OptionalApiKey<T> = Omit<T, "apiKey"> & {
|
|
3
|
+
/** Optional API key, defaults to API key specified in client */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ButlerBotClientOptions = {
|
|
7
|
+
/** The server endpoint, API calls are sent here */
|
|
8
|
+
serverUrl?: string;
|
|
9
|
+
/** The API key to use with ButlerBot */
|
|
10
|
+
apiKey: string;
|
|
11
|
+
/** Whether to enable debug logs */
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class ButlerBotClient {
|
|
15
|
+
private apiKey;
|
|
16
|
+
private serverUrl;
|
|
17
|
+
private debug;
|
|
18
|
+
constructor(config: ButlerBotClientOptions);
|
|
19
|
+
/** Checks the health of the server returning true if server is alive */
|
|
20
|
+
healthCheck(healthCheckPath?: string): Promise<boolean>;
|
|
21
|
+
/** Spawns a new Conversation, inherits api key and server URL */
|
|
22
|
+
createConversation(config?: OptionalApiKey<ConversationOptions>): Conversation;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ButlerBotClient = void 0;
|
|
13
|
+
const config_1 = require("./config");
|
|
14
|
+
const conversation_1 = require("./modules/conversation");
|
|
15
|
+
class ButlerBotClient {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.apiKey = config.apiKey;
|
|
18
|
+
this.serverUrl = config.serverUrl || config_1.CONFIG.server;
|
|
19
|
+
this.debug = config.debug || false;
|
|
20
|
+
}
|
|
21
|
+
/** Checks the health of the server returning true if server is alive */
|
|
22
|
+
healthCheck() {
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* (healthCheckPath = config_1.CONFIG.healthcheckPath) {
|
|
24
|
+
const url = `${this.serverUrl}${healthCheckPath}`;
|
|
25
|
+
try {
|
|
26
|
+
const response = yield fetch(url);
|
|
27
|
+
return response.ok;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (this.debug)
|
|
31
|
+
console.warn("[Healthcheck Failure]", error);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Spawns a new Conversation, inherits api key and server URL */
|
|
37
|
+
createConversation(config = {}) {
|
|
38
|
+
return new conversation_1.Conversation(Object.assign({ debug: this.debug, apiKey: this.apiKey, serverUrl: this.serverUrl }, config));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ButlerBotClient = ButlerBotClient;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RequestResponse } from "../types/dialogue_response_v3";
|
|
2
|
+
export type DialogueRequestParams = {
|
|
3
|
+
/** Unique identifier for the chat session */
|
|
4
|
+
chatId?: string;
|
|
5
|
+
/** The message to be sent to the AI */
|
|
6
|
+
message: string;
|
|
7
|
+
/** AI model to use for generating responses */
|
|
8
|
+
model?: string;
|
|
9
|
+
/** Additional instructions for location-specific context */
|
|
10
|
+
instructions?: string;
|
|
11
|
+
/** Platform where the chat is occurring */
|
|
12
|
+
platform?: string;
|
|
13
|
+
/** Custom personality configuration for the AI */
|
|
14
|
+
personality?: string;
|
|
15
|
+
};
|
|
16
|
+
export type ConversationOptions = {
|
|
17
|
+
/** The conversation ID to load the conversation from, server will error if this convo id doesn't exist */
|
|
18
|
+
convoId?: string;
|
|
19
|
+
/** The API key to use */
|
|
20
|
+
apiKey: string;
|
|
21
|
+
/** The server URL to use */
|
|
22
|
+
serverUrl?: string;
|
|
23
|
+
/** The path to append to the server URL specifying the API endpoint to use */
|
|
24
|
+
path?: string;
|
|
25
|
+
/** Whether to enable debug logs */
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare class Conversation {
|
|
29
|
+
convoId?: string;
|
|
30
|
+
endpoint: string;
|
|
31
|
+
apiKey: string;
|
|
32
|
+
private debug;
|
|
33
|
+
constructor(config: ConversationOptions);
|
|
34
|
+
/** Sends a message into the conversation */
|
|
35
|
+
send(message: string, cb: (chunk: RequestResponse) => any): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Conversation = void 0;
|
|
13
|
+
const eventsource_1 = require("eventsource");
|
|
14
|
+
const config_1 = require("../config");
|
|
15
|
+
class Conversation {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.convoId = config.convoId;
|
|
18
|
+
this.endpoint = (config.serverUrl || config_1.CONFIG.server) + (config.path || config_1.CONFIG.paths.conversation.v3.base);
|
|
19
|
+
this.apiKey = config.apiKey;
|
|
20
|
+
this.debug = config.debug || false;
|
|
21
|
+
}
|
|
22
|
+
/** Sends a message into the conversation */
|
|
23
|
+
send(message, cb) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const params = {
|
|
26
|
+
message,
|
|
27
|
+
api_key: this.apiKey
|
|
28
|
+
};
|
|
29
|
+
if (this.convoId)
|
|
30
|
+
params.chatId = this.convoId;
|
|
31
|
+
const paramQuery = new URLSearchParams(params).toString();
|
|
32
|
+
const url = `${this.endpoint}?${paramQuery}`;
|
|
33
|
+
if (this.debug) {
|
|
34
|
+
const debugUrl = new URL(url);
|
|
35
|
+
const apiKey = debugUrl.searchParams.get('api_key');
|
|
36
|
+
if (apiKey) {
|
|
37
|
+
const obscuredKey = apiKey.length > 6 ? `${apiKey.slice(0, 3)}...${apiKey.slice(-3)}` : '***';
|
|
38
|
+
debugUrl.searchParams.set('api_key', obscuredKey);
|
|
39
|
+
}
|
|
40
|
+
console.log(`[Requesting URL ${debugUrl.toString()}]`);
|
|
41
|
+
}
|
|
42
|
+
const sse = new eventsource_1.EventSource(url);
|
|
43
|
+
sse.addEventListener("message", (event) => {
|
|
44
|
+
const data = JSON.parse(event.data);
|
|
45
|
+
cb(data);
|
|
46
|
+
if (data.data.quitStream)
|
|
47
|
+
sse.close();
|
|
48
|
+
});
|
|
49
|
+
sse.addEventListener("error", (event) => {
|
|
50
|
+
if (this.debug)
|
|
51
|
+
console.warn(`[Stream Error: ${url}]`, event);
|
|
52
|
+
cb({
|
|
53
|
+
success: false,
|
|
54
|
+
data: {
|
|
55
|
+
code: "STREAM_ERROR",
|
|
56
|
+
error: "Stream error",
|
|
57
|
+
message: event.message || "An error occurred while streaming",
|
|
58
|
+
quitStream: true
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.Conversation = Conversation;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ButlerBotClient = void 0;
|
|
13
|
+
const conversation_1 = require("./modules/conversation");
|
|
14
|
+
class ButlerBotClient {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.apiKey = config.apiKey;
|
|
17
|
+
this.serverUrl = config.serverUrl;
|
|
18
|
+
}
|
|
19
|
+
/** Checks the health of the server returning true if server is alive */
|
|
20
|
+
healthCheck() {
|
|
21
|
+
return __awaiter(this, arguments, void 0, function* (healthCheckPath = "/health") {
|
|
22
|
+
const url = `${this.serverUrl}${healthCheckPath}`;
|
|
23
|
+
try {
|
|
24
|
+
const response = yield fetch(url);
|
|
25
|
+
return response.ok;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Spawns a new Conversation, inherits api key and server URL */
|
|
33
|
+
createConversation(config = {}) {
|
|
34
|
+
return new conversation_1.Conversation(Object.assign({ apiKey: this.apiKey, serverUrl: this.serverUrl }, config));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ButlerBotClient = ButlerBotClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Conversation = void 0;
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
class Conversation {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.convoId = config.convoId;
|
|
17
|
+
this.endpoint = (config.serverUrl || config_1.CONFIG.server) + (config.path || config_1.CONFIG.paths.conversation.v3.base);
|
|
18
|
+
this.apiKey = config.apiKey;
|
|
19
|
+
}
|
|
20
|
+
/** Sends a message into the conversation */
|
|
21
|
+
send(message, cb) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const params = {
|
|
24
|
+
message,
|
|
25
|
+
api_key: this.apiKey,
|
|
26
|
+
chatId: this.convoId,
|
|
27
|
+
};
|
|
28
|
+
const paramQuery = new URLSearchParams(params).toString();
|
|
29
|
+
const url = `${this.endpoint}?${paramQuery}`;
|
|
30
|
+
const sse = new EventSource(url);
|
|
31
|
+
sse.onmessage = (event) => {
|
|
32
|
+
const data = JSON.parse(event.data);
|
|
33
|
+
if (data.payload.quitStream)
|
|
34
|
+
sse.close();
|
|
35
|
+
cb(data);
|
|
36
|
+
};
|
|
37
|
+
sse.onerror = (event) => {
|
|
38
|
+
console.error(event);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Conversation = Conversation;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ErrorCode } from "./error";
|
|
2
|
+
type AIChatResultFail = {
|
|
3
|
+
success: false;
|
|
4
|
+
errorcode: ErrorCode;
|
|
5
|
+
};
|
|
6
|
+
type AIChatResultSuccess = {
|
|
7
|
+
success: true;
|
|
8
|
+
response: AIResponse[];
|
|
9
|
+
usage: any;
|
|
10
|
+
};
|
|
11
|
+
export type AIChatResult = AIChatResultFail | AIChatResultSuccess;
|
|
12
|
+
type BaseAIResponseMetadata = {
|
|
13
|
+
/** The model that generated this message */
|
|
14
|
+
model: string;
|
|
15
|
+
/** The actual model ID that generated this message */
|
|
16
|
+
modelId: string;
|
|
17
|
+
/** Epoch time for when this happened */
|
|
18
|
+
timestamp: number;
|
|
19
|
+
};
|
|
20
|
+
type AIMessageResponse = {
|
|
21
|
+
/** Specifies type to be a message */
|
|
22
|
+
type: "message";
|
|
23
|
+
payload: {
|
|
24
|
+
/** Message to send to the user */
|
|
25
|
+
message: string;
|
|
26
|
+
/** The associated message id */
|
|
27
|
+
messageId: string;
|
|
28
|
+
/** Whether this message was completed */
|
|
29
|
+
completed: boolean;
|
|
30
|
+
};
|
|
31
|
+
metadata: BaseAIResponseMetadata & {};
|
|
32
|
+
};
|
|
33
|
+
type AIResponseStatusResponse = {
|
|
34
|
+
/** Specifies type to be a status update for the response */
|
|
35
|
+
type: "response_status";
|
|
36
|
+
payload: {
|
|
37
|
+
/** Whether the entire AI response is completed */
|
|
38
|
+
completed: boolean;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type AIConvoStatusResponse = {
|
|
42
|
+
/** Specifies type to be a status update for the conversation */
|
|
43
|
+
type: "convo_status";
|
|
44
|
+
payload: {
|
|
45
|
+
/** Whether the entire AI convo has been disabled, a disabled convo cannot be restarted */
|
|
46
|
+
disabled: boolean;
|
|
47
|
+
/** Whether the AI convo has been stopped, a stopped convo can be restarted
|
|
48
|
+
* although just because it's not stopped does not necasserily mean it's an ongoing conversation */
|
|
49
|
+
stopped: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type AIToolResponse = {
|
|
53
|
+
/** Specifies type to be a tool use status update */
|
|
54
|
+
type: "tool";
|
|
55
|
+
payload: {};
|
|
56
|
+
metadata: BaseAIResponseMetadata & {};
|
|
57
|
+
};
|
|
58
|
+
export type AIResponse = AIMessageResponse | AIToolResponse | AIConvoStatusResponse | AIResponseStatusResponse;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AIResponse } from "./ai_response_v3";
|
|
2
|
+
import { ErrorCode } from "./error";
|
|
3
|
+
type RequestBaseResponsePayload = {
|
|
4
|
+
/** Whether the conversation's ending */
|
|
5
|
+
end?: boolean;
|
|
6
|
+
/** Whether the stream is ending */
|
|
7
|
+
quitStream?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type RequestFailResponse = {
|
|
10
|
+
success: false;
|
|
11
|
+
data: {
|
|
12
|
+
/** Error code */
|
|
13
|
+
code: ErrorCode;
|
|
14
|
+
/** Error message */
|
|
15
|
+
error: string;
|
|
16
|
+
/** User facing message */
|
|
17
|
+
message: string;
|
|
18
|
+
} & RequestBaseResponsePayload;
|
|
19
|
+
};
|
|
20
|
+
export type RequestSucessResponse = {
|
|
21
|
+
success: true;
|
|
22
|
+
data: {
|
|
23
|
+
/** The AI's response */
|
|
24
|
+
response: AIResponse;
|
|
25
|
+
} & RequestBaseResponsePayload;
|
|
26
|
+
};
|
|
27
|
+
export type RequestResponse = RequestFailResponse | RequestSucessResponse;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ErrorCode = string;
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@butlerbot/sdk",
|
|
3
|
+
"version": "0.0.1-alpha1",
|
|
4
|
+
"description": "The official ButlerBot SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"pack": "npm run build && npm pack --pack-destination=\"G:\\tarballs\"",
|
|
13
|
+
|
|
14
|
+
"test": "jest"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"butlerbot",
|
|
18
|
+
"alfred",
|
|
19
|
+
"sdk",
|
|
20
|
+
"chatbot",
|
|
21
|
+
"ai",
|
|
22
|
+
"butler"
|
|
23
|
+
],
|
|
24
|
+
"author": "Fragly",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/isdevco/alfred5_sdk.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/isdevco/alfred5_sdk/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://butlerbot.net",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=14.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.13.10",
|
|
39
|
+
"typescript": "^5.8.2"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"eventsource": "^3.0.5"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# ButlerBot SDK
|
|
2
|
+
|
|
3
|
+
ButlerBot SDK is a JavaScript library that provides a simple way to interact with the [ButlerBot](https://butlerbot.net/) API.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- ButlerBot API key
|
|
8
|
+
|
|
9
|
+
## Example
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { ButlerBotClient } from "butlerbot";
|
|
13
|
+
|
|
14
|
+
const client = new ButlerBotClient({
|
|
15
|
+
apiKey: "your_api_key_here",
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const convo = client.createConversation();
|
|
19
|
+
|
|
20
|
+
convo.send("Hey there Alfred!", (res) => {
|
|
21
|
+
if (!res.success) return;
|
|
22
|
+
|
|
23
|
+
const { type, payload } = res.data.response;
|
|
24
|
+
console.log(type, payload); // message { message: "Good day", ... }
|
|
25
|
+
});
|
|
26
|
+
```
|