botversion-sdk 1.0.3 → 1.0.4
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/bin/init.js +5 -2
- package/cli/generator.js +4 -4
- package/client.js +2 -1
- package/index.js +3 -2
- package/package.json +1 -1
package/bin/init.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
// botversion-sdk/bin/init.js
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
@@ -113,7 +113,10 @@ async function main() {
|
|
|
113
113
|
step("Fetching project info from platform...");
|
|
114
114
|
let projectInfo;
|
|
115
115
|
try {
|
|
116
|
-
projectInfo = await fetchProjectInfo(
|
|
116
|
+
projectInfo = await fetchProjectInfo(
|
|
117
|
+
args.key,
|
|
118
|
+
"https://chatbusiness-two.vercel.app",
|
|
119
|
+
);
|
|
117
120
|
success(`Project found — ID: ${projectInfo.projectId}`);
|
|
118
121
|
} catch (err) {
|
|
119
122
|
error(err.message);
|
package/cli/generator.js
CHANGED
|
@@ -366,7 +366,7 @@ export async function POST(req${typeAnnotation}) {
|
|
|
366
366
|
};
|
|
367
367
|
|
|
368
368
|
// Forward to BotVersion platform directly
|
|
369
|
-
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || '
|
|
369
|
+
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || 'https://chatbusiness-two.vercel.app'}/api/chatbot/widget-chat\`, {
|
|
370
370
|
method: 'POST',
|
|
371
371
|
headers: { 'Content-Type': 'application/json' },
|
|
372
372
|
body: JSON.stringify({
|
|
@@ -405,7 +405,7 @@ export async function POST(req${typeAnnotation}) {
|
|
|
405
405
|
const { userId } = await auth();
|
|
406
406
|
const body = await req.json();
|
|
407
407
|
|
|
408
|
-
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || '
|
|
408
|
+
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || 'https://chatbusiness-two.vercel.app'}/api/chatbot/widget-chat\`, {
|
|
409
409
|
method: 'POST',
|
|
410
410
|
headers: { 'Content-Type': 'application/json' },
|
|
411
411
|
body: JSON.stringify({
|
|
@@ -444,7 +444,7 @@ export async function POST(req${typeAnnotation}) {
|
|
|
444
444
|
const { data: { session } } = await supabase.auth.getSession();
|
|
445
445
|
const body = await req.json();
|
|
446
446
|
|
|
447
|
-
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || '
|
|
447
|
+
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || 'https://chatbusiness-two.vercel.app'}/api/chatbot/widget-chat\`, {
|
|
448
448
|
method: 'POST',
|
|
449
449
|
headers: { 'Content-Type': 'application/json' },
|
|
450
450
|
body: JSON.stringify({
|
|
@@ -491,7 +491,7 @@ export async function POST(req${typeAnnotation}) {
|
|
|
491
491
|
// Add userContext here if needed:
|
|
492
492
|
// const userContext = { userId: '...', email: '...' };
|
|
493
493
|
|
|
494
|
-
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || '
|
|
494
|
+
const response = await fetch(\`\${process.env.BOTVERSION_PLATFORM_URL || 'https://chatbusiness-two.vercel.app'}/api/chatbot/widget-chat\`, {
|
|
495
495
|
method: 'POST',
|
|
496
496
|
headers: { 'Content-Type': 'application/json' },
|
|
497
497
|
body: JSON.stringify({
|
package/client.js
CHANGED
|
@@ -12,7 +12,8 @@ const url = require("url");
|
|
|
12
12
|
function BotVersionClient(options) {
|
|
13
13
|
this.apiKey = options.apiKey;
|
|
14
14
|
this.chatbotId = options.chatbotId;
|
|
15
|
-
this.platformUrl =
|
|
15
|
+
this.platformUrl =
|
|
16
|
+
options.platformUrl || "https://chatbusiness-two.vercel.app";
|
|
16
17
|
this.debug = options.debug || false;
|
|
17
18
|
this.timeout = options.timeout || 30000;
|
|
18
19
|
|
package/index.js
CHANGED
|
@@ -61,7 +61,7 @@ var BotVersion = {
|
|
|
61
61
|
|
|
62
62
|
this._client = new BotVersionClient({
|
|
63
63
|
apiKey: options.apiKey,
|
|
64
|
-
platformUrl: options.platformUrl || "
|
|
64
|
+
platformUrl: options.platformUrl || "https://chatbusiness-two.vercel.app",
|
|
65
65
|
debug: options.debug || false,
|
|
66
66
|
timeout: options.timeout || 30000,
|
|
67
67
|
});
|
|
@@ -400,7 +400,8 @@ BotVersion.nextHandler = function (options) {
|
|
|
400
400
|
|
|
401
401
|
self._client = new BotVersionClient({
|
|
402
402
|
apiKey: apiKey,
|
|
403
|
-
platformUrl:
|
|
403
|
+
platformUrl:
|
|
404
|
+
options.platformUrl || "https://chatbusiness-two.vercel.app",
|
|
404
405
|
debug: options.debug || false,
|
|
405
406
|
timeout: options.timeout || 30000,
|
|
406
407
|
});
|