machinaos 0.0.1
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/.env.template +71 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/bin/cli.js +159 -0
- package/client/.dockerignore +45 -0
- package/client/Dockerfile +68 -0
- package/client/eslint.config.js +29 -0
- package/client/index.html +13 -0
- package/client/nginx.conf +66 -0
- package/client/package.json +48 -0
- package/client/src/App.tsx +27 -0
- package/client/src/Dashboard.tsx +1173 -0
- package/client/src/ParameterPanel.tsx +301 -0
- package/client/src/components/AIAgentNode.tsx +321 -0
- package/client/src/components/APIKeyValidator.tsx +118 -0
- package/client/src/components/ClaudeChatModelNode.tsx +18 -0
- package/client/src/components/ConditionalEdge.tsx +189 -0
- package/client/src/components/CredentialsModal.tsx +306 -0
- package/client/src/components/EdgeConditionEditor.tsx +443 -0
- package/client/src/components/GeminiChatModelNode.tsx +18 -0
- package/client/src/components/GenericNode.tsx +357 -0
- package/client/src/components/LocationParameterPanel.tsx +154 -0
- package/client/src/components/ModelNode.tsx +286 -0
- package/client/src/components/OpenAIChatModelNode.tsx +18 -0
- package/client/src/components/OutputPanel.tsx +471 -0
- package/client/src/components/ParameterRenderer.tsx +1874 -0
- package/client/src/components/SkillEditorModal.tsx +417 -0
- package/client/src/components/SquareNode.tsx +797 -0
- package/client/src/components/StartNode.tsx +250 -0
- package/client/src/components/ToolkitNode.tsx +365 -0
- package/client/src/components/TriggerNode.tsx +463 -0
- package/client/src/components/auth/LoginPage.tsx +247 -0
- package/client/src/components/auth/ProtectedRoute.tsx +59 -0
- package/client/src/components/base/BaseChatModelNode.tsx +271 -0
- package/client/src/components/icons/AIProviderIcons.tsx +50 -0
- package/client/src/components/maps/GoogleMapsPicker.tsx +137 -0
- package/client/src/components/maps/MapsPreviewPanel.tsx +110 -0
- package/client/src/components/maps/index.ts +26 -0
- package/client/src/components/parameterPanel/InputSection.tsx +1094 -0
- package/client/src/components/parameterPanel/LocationPanelLayout.tsx +65 -0
- package/client/src/components/parameterPanel/MapsSection.tsx +92 -0
- package/client/src/components/parameterPanel/MiddleSection.tsx +571 -0
- package/client/src/components/parameterPanel/OutputSection.tsx +81 -0
- package/client/src/components/parameterPanel/ParameterPanelLayout.tsx +82 -0
- package/client/src/components/parameterPanel/ToolSchemaEditor.tsx +436 -0
- package/client/src/components/parameterPanel/index.ts +42 -0
- package/client/src/components/shared/DataPanel.tsx +142 -0
- package/client/src/components/shared/JSONTreeRenderer.tsx +106 -0
- package/client/src/components/ui/AIResultModal.tsx +204 -0
- package/client/src/components/ui/AndroidSettingsPanel.tsx +401 -0
- package/client/src/components/ui/CodeEditor.tsx +81 -0
- package/client/src/components/ui/CollapsibleSection.tsx +88 -0
- package/client/src/components/ui/ComponentItem.tsx +154 -0
- package/client/src/components/ui/ComponentPalette.tsx +321 -0
- package/client/src/components/ui/ConsolePanel.tsx +1074 -0
- package/client/src/components/ui/ErrorBoundary.tsx +196 -0
- package/client/src/components/ui/InputNodesPanel.tsx +204 -0
- package/client/src/components/ui/MapSelector.tsx +314 -0
- package/client/src/components/ui/Modal.tsx +149 -0
- package/client/src/components/ui/NodeContextMenu.tsx +192 -0
- package/client/src/components/ui/NodeOutputPanel.tsx +1150 -0
- package/client/src/components/ui/OutputDisplayPanel.tsx +381 -0
- package/client/src/components/ui/SettingsPanel.tsx +243 -0
- package/client/src/components/ui/TopToolbar.tsx +736 -0
- package/client/src/components/ui/WhatsAppSettingsPanel.tsx +345 -0
- package/client/src/components/ui/WorkflowSidebar.tsx +294 -0
- package/client/src/config/antdTheme.ts +186 -0
- package/client/src/config/api.ts +54 -0
- package/client/src/contexts/AuthContext.tsx +221 -0
- package/client/src/contexts/ThemeContext.tsx +42 -0
- package/client/src/contexts/WebSocketContext.tsx +1971 -0
- package/client/src/factories/baseChatModelFactory.ts +256 -0
- package/client/src/hooks/useAndroidOperations.ts +164 -0
- package/client/src/hooks/useApiKeyValidation.ts +107 -0
- package/client/src/hooks/useApiKeys.ts +238 -0
- package/client/src/hooks/useAppTheme.ts +17 -0
- package/client/src/hooks/useComponentPalette.ts +51 -0
- package/client/src/hooks/useCopyPaste.ts +155 -0
- package/client/src/hooks/useDragAndDrop.ts +124 -0
- package/client/src/hooks/useDragVariable.ts +88 -0
- package/client/src/hooks/useExecution.ts +313 -0
- package/client/src/hooks/useParameterPanel.ts +176 -0
- package/client/src/hooks/useReactFlowNodes.ts +189 -0
- package/client/src/hooks/useToolSchema.ts +209 -0
- package/client/src/hooks/useWhatsApp.ts +196 -0
- package/client/src/hooks/useWorkflowManagement.ts +46 -0
- package/client/src/index.css +315 -0
- package/client/src/main.tsx +19 -0
- package/client/src/nodeDefinitions/aiAgentNodes.ts +336 -0
- package/client/src/nodeDefinitions/aiModelNodes.ts +340 -0
- package/client/src/nodeDefinitions/androidDeviceNodes.ts +140 -0
- package/client/src/nodeDefinitions/androidServiceNodes.ts +383 -0
- package/client/src/nodeDefinitions/chatNodes.ts +135 -0
- package/client/src/nodeDefinitions/codeNodes.ts +54 -0
- package/client/src/nodeDefinitions/documentNodes.ts +379 -0
- package/client/src/nodeDefinitions/index.ts +15 -0
- package/client/src/nodeDefinitions/locationNodes.ts +463 -0
- package/client/src/nodeDefinitions/schedulerNodes.ts +220 -0
- package/client/src/nodeDefinitions/skillNodes.ts +211 -0
- package/client/src/nodeDefinitions/toolNodes.ts +198 -0
- package/client/src/nodeDefinitions/utilityNodes.ts +284 -0
- package/client/src/nodeDefinitions/whatsappNodes.ts +865 -0
- package/client/src/nodeDefinitions/workflowNodes.ts +41 -0
- package/client/src/nodeDefinitions.ts +104 -0
- package/client/src/schemas/workflowSchema.ts +264 -0
- package/client/src/services/dynamicParameterService.ts +96 -0
- package/client/src/services/execution/aiAgentExecutionService.ts +35 -0
- package/client/src/services/executionService.ts +232 -0
- package/client/src/services/workflowApi.ts +91 -0
- package/client/src/store/useAppStore.ts +582 -0
- package/client/src/styles/theme.ts +508 -0
- package/client/src/styles/zIndex.ts +17 -0
- package/client/src/types/ComponentTypes.ts +39 -0
- package/client/src/types/EdgeCondition.ts +231 -0
- package/client/src/types/INodeProperties.ts +288 -0
- package/client/src/types/NodeTypes.ts +28 -0
- package/client/src/utils/formatters.ts +33 -0
- package/client/src/utils/googleMapsLoader.ts +140 -0
- package/client/src/utils/locationUtils.ts +85 -0
- package/client/src/utils/nodeUtils.ts +31 -0
- package/client/src/utils/workflow.ts +30 -0
- package/client/src/utils/workflowExport.ts +120 -0
- package/client/src/vite-env.d.ts +12 -0
- package/client/tailwind.config.js +60 -0
- package/client/tsconfig.json +25 -0
- package/client/tsconfig.node.json +11 -0
- package/client/vite.config.js +35 -0
- package/docker-compose.prod.yml +107 -0
- package/docker-compose.yml +104 -0
- package/docs-MachinaOs/README.md +85 -0
- package/docs-MachinaOs/deployment/docker.mdx +228 -0
- package/docs-MachinaOs/deployment/production.mdx +345 -0
- package/docs-MachinaOs/docs.json +75 -0
- package/docs-MachinaOs/faq.mdx +309 -0
- package/docs-MachinaOs/favicon.svg +5 -0
- package/docs-MachinaOs/installation.mdx +160 -0
- package/docs-MachinaOs/introduction.mdx +114 -0
- package/docs-MachinaOs/logo/dark.svg +6 -0
- package/docs-MachinaOs/logo/light.svg +6 -0
- package/docs-MachinaOs/nodes/ai-agent.mdx +216 -0
- package/docs-MachinaOs/nodes/ai-models.mdx +240 -0
- package/docs-MachinaOs/nodes/android.mdx +411 -0
- package/docs-MachinaOs/nodes/overview.mdx +181 -0
- package/docs-MachinaOs/nodes/schedulers.mdx +316 -0
- package/docs-MachinaOs/nodes/webhooks.mdx +330 -0
- package/docs-MachinaOs/nodes/whatsapp.mdx +305 -0
- package/docs-MachinaOs/quickstart.mdx +119 -0
- package/docs-MachinaOs/tutorials/ai-agent-workflow.mdx +177 -0
- package/docs-MachinaOs/tutorials/android-automation.mdx +242 -0
- package/docs-MachinaOs/tutorials/first-workflow.mdx +134 -0
- package/docs-MachinaOs/tutorials/whatsapp-automation.mdx +185 -0
- package/nul +0 -0
- package/package.json +70 -0
- package/scripts/build.js +158 -0
- package/scripts/check-ports.ps1 +33 -0
- package/scripts/clean.js +40 -0
- package/scripts/docker.js +93 -0
- package/scripts/kill-port.ps1 +154 -0
- package/scripts/start.js +210 -0
- package/scripts/stop.js +325 -0
- package/server/.dockerignore +44 -0
- package/server/Dockerfile +45 -0
- package/server/constants.py +249 -0
- package/server/core/__init__.py +1 -0
- package/server/core/cache.py +461 -0
- package/server/core/config.py +128 -0
- package/server/core/container.py +99 -0
- package/server/core/database.py +1211 -0
- package/server/core/logging.py +314 -0
- package/server/main.py +289 -0
- package/server/middleware/__init__.py +5 -0
- package/server/middleware/auth.py +89 -0
- package/server/models/__init__.py +1 -0
- package/server/models/auth.py +52 -0
- package/server/models/cache.py +24 -0
- package/server/models/database.py +211 -0
- package/server/models/nodes.py +455 -0
- package/server/package.json +9 -0
- package/server/pyproject.toml +72 -0
- package/server/requirements.txt +83 -0
- package/server/routers/__init__.py +1 -0
- package/server/routers/android.py +294 -0
- package/server/routers/auth.py +203 -0
- package/server/routers/database.py +151 -0
- package/server/routers/maps.py +142 -0
- package/server/routers/nodejs_compat.py +289 -0
- package/server/routers/webhook.py +90 -0
- package/server/routers/websocket.py +2127 -0
- package/server/routers/whatsapp.py +761 -0
- package/server/routers/workflow.py +200 -0
- package/server/services/__init__.py +1 -0
- package/server/services/ai.py +2415 -0
- package/server/services/android/__init__.py +27 -0
- package/server/services/android/broadcaster.py +114 -0
- package/server/services/android/client.py +608 -0
- package/server/services/android/manager.py +78 -0
- package/server/services/android/protocol.py +165 -0
- package/server/services/android_service.py +588 -0
- package/server/services/auth.py +131 -0
- package/server/services/chat_client.py +160 -0
- package/server/services/deployment/__init__.py +12 -0
- package/server/services/deployment/manager.py +706 -0
- package/server/services/deployment/state.py +47 -0
- package/server/services/deployment/triggers.py +275 -0
- package/server/services/event_waiter.py +785 -0
- package/server/services/execution/__init__.py +77 -0
- package/server/services/execution/cache.py +769 -0
- package/server/services/execution/conditions.py +373 -0
- package/server/services/execution/dlq.py +132 -0
- package/server/services/execution/executor.py +1351 -0
- package/server/services/execution/models.py +531 -0
- package/server/services/execution/recovery.py +235 -0
- package/server/services/handlers/__init__.py +126 -0
- package/server/services/handlers/ai.py +355 -0
- package/server/services/handlers/android.py +260 -0
- package/server/services/handlers/code.py +278 -0
- package/server/services/handlers/document.py +598 -0
- package/server/services/handlers/http.py +193 -0
- package/server/services/handlers/polyglot.py +105 -0
- package/server/services/handlers/tools.py +845 -0
- package/server/services/handlers/triggers.py +107 -0
- package/server/services/handlers/utility.py +822 -0
- package/server/services/handlers/whatsapp.py +476 -0
- package/server/services/maps.py +289 -0
- package/server/services/memory_store.py +103 -0
- package/server/services/node_executor.py +375 -0
- package/server/services/parameter_resolver.py +218 -0
- package/server/services/polyglot_client.py +169 -0
- package/server/services/scheduler.py +155 -0
- package/server/services/skill_loader.py +417 -0
- package/server/services/status_broadcaster.py +826 -0
- package/server/services/temporal/__init__.py +23 -0
- package/server/services/temporal/activities.py +344 -0
- package/server/services/temporal/client.py +76 -0
- package/server/services/temporal/executor.py +147 -0
- package/server/services/temporal/worker.py +251 -0
- package/server/services/temporal/workflow.py +355 -0
- package/server/services/temporal/ws_client.py +236 -0
- package/server/services/text.py +111 -0
- package/server/services/user_auth.py +172 -0
- package/server/services/websocket_client.py +29 -0
- package/server/services/workflow.py +597 -0
- package/server/skills/android-skill/SKILL.md +82 -0
- package/server/skills/assistant-personality/SKILL.md +45 -0
- package/server/skills/code-skill/SKILL.md +140 -0
- package/server/skills/http-skill/SKILL.md +161 -0
- package/server/skills/maps-skill/SKILL.md +170 -0
- package/server/skills/memory-skill/SKILL.md +154 -0
- package/server/skills/scheduler-skill/SKILL.md +84 -0
- package/server/skills/whatsapp-skill/SKILL.md +283 -0
- package/server/uv.lock +2916 -0
- package/server/whatsapp-rpc/.dockerignore +30 -0
- package/server/whatsapp-rpc/Dockerfile +44 -0
- package/server/whatsapp-rpc/Dockerfile.web +17 -0
- package/server/whatsapp-rpc/README.md +139 -0
- package/server/whatsapp-rpc/cli.js +95 -0
- package/server/whatsapp-rpc/configs/config.yaml +7 -0
- package/server/whatsapp-rpc/docker-compose.yml +35 -0
- package/server/whatsapp-rpc/docs/API.md +410 -0
- package/server/whatsapp-rpc/go.mod +67 -0
- package/server/whatsapp-rpc/go.sum +203 -0
- package/server/whatsapp-rpc/package.json +30 -0
- package/server/whatsapp-rpc/schema.json +1294 -0
- package/server/whatsapp-rpc/scripts/clean.cjs +66 -0
- package/server/whatsapp-rpc/scripts/cli.js +162 -0
- package/server/whatsapp-rpc/src/go/cmd/server/main.go +91 -0
- package/server/whatsapp-rpc/src/go/config/config.go +49 -0
- package/server/whatsapp-rpc/src/go/rpc/rpc.go +446 -0
- package/server/whatsapp-rpc/src/go/rpc/server.go +112 -0
- package/server/whatsapp-rpc/src/go/whatsapp/history.go +166 -0
- package/server/whatsapp-rpc/src/go/whatsapp/messages.go +390 -0
- package/server/whatsapp-rpc/src/go/whatsapp/service.go +2130 -0
- package/server/whatsapp-rpc/src/go/whatsapp/types.go +261 -0
- package/server/whatsapp-rpc/src/python/pyproject.toml +15 -0
- package/server/whatsapp-rpc/src/python/whatsapp_rpc/__init__.py +4 -0
- package/server/whatsapp-rpc/src/python/whatsapp_rpc/client.py +427 -0
- package/server/whatsapp-rpc/web/app.py +609 -0
- package/server/whatsapp-rpc/web/requirements.txt +6 -0
- package/server/whatsapp-rpc/web/rpc_client.py +427 -0
- package/server/whatsapp-rpc/web/static/openapi.yaml +59 -0
- package/server/whatsapp-rpc/web/templates/base.html +150 -0
- package/server/whatsapp-rpc/web/templates/contacts.html +240 -0
- package/server/whatsapp-rpc/web/templates/dashboard.html +320 -0
- package/server/whatsapp-rpc/web/templates/groups.html +328 -0
- package/server/whatsapp-rpc/web/templates/messages.html +465 -0
- package/server/whatsapp-rpc/web/templates/messaging.html +681 -0
- package/server/whatsapp-rpc/web/templates/send.html +259 -0
- package/server/whatsapp-rpc/web/templates/settings.html +459 -0
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
// WhatsApp Node Definitions - Messaging integration via whatsmeow
|
|
2
|
+
import {
|
|
3
|
+
INodeTypeDescription,
|
|
4
|
+
NodeConnectionType
|
|
5
|
+
} from '../types/INodeProperties';
|
|
6
|
+
import { API_CONFIG } from '../config/api';
|
|
7
|
+
|
|
8
|
+
// Get WebSocket URL dynamically based on environment
|
|
9
|
+
const getWebSocketUrl = (): string => {
|
|
10
|
+
const baseUrl = API_CONFIG.PYTHON_BASE_URL;
|
|
11
|
+
|
|
12
|
+
// Production: empty base URL means use current origin
|
|
13
|
+
if (!baseUrl) {
|
|
14
|
+
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
|
15
|
+
return `${wsProtocol}://${window.location.host}/ws/status`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Development: convert http(s) to ws(s)
|
|
19
|
+
const wsProtocol = baseUrl.startsWith('https') ? 'wss' : 'ws';
|
|
20
|
+
const wsUrl = baseUrl.replace(/^https?/, wsProtocol);
|
|
21
|
+
return `${wsUrl}/ws/status`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Helper to make WebSocket requests
|
|
25
|
+
async function wsRequest(type: string, data: Record<string, unknown> = {}): Promise<unknown> {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const ws = new WebSocket(getWebSocketUrl());
|
|
28
|
+
const timeout = setTimeout(() => {
|
|
29
|
+
ws.close();
|
|
30
|
+
reject(new Error('WebSocket request timeout'));
|
|
31
|
+
}, 10000);
|
|
32
|
+
|
|
33
|
+
ws.onopen = () => {
|
|
34
|
+
ws.send(JSON.stringify({ type, ...data }));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
ws.onmessage = (event) => {
|
|
38
|
+
clearTimeout(timeout);
|
|
39
|
+
try {
|
|
40
|
+
const response = JSON.parse(event.data);
|
|
41
|
+
ws.close();
|
|
42
|
+
resolve(response);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
ws.close();
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
ws.onerror = (error) => {
|
|
50
|
+
clearTimeout(timeout);
|
|
51
|
+
ws.close();
|
|
52
|
+
reject(error);
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// WHATSAPP ICONS (SVG Data URIs)
|
|
59
|
+
// ============================================================================
|
|
60
|
+
|
|
61
|
+
// WhatsApp Send - Paper plane (send message)
|
|
62
|
+
const WHATSAPP_SEND_ICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2325D366'%3E%3Cpath d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z'/%3E%3C/svg%3E";
|
|
63
|
+
|
|
64
|
+
// WhatsApp Connect - Official WhatsApp logo (exported for use in skill nodes)
|
|
65
|
+
export const WHATSAPP_CONNECT_ICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2325D366'%3E%3Cpath d='M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z'/%3E%3C/svg%3E";
|
|
66
|
+
|
|
67
|
+
// WhatsApp Receive - Notification bell with dot (trigger node)
|
|
68
|
+
const WHATSAPP_RECEIVE_ICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2325D366'%3E%3Cpath d='M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z'/%3E%3Ccircle cx='18' cy='6' r='4'/%3E%3C/svg%3E";
|
|
69
|
+
|
|
70
|
+
// WhatsApp DB - Database icon (query contacts, groups, messages)
|
|
71
|
+
const WHATSAPP_DB_ICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2325D366'%3E%3Cpath d='M12 3C7.58 3 4 4.79 4 7v10c0 2.21 3.58 4 8 4s8-1.79 8-4V7c0-2.21-3.58-4-8-4zm0 2c3.87 0 6 1.5 6 2s-2.13 2-6 2-6-1.5-6-2 2.13-2 6-2zm6 12c0 .5-2.13 2-6 2s-6-1.5-6-2v-2.23c1.61.78 3.72 1.23 6 1.23s4.39-.45 6-1.23V17zm0-4c0 .5-2.13 2-6 2s-6-1.5-6-2v-2.23c1.61.78 3.72 1.23 6 1.23s4.39-.45 6-1.23V13zm0-4c0 .5-2.13 2-6 2s-6-1.5-6-2V6.77C7.61 7.55 9.72 8 12 8s4.39-.45 6-1.23V9z'/%3E%3C/svg%3E";
|
|
72
|
+
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// WHATSAPP NODES
|
|
75
|
+
// ============================================================================
|
|
76
|
+
|
|
77
|
+
export const whatsappNodes: Record<string, INodeTypeDescription> = {
|
|
78
|
+
// WhatsApp Send Message Node - Enhanced with full schema support
|
|
79
|
+
whatsappSend: {
|
|
80
|
+
displayName: 'WhatsApp Send',
|
|
81
|
+
name: 'whatsappSend',
|
|
82
|
+
icon: WHATSAPP_SEND_ICON,
|
|
83
|
+
group: ['whatsapp', 'tool'],
|
|
84
|
+
version: 1,
|
|
85
|
+
subtitle: 'Send WhatsApp Message',
|
|
86
|
+
description: 'Send text, media, location, or contact messages via WhatsApp',
|
|
87
|
+
defaults: { name: 'WhatsApp Send', color: '#25D366' },
|
|
88
|
+
inputs: [{
|
|
89
|
+
name: 'main',
|
|
90
|
+
displayName: 'Input',
|
|
91
|
+
type: 'main' as NodeConnectionType,
|
|
92
|
+
description: 'Message input'
|
|
93
|
+
}],
|
|
94
|
+
outputs: [
|
|
95
|
+
{
|
|
96
|
+
name: 'main',
|
|
97
|
+
displayName: 'Output',
|
|
98
|
+
type: 'main' as NodeConnectionType,
|
|
99
|
+
description: 'Message output'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'tool',
|
|
103
|
+
displayName: 'Tool',
|
|
104
|
+
type: 'main' as NodeConnectionType,
|
|
105
|
+
description: 'Connect to AI Agent tool handle'
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
properties: [
|
|
109
|
+
// ===== RECIPIENT =====
|
|
110
|
+
{
|
|
111
|
+
displayName: 'Send To',
|
|
112
|
+
name: 'recipient_type',
|
|
113
|
+
type: 'options',
|
|
114
|
+
options: [
|
|
115
|
+
{ name: 'Phone Number', value: 'phone' },
|
|
116
|
+
{ name: 'Group', value: 'group' }
|
|
117
|
+
],
|
|
118
|
+
default: 'phone',
|
|
119
|
+
description: 'Send to individual or group'
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
displayName: 'Phone Number',
|
|
123
|
+
name: 'phone',
|
|
124
|
+
type: 'string',
|
|
125
|
+
default: '',
|
|
126
|
+
required: true,
|
|
127
|
+
placeholder: '1234567890',
|
|
128
|
+
description: 'Recipient phone number (without + prefix)',
|
|
129
|
+
displayOptions: {
|
|
130
|
+
show: { recipient_type: ['phone'] }
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Group',
|
|
135
|
+
name: 'group_id',
|
|
136
|
+
type: 'string',
|
|
137
|
+
default: '',
|
|
138
|
+
required: true,
|
|
139
|
+
placeholder: '123456789@g.us',
|
|
140
|
+
description: 'Group JID to send message to (use Load button to select)',
|
|
141
|
+
displayOptions: {
|
|
142
|
+
show: { recipient_type: ['group'] }
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
// ===== MESSAGE TYPE =====
|
|
147
|
+
{
|
|
148
|
+
displayName: 'Message Type',
|
|
149
|
+
name: 'message_type',
|
|
150
|
+
type: 'options',
|
|
151
|
+
options: [
|
|
152
|
+
{ name: 'Text', value: 'text' },
|
|
153
|
+
{ name: 'Image', value: 'image' },
|
|
154
|
+
{ name: 'Video', value: 'video' },
|
|
155
|
+
{ name: 'Audio', value: 'audio' },
|
|
156
|
+
{ name: 'Document', value: 'document' },
|
|
157
|
+
{ name: 'Sticker', value: 'sticker' },
|
|
158
|
+
{ name: 'Location', value: 'location' },
|
|
159
|
+
{ name: 'Contact', value: 'contact' }
|
|
160
|
+
],
|
|
161
|
+
default: 'text',
|
|
162
|
+
description: 'Type of message to send'
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// ===== TEXT MESSAGE =====
|
|
166
|
+
{
|
|
167
|
+
displayName: 'Message',
|
|
168
|
+
name: 'message',
|
|
169
|
+
type: 'string',
|
|
170
|
+
default: '',
|
|
171
|
+
required: true,
|
|
172
|
+
typeOptions: { rows: 4 },
|
|
173
|
+
description: 'Text message content',
|
|
174
|
+
placeholder: 'Enter your message...',
|
|
175
|
+
displayOptions: {
|
|
176
|
+
show: { message_type: ['text'] }
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// ===== MEDIA MESSAGES (image, video, audio, document, sticker) =====
|
|
181
|
+
{
|
|
182
|
+
displayName: 'Media Source',
|
|
183
|
+
name: 'media_source',
|
|
184
|
+
type: 'options',
|
|
185
|
+
options: [
|
|
186
|
+
{ name: 'Base64 Data', value: 'base64' },
|
|
187
|
+
{ name: 'File Path', value: 'file' },
|
|
188
|
+
{ name: 'URL', value: 'url' }
|
|
189
|
+
],
|
|
190
|
+
default: 'base64',
|
|
191
|
+
description: 'Source of media data',
|
|
192
|
+
displayOptions: {
|
|
193
|
+
show: { message_type: ['image', 'video', 'audio', 'document', 'sticker'] }
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
displayName: 'Media Data (Base64)',
|
|
198
|
+
name: 'media_data',
|
|
199
|
+
type: 'string',
|
|
200
|
+
default: '',
|
|
201
|
+
required: true,
|
|
202
|
+
typeOptions: { rows: 3 },
|
|
203
|
+
description: 'Base64-encoded media data',
|
|
204
|
+
displayOptions: {
|
|
205
|
+
show: { message_type: ['image', 'video', 'audio', 'document', 'sticker'], media_source: ['base64'] }
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
displayName: 'File',
|
|
210
|
+
name: 'file_path',
|
|
211
|
+
type: 'file',
|
|
212
|
+
default: '',
|
|
213
|
+
required: true,
|
|
214
|
+
placeholder: '/path/to/file.jpg',
|
|
215
|
+
description: 'Upload a file or enter server path',
|
|
216
|
+
typeOptions: {
|
|
217
|
+
accept: '*/*'
|
|
218
|
+
},
|
|
219
|
+
displayOptions: {
|
|
220
|
+
show: { message_type: ['image', 'video', 'audio', 'document', 'sticker'], media_source: ['file'] }
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
displayName: 'Media URL',
|
|
225
|
+
name: 'media_url',
|
|
226
|
+
type: 'string',
|
|
227
|
+
default: '',
|
|
228
|
+
required: true,
|
|
229
|
+
placeholder: 'https://example.com/image.jpg',
|
|
230
|
+
description: 'URL to download media from',
|
|
231
|
+
displayOptions: {
|
|
232
|
+
show: { message_type: ['image', 'video', 'audio', 'document', 'sticker'], media_source: ['url'] }
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
displayName: 'MIME Type',
|
|
237
|
+
name: 'mime_type',
|
|
238
|
+
type: 'string',
|
|
239
|
+
default: '',
|
|
240
|
+
placeholder: 'image/jpeg, video/mp4, audio/ogg',
|
|
241
|
+
description: 'MIME type of the media (auto-detected if empty)',
|
|
242
|
+
displayOptions: {
|
|
243
|
+
show: { message_type: ['image', 'video', 'audio', 'document', 'sticker'] }
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
displayName: 'Caption',
|
|
248
|
+
name: 'caption',
|
|
249
|
+
type: 'string',
|
|
250
|
+
default: '',
|
|
251
|
+
typeOptions: { rows: 2 },
|
|
252
|
+
description: 'Optional caption for media',
|
|
253
|
+
displayOptions: {
|
|
254
|
+
show: { message_type: ['image', 'video', 'document'] }
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
displayName: 'Filename',
|
|
259
|
+
name: 'filename',
|
|
260
|
+
type: 'string',
|
|
261
|
+
default: '',
|
|
262
|
+
placeholder: 'document.pdf',
|
|
263
|
+
description: 'Filename for document',
|
|
264
|
+
displayOptions: {
|
|
265
|
+
show: { message_type: ['document'] }
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
// ===== LOCATION MESSAGE =====
|
|
270
|
+
{
|
|
271
|
+
displayName: 'Latitude',
|
|
272
|
+
name: 'latitude',
|
|
273
|
+
type: 'number',
|
|
274
|
+
default: 0,
|
|
275
|
+
required: true,
|
|
276
|
+
description: 'Location latitude',
|
|
277
|
+
displayOptions: {
|
|
278
|
+
show: { message_type: ['location'] }
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Longitude',
|
|
283
|
+
name: 'longitude',
|
|
284
|
+
type: 'number',
|
|
285
|
+
default: 0,
|
|
286
|
+
required: true,
|
|
287
|
+
description: 'Location longitude',
|
|
288
|
+
displayOptions: {
|
|
289
|
+
show: { message_type: ['location'] }
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
displayName: 'Location Name',
|
|
294
|
+
name: 'location_name',
|
|
295
|
+
type: 'string',
|
|
296
|
+
default: '',
|
|
297
|
+
placeholder: 'San Francisco',
|
|
298
|
+
description: 'Display name for location',
|
|
299
|
+
displayOptions: {
|
|
300
|
+
show: { message_type: ['location'] }
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
displayName: 'Address',
|
|
305
|
+
name: 'address',
|
|
306
|
+
type: 'string',
|
|
307
|
+
default: '',
|
|
308
|
+
placeholder: 'California, USA',
|
|
309
|
+
description: 'Address text',
|
|
310
|
+
displayOptions: {
|
|
311
|
+
show: { message_type: ['location'] }
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
// ===== CONTACT MESSAGE =====
|
|
316
|
+
{
|
|
317
|
+
displayName: 'Contact Name',
|
|
318
|
+
name: 'contact_name',
|
|
319
|
+
type: 'string',
|
|
320
|
+
default: '',
|
|
321
|
+
required: true,
|
|
322
|
+
placeholder: 'John Doe',
|
|
323
|
+
description: 'Display name for contact',
|
|
324
|
+
displayOptions: {
|
|
325
|
+
show: { message_type: ['contact'] }
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
displayName: 'Contact vCard',
|
|
330
|
+
name: 'vcard',
|
|
331
|
+
type: 'string',
|
|
332
|
+
default: '',
|
|
333
|
+
required: true,
|
|
334
|
+
typeOptions: { rows: 4 },
|
|
335
|
+
placeholder: 'BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+1234567890\nEND:VCARD',
|
|
336
|
+
description: 'vCard 3.0 format string',
|
|
337
|
+
displayOptions: {
|
|
338
|
+
show: { message_type: ['contact'] }
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
// ===== REPLY (QUOTE) =====
|
|
343
|
+
{
|
|
344
|
+
displayName: 'Reply To Message',
|
|
345
|
+
name: 'is_reply',
|
|
346
|
+
type: 'boolean',
|
|
347
|
+
default: false,
|
|
348
|
+
description: 'Quote an existing message'
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
displayName: 'Reply Message ID',
|
|
352
|
+
name: 'reply_message_id',
|
|
353
|
+
type: 'string',
|
|
354
|
+
default: '',
|
|
355
|
+
required: true,
|
|
356
|
+
placeholder: 'ABC123DEF456',
|
|
357
|
+
description: 'ID of message to reply to',
|
|
358
|
+
displayOptions: {
|
|
359
|
+
show: { is_reply: [true] }
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
displayName: 'Reply Sender',
|
|
364
|
+
name: 'reply_sender',
|
|
365
|
+
type: 'string',
|
|
366
|
+
default: '',
|
|
367
|
+
required: true,
|
|
368
|
+
placeholder: '1234567890@s.whatsapp.net',
|
|
369
|
+
description: 'Sender JID of quoted message',
|
|
370
|
+
displayOptions: {
|
|
371
|
+
show: { is_reply: [true] }
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
displayName: 'Reply Preview',
|
|
376
|
+
name: 'reply_content',
|
|
377
|
+
type: 'string',
|
|
378
|
+
default: '',
|
|
379
|
+
placeholder: 'Original message text...',
|
|
380
|
+
description: 'Text preview of quoted message',
|
|
381
|
+
displayOptions: {
|
|
382
|
+
show: { is_reply: [true] }
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
// WhatsApp Connection/Auth Node
|
|
389
|
+
whatsappConnect: {
|
|
390
|
+
displayName: 'WhatsApp Connect',
|
|
391
|
+
name: 'whatsappConnect',
|
|
392
|
+
icon: WHATSAPP_CONNECT_ICON,
|
|
393
|
+
group: ['whatsapp'],
|
|
394
|
+
version: 1,
|
|
395
|
+
subtitle: 'WhatsApp Status',
|
|
396
|
+
description: 'Check WhatsApp connection status (QR code authentication removed - use external WhatsApp service)',
|
|
397
|
+
defaults: { name: 'WhatsApp Connect', color: '#128C7E' },
|
|
398
|
+
inputs: [],
|
|
399
|
+
outputs: [{
|
|
400
|
+
name: 'main',
|
|
401
|
+
displayName: 'Output',
|
|
402
|
+
type: 'main' as NodeConnectionType,
|
|
403
|
+
description: 'Connection output'
|
|
404
|
+
}],
|
|
405
|
+
properties: [
|
|
406
|
+
{
|
|
407
|
+
displayName: 'Connection Type',
|
|
408
|
+
name: 'connectionType',
|
|
409
|
+
type: 'options',
|
|
410
|
+
options: [
|
|
411
|
+
{
|
|
412
|
+
name: 'Scan QR Code',
|
|
413
|
+
value: 'qr_code'
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
name: 'Use Existing Session',
|
|
417
|
+
value: 'existing'
|
|
418
|
+
}
|
|
419
|
+
],
|
|
420
|
+
default: 'qr_code',
|
|
421
|
+
description: 'How to connect to WhatsApp'
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
displayName: 'Session Info',
|
|
425
|
+
name: 'sessionInfo',
|
|
426
|
+
type: 'notice',
|
|
427
|
+
default: 'Session will persist across workflow runs. Re-authentication required approximately every 20 days.'
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
// WhatsApp Receive Message - triggers workflow on incoming messages
|
|
433
|
+
whatsappReceive: {
|
|
434
|
+
displayName: 'WhatsApp Receive',
|
|
435
|
+
name: 'whatsappReceive',
|
|
436
|
+
icon: WHATSAPP_RECEIVE_ICON,
|
|
437
|
+
group: ['whatsapp', 'trigger'],
|
|
438
|
+
version: 1,
|
|
439
|
+
subtitle: 'On Message Received',
|
|
440
|
+
description: 'Trigger workflow when WhatsApp message is received. Outputs message data including sender, content, and metadata.',
|
|
441
|
+
defaults: { name: 'WhatsApp Receive', color: '#075E54' },
|
|
442
|
+
inputs: [],
|
|
443
|
+
outputs: [{
|
|
444
|
+
name: 'main',
|
|
445
|
+
displayName: 'Message',
|
|
446
|
+
type: 'main' as NodeConnectionType,
|
|
447
|
+
description: 'Received message data (message_id, sender, sender_phone, chat_id, message_type, text, timestamp, is_group, is_from_me, group_info.sender_jid, group_info.sender_phone, group_info.sender_name)'
|
|
448
|
+
}],
|
|
449
|
+
properties: [
|
|
450
|
+
// ===== MESSAGE TYPE FILTER =====
|
|
451
|
+
{
|
|
452
|
+
displayName: 'Message Type',
|
|
453
|
+
name: 'messageTypeFilter',
|
|
454
|
+
type: 'options',
|
|
455
|
+
options: [
|
|
456
|
+
{ name: 'All Types', value: 'all' },
|
|
457
|
+
{ name: 'Text Only', value: 'text' },
|
|
458
|
+
{ name: 'Image Only', value: 'image' },
|
|
459
|
+
{ name: 'Video Only', value: 'video' },
|
|
460
|
+
{ name: 'Audio Only', value: 'audio' },
|
|
461
|
+
{ name: 'Document Only', value: 'document' },
|
|
462
|
+
{ name: 'Location Only', value: 'location' },
|
|
463
|
+
{ name: 'Contact Only', value: 'contact' }
|
|
464
|
+
],
|
|
465
|
+
default: 'all',
|
|
466
|
+
description: 'Filter by message content type'
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
// ===== SENDER FILTER =====
|
|
470
|
+
{
|
|
471
|
+
displayName: 'Sender Filter',
|
|
472
|
+
name: 'filter',
|
|
473
|
+
type: 'options',
|
|
474
|
+
options: [
|
|
475
|
+
{ name: 'All Messages', value: 'all' },
|
|
476
|
+
{ name: 'From Any Contact (Non-Group)', value: 'any_contact' },
|
|
477
|
+
{ name: 'From Specific Contact', value: 'contact' },
|
|
478
|
+
{ name: 'From Specific Group', value: 'group' },
|
|
479
|
+
{ name: 'Contains Keywords', value: 'keywords' }
|
|
480
|
+
],
|
|
481
|
+
default: 'all',
|
|
482
|
+
description: 'Filter which messages trigger the workflow'
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
displayName: 'Contact Phone',
|
|
486
|
+
name: 'contactPhone',
|
|
487
|
+
type: 'string',
|
|
488
|
+
default: '',
|
|
489
|
+
required: true,
|
|
490
|
+
displayOptions: {
|
|
491
|
+
show: { filter: ['contact'] }
|
|
492
|
+
},
|
|
493
|
+
placeholder: '1234567890',
|
|
494
|
+
description: 'Phone number to filter messages from (without + prefix)'
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
displayName: 'Group',
|
|
498
|
+
name: 'group_id',
|
|
499
|
+
type: 'string',
|
|
500
|
+
default: '',
|
|
501
|
+
required: true,
|
|
502
|
+
displayOptions: {
|
|
503
|
+
show: { filter: ['group'] }
|
|
504
|
+
},
|
|
505
|
+
placeholder: '123456789@g.us',
|
|
506
|
+
description: 'Group JID to filter messages from (use Load button to select)'
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
displayName: 'Sender Number',
|
|
510
|
+
name: 'senderNumber',
|
|
511
|
+
type: 'string',
|
|
512
|
+
default: '',
|
|
513
|
+
displayOptions: {
|
|
514
|
+
show: { filter: ['group'] }
|
|
515
|
+
},
|
|
516
|
+
placeholder: '1234567890',
|
|
517
|
+
description: 'Optional: Filter by sender phone number (use Load button to select from group members)'
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
displayName: 'Keywords',
|
|
521
|
+
name: 'keywords',
|
|
522
|
+
type: 'string',
|
|
523
|
+
default: '',
|
|
524
|
+
required: true,
|
|
525
|
+
displayOptions: {
|
|
526
|
+
show: { filter: ['keywords'] }
|
|
527
|
+
},
|
|
528
|
+
placeholder: 'help, support, info',
|
|
529
|
+
description: 'Comma-separated keywords to trigger on (case-insensitive)'
|
|
530
|
+
},
|
|
531
|
+
|
|
532
|
+
// ===== OPTIONS =====
|
|
533
|
+
{
|
|
534
|
+
displayName: 'Ignore Own Messages',
|
|
535
|
+
name: 'ignoreOwnMessages',
|
|
536
|
+
type: 'boolean',
|
|
537
|
+
default: true,
|
|
538
|
+
description: 'Do not trigger on messages sent by this device'
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
displayName: 'Forwarded Messages',
|
|
542
|
+
name: 'forwardedFilter',
|
|
543
|
+
type: 'options',
|
|
544
|
+
options: [
|
|
545
|
+
{ name: 'Include All', value: 'all' },
|
|
546
|
+
{ name: 'Only Forwarded', value: 'only_forwarded' },
|
|
547
|
+
{ name: 'Ignore Forwarded', value: 'ignore_forwarded' }
|
|
548
|
+
],
|
|
549
|
+
default: 'all',
|
|
550
|
+
description: 'Filter messages based on forwarded status'
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
displayName: 'Include Media Data',
|
|
554
|
+
name: 'includeMediaData',
|
|
555
|
+
type: 'boolean',
|
|
556
|
+
default: false,
|
|
557
|
+
description: 'Include base64 media data in output (increases memory usage)'
|
|
558
|
+
}
|
|
559
|
+
],
|
|
560
|
+
methods: {
|
|
561
|
+
loadOptions: {
|
|
562
|
+
async getWhatsAppGroups(): Promise<Array<{name: string, value: string, description?: string}>> {
|
|
563
|
+
try {
|
|
564
|
+
const response = await wsRequest('whatsapp_groups') as { success: boolean; groups?: Array<{ jid: string; name: string; participant_count?: number; is_community?: boolean }> };
|
|
565
|
+
|
|
566
|
+
if (response.success && response.groups) {
|
|
567
|
+
// Filter out communities - they don't have regular chat history
|
|
568
|
+
const regularGroups = response.groups.filter((group) => !group.is_community);
|
|
569
|
+
if (regularGroups.length === 0) {
|
|
570
|
+
return [{ name: 'No groups found', value: '', description: 'Only communities found (no chat history)' }];
|
|
571
|
+
}
|
|
572
|
+
return regularGroups.map((group) => ({
|
|
573
|
+
name: group.name || group.jid,
|
|
574
|
+
value: group.jid,
|
|
575
|
+
description: group.participant_count ? `${group.participant_count} members` : undefined
|
|
576
|
+
}));
|
|
577
|
+
}
|
|
578
|
+
return [{ name: 'No groups found', value: '', description: 'Connect WhatsApp first' }];
|
|
579
|
+
} catch (error) {
|
|
580
|
+
console.error('Error loading WhatsApp groups:', error);
|
|
581
|
+
return [{ name: 'Error loading groups', value: '', description: 'Check WhatsApp connection' }];
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
|
|
585
|
+
async getGroupMembers(this: { getCurrentNodeParameter: (name: string) => string }): Promise<Array<{name: string, value: string, description?: string}>> {
|
|
586
|
+
try {
|
|
587
|
+
const groupId = this.getCurrentNodeParameter('group_id');
|
|
588
|
+
if (!groupId) {
|
|
589
|
+
return [{ name: 'Select a group first', value: '', description: 'Choose a group above' }];
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const response = await wsRequest('whatsapp_group_info', { group_id: groupId }) as {
|
|
593
|
+
success: boolean;
|
|
594
|
+
participants?: Array<{ phone: string; name: string; jid: string; is_admin?: boolean }>;
|
|
595
|
+
name?: string;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
if (response.success && response.participants && response.participants.length > 0) {
|
|
599
|
+
// Add "All Members" option first
|
|
600
|
+
const options: Array<{name: string, value: string, description?: string}> = [
|
|
601
|
+
{ name: 'All Members', value: '', description: 'Receive from anyone in group' }
|
|
602
|
+
];
|
|
603
|
+
|
|
604
|
+
// Add each participant
|
|
605
|
+
for (const p of response.participants) {
|
|
606
|
+
const displayName = p.name || p.phone;
|
|
607
|
+
const adminLabel = p.is_admin ? ' (Admin)' : '';
|
|
608
|
+
options.push({
|
|
609
|
+
name: `${displayName}${adminLabel}`,
|
|
610
|
+
value: p.phone,
|
|
611
|
+
description: p.phone
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return options;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
return [{ name: 'No members found', value: '', description: 'Could not load group members' }];
|
|
619
|
+
} catch (error) {
|
|
620
|
+
console.error('Error loading group members:', error);
|
|
621
|
+
return [{ name: 'Error loading members', value: '', description: 'Check WhatsApp connection' }];
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
|
|
628
|
+
// WhatsApp DB Node - Query contacts, groups, messages
|
|
629
|
+
// Can be used as workflow node OR as AI Agent tool (group includes 'tool')
|
|
630
|
+
whatsappDb: {
|
|
631
|
+
displayName: 'WhatsApp DB',
|
|
632
|
+
name: 'whatsappDb',
|
|
633
|
+
icon: WHATSAPP_DB_ICON,
|
|
634
|
+
group: ['whatsapp', 'tool'],
|
|
635
|
+
version: 1,
|
|
636
|
+
subtitle: 'Query WhatsApp',
|
|
637
|
+
description: 'Query WhatsApp database - contacts, groups, messages, contact info',
|
|
638
|
+
defaults: { name: 'WhatsApp DB', color: '#25D366' },
|
|
639
|
+
inputs: [{
|
|
640
|
+
name: 'main',
|
|
641
|
+
displayName: 'Input',
|
|
642
|
+
type: 'main' as NodeConnectionType,
|
|
643
|
+
description: 'Trigger input'
|
|
644
|
+
}],
|
|
645
|
+
outputs: [
|
|
646
|
+
{
|
|
647
|
+
name: 'main',
|
|
648
|
+
displayName: 'Output',
|
|
649
|
+
type: 'main' as NodeConnectionType,
|
|
650
|
+
description: 'Query result'
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: 'tool',
|
|
654
|
+
displayName: 'Tool',
|
|
655
|
+
type: 'main' as NodeConnectionType,
|
|
656
|
+
description: 'Connect to AI Agent tool handle'
|
|
657
|
+
}
|
|
658
|
+
],
|
|
659
|
+
properties: [
|
|
660
|
+
// ===== OPERATION SELECTOR =====
|
|
661
|
+
{
|
|
662
|
+
displayName: 'Operation',
|
|
663
|
+
name: 'operation',
|
|
664
|
+
type: 'options',
|
|
665
|
+
options: [
|
|
666
|
+
{ name: 'Chat History', value: 'chat_history' },
|
|
667
|
+
{ name: 'Search Groups', value: 'search_groups' },
|
|
668
|
+
{ name: 'Get Group Info', value: 'get_group_info' },
|
|
669
|
+
{ name: 'Get Contact Info', value: 'get_contact_info' },
|
|
670
|
+
{ name: 'List Contacts', value: 'list_contacts' },
|
|
671
|
+
{ name: 'Check Contacts', value: 'check_contacts' }
|
|
672
|
+
],
|
|
673
|
+
default: 'chat_history',
|
|
674
|
+
description: 'Operation to perform'
|
|
675
|
+
},
|
|
676
|
+
|
|
677
|
+
// ===== CHAT HISTORY PARAMETERS =====
|
|
678
|
+
{
|
|
679
|
+
displayName: 'Chat Type',
|
|
680
|
+
name: 'chat_type',
|
|
681
|
+
type: 'options',
|
|
682
|
+
options: [
|
|
683
|
+
{ name: 'Individual Chat', value: 'individual' },
|
|
684
|
+
{ name: 'Group Chat', value: 'group' }
|
|
685
|
+
],
|
|
686
|
+
default: 'individual',
|
|
687
|
+
description: 'Type of chat to retrieve history from',
|
|
688
|
+
displayOptions: {
|
|
689
|
+
show: { operation: ['chat_history'] }
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
displayName: 'Phone Number',
|
|
694
|
+
name: 'phone',
|
|
695
|
+
type: 'string',
|
|
696
|
+
default: '',
|
|
697
|
+
required: true,
|
|
698
|
+
placeholder: '1234567890',
|
|
699
|
+
description: 'Phone number of the contact (without + prefix)',
|
|
700
|
+
displayOptions: {
|
|
701
|
+
show: { operation: ['chat_history'], chat_type: ['individual'] }
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
displayName: 'Group',
|
|
706
|
+
name: 'group_id',
|
|
707
|
+
type: 'string',
|
|
708
|
+
default: '',
|
|
709
|
+
required: true,
|
|
710
|
+
placeholder: '123456789@g.us',
|
|
711
|
+
description: 'Group JID',
|
|
712
|
+
displayOptions: {
|
|
713
|
+
show: { operation: ['chat_history', 'get_group_info'], chat_type: ['group'] }
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
displayName: 'Message Filter',
|
|
718
|
+
name: 'group_filter',
|
|
719
|
+
type: 'options',
|
|
720
|
+
options: [
|
|
721
|
+
{ name: 'All Messages', value: 'all' },
|
|
722
|
+
{ name: 'From Specific Contact', value: 'contact' }
|
|
723
|
+
],
|
|
724
|
+
default: 'all',
|
|
725
|
+
description: 'Filter messages in group',
|
|
726
|
+
displayOptions: {
|
|
727
|
+
show: { operation: ['chat_history'], chat_type: ['group'] }
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
displayName: 'Sender Phone',
|
|
732
|
+
name: 'sender_phone',
|
|
733
|
+
type: 'string',
|
|
734
|
+
default: '',
|
|
735
|
+
placeholder: '1234567890',
|
|
736
|
+
description: 'Filter messages from specific group member',
|
|
737
|
+
displayOptions: {
|
|
738
|
+
show: { operation: ['chat_history'], chat_type: ['group'], group_filter: ['contact'] }
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
displayName: 'Message Type',
|
|
743
|
+
name: 'message_filter',
|
|
744
|
+
type: 'options',
|
|
745
|
+
options: [
|
|
746
|
+
{ name: 'All Types', value: 'all' },
|
|
747
|
+
{ name: 'Text Only', value: 'text_only' }
|
|
748
|
+
],
|
|
749
|
+
default: 'all',
|
|
750
|
+
description: 'Filter by message type',
|
|
751
|
+
displayOptions: {
|
|
752
|
+
show: { operation: ['chat_history'] }
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
displayName: 'Limit',
|
|
757
|
+
name: 'limit',
|
|
758
|
+
type: 'number',
|
|
759
|
+
default: 50,
|
|
760
|
+
typeOptions: { minValue: 1, maxValue: 500 },
|
|
761
|
+
description: 'Maximum number of messages to retrieve (1-500)',
|
|
762
|
+
displayOptions: {
|
|
763
|
+
show: { operation: ['chat_history'] }
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
displayName: 'Offset',
|
|
768
|
+
name: 'offset',
|
|
769
|
+
type: 'number',
|
|
770
|
+
default: 0,
|
|
771
|
+
typeOptions: { minValue: 0 },
|
|
772
|
+
description: 'Number of messages to skip (for pagination)',
|
|
773
|
+
displayOptions: {
|
|
774
|
+
show: { operation: ['chat_history'] }
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
|
|
778
|
+
// ===== SEARCH GROUPS PARAMETERS =====
|
|
779
|
+
{
|
|
780
|
+
displayName: 'Search Query',
|
|
781
|
+
name: 'query',
|
|
782
|
+
type: 'string',
|
|
783
|
+
default: '',
|
|
784
|
+
placeholder: 'Family, Work, etc.',
|
|
785
|
+
description: 'Search groups by name (leave empty for all groups)',
|
|
786
|
+
displayOptions: {
|
|
787
|
+
show: { operation: ['search_groups', 'list_contacts'] }
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
|
|
791
|
+
// ===== GET GROUP INFO PARAMETERS =====
|
|
792
|
+
{
|
|
793
|
+
displayName: 'Group',
|
|
794
|
+
name: 'group_id_for_info',
|
|
795
|
+
type: 'string',
|
|
796
|
+
default: '',
|
|
797
|
+
required: true,
|
|
798
|
+
placeholder: '123456789@g.us',
|
|
799
|
+
description: 'Group JID to get info for',
|
|
800
|
+
displayOptions: {
|
|
801
|
+
show: { operation: ['get_group_info'] }
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
|
|
805
|
+
// ===== GET CONTACT INFO PARAMETERS =====
|
|
806
|
+
{
|
|
807
|
+
displayName: 'Phone Number',
|
|
808
|
+
name: 'contact_phone',
|
|
809
|
+
type: 'string',
|
|
810
|
+
default: '',
|
|
811
|
+
required: true,
|
|
812
|
+
placeholder: '1234567890',
|
|
813
|
+
description: 'Phone number to get contact info for',
|
|
814
|
+
displayOptions: {
|
|
815
|
+
show: { operation: ['get_contact_info'] }
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
|
|
819
|
+
// ===== CHECK CONTACTS PARAMETERS =====
|
|
820
|
+
{
|
|
821
|
+
displayName: 'Phone Numbers',
|
|
822
|
+
name: 'phones',
|
|
823
|
+
type: 'string',
|
|
824
|
+
default: '',
|
|
825
|
+
required: true,
|
|
826
|
+
placeholder: '1234567890, 0987654321',
|
|
827
|
+
description: 'Comma-separated phone numbers to check WhatsApp registration',
|
|
828
|
+
displayOptions: {
|
|
829
|
+
show: { operation: ['check_contacts'] }
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
],
|
|
833
|
+
methods: {
|
|
834
|
+
loadOptions: {
|
|
835
|
+
async getWhatsAppGroups(): Promise<Array<{name: string, value: string, description?: string}>> {
|
|
836
|
+
try {
|
|
837
|
+
const response = await wsRequest('whatsapp_groups') as { success: boolean; groups?: Array<{ jid: string; name: string; participant_count?: number; is_community?: boolean }> };
|
|
838
|
+
|
|
839
|
+
if (response.success && response.groups) {
|
|
840
|
+
const regularGroups = response.groups.filter((group) => !group.is_community);
|
|
841
|
+
if (regularGroups.length === 0) {
|
|
842
|
+
return [{ name: 'No groups found', value: '', description: 'Only communities found' }];
|
|
843
|
+
}
|
|
844
|
+
return regularGroups.map((group) => ({
|
|
845
|
+
name: group.name || group.jid,
|
|
846
|
+
value: group.jid,
|
|
847
|
+
description: group.participant_count ? `${group.participant_count} members` : undefined
|
|
848
|
+
}));
|
|
849
|
+
}
|
|
850
|
+
return [{ name: 'No groups found', value: '', description: 'Connect WhatsApp first' }];
|
|
851
|
+
} catch (error) {
|
|
852
|
+
console.error('Error loading WhatsApp groups:', error);
|
|
853
|
+
return [{ name: 'Error loading groups', value: '', description: 'Check WhatsApp connection' }];
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// ============================================================================
|
|
862
|
+
// EXPORTS
|
|
863
|
+
// ============================================================================
|
|
864
|
+
|
|
865
|
+
export const WHATSAPP_NODE_TYPES = ['whatsappSend', 'whatsappConnect', 'whatsappReceive', 'whatsappDb'];
|