plazbot-cli 0.2.19 → 0.2.20
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.
|
@@ -10,6 +10,7 @@ const plazbot_1 = require("plazbot");
|
|
|
10
10
|
const credentials_1 = require("../../utils/credentials");
|
|
11
11
|
const logger_1 = require("../../utils/logger");
|
|
12
12
|
const ui_1 = require("../../utils/ui");
|
|
13
|
+
const wizard_1 = require("./wizard");
|
|
13
14
|
// Plantilla: Clinica
|
|
14
15
|
const plantillaClinica = {
|
|
15
16
|
"name": "Asistente Clinica Salud",
|
|
@@ -704,23 +705,24 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
704
705
|
}]);
|
|
705
706
|
placeholderAnswers[ph.key] = value.trim();
|
|
706
707
|
}
|
|
707
|
-
// Paso 3: WhatsApp
|
|
708
|
-
console.log(ui_1.theme.bold('\n
|
|
709
|
-
const {
|
|
708
|
+
// Paso 3: Canales (WhatsApp, Messenger, Instagram, Telegram)
|
|
709
|
+
console.log(ui_1.theme.bold('\n Conexion de canales'));
|
|
710
|
+
const { wantChannels } = await inquirer_1.default.prompt([{
|
|
710
711
|
type: 'confirm',
|
|
711
|
-
name: '
|
|
712
|
-
message: 'Deseas
|
|
712
|
+
name: 'wantChannels',
|
|
713
|
+
message: 'Deseas conectar canales (WhatsApp, Messenger, Instagram, Telegram)?',
|
|
713
714
|
default: true,
|
|
714
715
|
}]);
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
716
|
+
const credentials = await (0, credentials_1.getStoredCredentials)();
|
|
717
|
+
let connectedChannels = [];
|
|
718
|
+
if (wantChannels) {
|
|
719
|
+
const wizardCtx = {
|
|
720
|
+
zone: credentials.zone,
|
|
721
|
+
workspaceId: credentials.workspace,
|
|
722
|
+
apiKey: credentials.apiKey,
|
|
723
|
+
dev: !!options.dev,
|
|
724
|
+
};
|
|
725
|
+
connectedChannels = await (0, wizard_1.connectChannelFlow)(wizardCtx);
|
|
724
726
|
}
|
|
725
727
|
// Paso 4: API Key de OpenAI
|
|
726
728
|
console.log(ui_1.theme.bold('\n Configuracion de IA'));
|
|
@@ -752,8 +754,8 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
752
754
|
const configClone = JSON.parse(JSON.stringify(template.config));
|
|
753
755
|
const finalConfig = replacePlaceholders(configClone, placeholderAnswers);
|
|
754
756
|
finalConfig.timezone = timezone;
|
|
755
|
-
if (
|
|
756
|
-
finalConfig.channels =
|
|
757
|
+
if (connectedChannels.length > 0) {
|
|
758
|
+
finalConfig.channels = connectedChannels;
|
|
757
759
|
}
|
|
758
760
|
else {
|
|
759
761
|
finalConfig.channels = [];
|
|
@@ -773,7 +775,7 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
773
775
|
for (const ph of template.placeholders) {
|
|
774
776
|
console.log((0, ui_1.kvPair)(ph.label, placeholderAnswers[ph.key]));
|
|
775
777
|
}
|
|
776
|
-
console.log((0, ui_1.kvPair)('
|
|
778
|
+
console.log((0, ui_1.kvPair)('Canales', connectedChannels.length > 0 ? connectedChannels.map(c => `${c.channel} (${c.key})`).join(', ') : 'No configurado'));
|
|
777
779
|
console.log((0, ui_1.kvPair)('API Key OpenAI', apiToken ? 'Configurada' : 'No configurada (el agente no funcionara sin ella)'));
|
|
778
780
|
console.log((0, ui_1.kvPair)('Zona horaria', timezone));
|
|
779
781
|
console.log((0, ui_1.kvPair)('Acciones', String(finalConfig.actions.length)));
|
|
@@ -790,7 +792,6 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
790
792
|
return;
|
|
791
793
|
}
|
|
792
794
|
// Paso 7: Crear agente
|
|
793
|
-
const credentials = await (0, credentials_1.getStoredCredentials)();
|
|
794
795
|
const agent = new plazbot_1.Agent({
|
|
795
796
|
workspaceId: credentials.workspace,
|
|
796
797
|
apiKey: credentials.apiKey,
|
|
@@ -808,16 +809,20 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
808
809
|
}
|
|
809
810
|
logger_1.logger.label('Nombre', finalConfig.name);
|
|
810
811
|
logger_1.logger.label('Industria', template.industry);
|
|
811
|
-
if (
|
|
812
|
-
logger_1.logger.label('
|
|
812
|
+
if (connectedChannels.length > 0) {
|
|
813
|
+
logger_1.logger.label('Canales', connectedChannels.map(c => `${c.channel} (${c.key})`).join(', '));
|
|
813
814
|
}
|
|
814
815
|
logger_1.logger.label('Acciones', String(finalConfig.actions.length));
|
|
815
816
|
console.log();
|
|
816
817
|
console.log((0, ui_1.section)('Siguientes pasos'));
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
818
|
+
if (connectedChannels.length === 0) {
|
|
819
|
+
console.log(ui_1.theme.bold(' 1.') + ' Conecta canales desde: ' + ui_1.theme.success('plazbot agent chat -a <agentId>'));
|
|
820
|
+
console.log(ui_1.theme.bold(' 2.') + ' O conecta desde la plataforma en Ajustes > Integraciones');
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
console.log(ui_1.theme.bold(' 1.') + ' Tu agente ya tiene canales conectados y activados');
|
|
824
|
+
}
|
|
825
|
+
console.log(ui_1.theme.bold(` ${connectedChannels.length === 0 ? '3' : '2'}.`) + ' Agrega tu API Key de OpenAI si no la configuraste');
|
|
821
826
|
console.log();
|
|
822
827
|
if (!apiToken) {
|
|
823
828
|
logger_1.logger.warning('Recuerda configurar tu API Key de OpenAI para que el agente funcione:');
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.connectChannelFlow = connectChannelFlow;
|
|
6
7
|
exports.runAgentWizard = runAgentWizard;
|
|
7
8
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { getStoredCredentials } from '../../utils/credentials';
|
|
|
5
5
|
import { logger } from '../../utils/logger';
|
|
6
6
|
import { theme, section, kvPair, createTable, createSpinner } from '../../utils/ui';
|
|
7
7
|
import { AgentCommandOptions } from '../../types/agent';
|
|
8
|
+
import { connectChannelFlow, WizardContext } from './wizard';
|
|
8
9
|
|
|
9
10
|
interface TemplatePlaceholder {
|
|
10
11
|
key: string;
|
|
@@ -727,24 +728,25 @@ export const templatesCommand = new Command('templates')
|
|
|
727
728
|
placeholderAnswers[ph.key] = value.trim();
|
|
728
729
|
}
|
|
729
730
|
|
|
730
|
-
// Paso 3: WhatsApp
|
|
731
|
-
console.log(theme.bold('\n
|
|
732
|
-
const {
|
|
731
|
+
// Paso 3: Canales (WhatsApp, Messenger, Instagram, Telegram)
|
|
732
|
+
console.log(theme.bold('\n Conexion de canales'));
|
|
733
|
+
const { wantChannels } = await (inquirer as any).prompt([{
|
|
733
734
|
type: 'confirm',
|
|
734
|
-
name: '
|
|
735
|
-
message: 'Deseas
|
|
735
|
+
name: 'wantChannels',
|
|
736
|
+
message: 'Deseas conectar canales (WhatsApp, Messenger, Instagram, Telegram)?',
|
|
736
737
|
default: true,
|
|
737
738
|
}]);
|
|
738
739
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
740
|
+
const credentials = await getStoredCredentials();
|
|
741
|
+
let connectedChannels: { channel: string; key: string; multianswer: boolean }[] = [];
|
|
742
|
+
if (wantChannels) {
|
|
743
|
+
const wizardCtx: WizardContext = {
|
|
744
|
+
zone: credentials.zone,
|
|
745
|
+
workspaceId: credentials.workspace,
|
|
746
|
+
apiKey: credentials.apiKey,
|
|
747
|
+
dev: !!options.dev,
|
|
748
|
+
};
|
|
749
|
+
connectedChannels = await connectChannelFlow(wizardCtx);
|
|
748
750
|
}
|
|
749
751
|
|
|
750
752
|
// Paso 4: API Key de OpenAI
|
|
@@ -782,8 +784,8 @@ export const templatesCommand = new Command('templates')
|
|
|
782
784
|
|
|
783
785
|
finalConfig.timezone = timezone;
|
|
784
786
|
|
|
785
|
-
if (
|
|
786
|
-
finalConfig.channels =
|
|
787
|
+
if (connectedChannels.length > 0) {
|
|
788
|
+
finalConfig.channels = connectedChannels;
|
|
787
789
|
} else {
|
|
788
790
|
finalConfig.channels = [];
|
|
789
791
|
}
|
|
@@ -805,7 +807,7 @@ export const templatesCommand = new Command('templates')
|
|
|
805
807
|
for (const ph of template.placeholders) {
|
|
806
808
|
console.log(kvPair(ph.label, placeholderAnswers[ph.key]));
|
|
807
809
|
}
|
|
808
|
-
console.log(kvPair('
|
|
810
|
+
console.log(kvPair('Canales', connectedChannels.length > 0 ? connectedChannels.map(c => `${c.channel} (${c.key})`).join(', ') : 'No configurado'));
|
|
809
811
|
console.log(kvPair('API Key OpenAI', apiToken ? 'Configurada' : 'No configurada (el agente no funcionara sin ella)'));
|
|
810
812
|
console.log(kvPair('Zona horaria', timezone));
|
|
811
813
|
console.log(kvPair('Acciones', String(finalConfig.actions.length)));
|
|
@@ -825,8 +827,6 @@ export const templatesCommand = new Command('templates')
|
|
|
825
827
|
}
|
|
826
828
|
|
|
827
829
|
// Paso 7: Crear agente
|
|
828
|
-
const credentials = await getStoredCredentials();
|
|
829
|
-
|
|
830
830
|
const agent = new Agent({
|
|
831
831
|
workspaceId: credentials.workspace,
|
|
832
832
|
apiKey: credentials.apiKey,
|
|
@@ -849,17 +849,20 @@ export const templatesCommand = new Command('templates')
|
|
|
849
849
|
}
|
|
850
850
|
logger.label('Nombre', finalConfig.name);
|
|
851
851
|
logger.label('Industria', template.industry);
|
|
852
|
-
if (
|
|
853
|
-
logger.label('
|
|
852
|
+
if (connectedChannels.length > 0) {
|
|
853
|
+
logger.label('Canales', connectedChannels.map(c => `${c.channel} (${c.key})`).join(', '));
|
|
854
854
|
}
|
|
855
855
|
logger.label('Acciones', String(finalConfig.actions.length));
|
|
856
856
|
|
|
857
857
|
console.log();
|
|
858
858
|
console.log(section('Siguientes pasos'));
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
859
|
+
if (connectedChannels.length === 0) {
|
|
860
|
+
console.log(theme.bold(' 1.') + ' Conecta canales desde: ' + theme.success('plazbot agent chat -a <agentId>'));
|
|
861
|
+
console.log(theme.bold(' 2.') + ' O conecta desde la plataforma en Ajustes > Integraciones');
|
|
862
|
+
} else {
|
|
863
|
+
console.log(theme.bold(' 1.') + ' Tu agente ya tiene canales conectados y activados');
|
|
864
|
+
}
|
|
865
|
+
console.log(theme.bold(` ${connectedChannels.length === 0 ? '3' : '2'}.`) + ' Agrega tu API Key de OpenAI si no la configuraste');
|
|
863
866
|
console.log();
|
|
864
867
|
|
|
865
868
|
if (!apiToken) {
|
|
@@ -96,7 +96,7 @@ const MODELS: Record<string, string[]> = {
|
|
|
96
96
|
|
|
97
97
|
const COLORS = ['blue', 'green', 'orange', 'gray', 'white'];
|
|
98
98
|
|
|
99
|
-
interface WizardContext {
|
|
99
|
+
export interface WizardContext {
|
|
100
100
|
zone: string;
|
|
101
101
|
workspaceId: string;
|
|
102
102
|
apiKey: string;
|
|
@@ -160,7 +160,7 @@ async function activateIntegration(baseUrl: string, workspaceId: string, integra
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
async function connectChannelFlow(ctx: WizardContext): Promise<AgentChannel[]> {
|
|
163
|
+
export async function connectChannelFlow(ctx: WizardContext): Promise<AgentChannel[]> {
|
|
164
164
|
const channels: AgentChannel[] = [];
|
|
165
165
|
const baseUrl = getBaseUrl(ctx.zone, ctx.dev);
|
|
166
166
|
const headers = {
|