UNPKG

n8n-nodes-zuckzapgo

Version:

n8n community nodes for ZuckZapGo - WhatsApp Multi-Device REST API

1,175 lines (1,174 loc) 86.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ZuckZapGoAI = void 0; const GenericFunctions_1 = require("../GenericFunctions"); class ZuckZapGoAI { constructor() { this.description = { displayName: 'ZuckZapGo AI', name: 'zuckzapgoAi', icon: 'file:zuckzapgo.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"]}} message', description: 'Send WhatsApp messages using ZuckZapGo - optimized for AI workflows', defaults: { name: 'ZuckZapGo AI', }, usableAsTool: true, codex: { categories: ['Communication'], subcategories: { Communication: ['Messaging & Chat'], }, resources: { primaryDocumentation: [ { url: 'https://github.com/guilhermejansen/zuckzapgo', }, ], }, alias: ['WhatsApp', 'messaging', 'chat', 'AI assistant', 'communication', 'business messaging'], }, inputs: ["main" /* NodeConnectionType.Main */], outputs: ["main" /* NodeConnectionType.Main */], credentials: [ { name: 'zuckzapgoApi', required: true, }, ], properties: [ { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, options: [ { name: 'Send Text', value: 'sendText', description: 'Send plain text messages to WhatsApp users, groups, newsletters, or LIDs. Supports forwarding, replies, and mentions.', action: 'Send a text message via whats app', }, { name: 'Send Image', value: 'sendImage', description: 'Send image files (JPEG, PNG, WebP) with optional captions. Supports binary data, Base64, or URL sources with advanced forwarding and reply features.', action: 'Send an image message via whats app', }, { name: 'Send Document', value: 'sendDocument', description: 'Send document files (PDF, DOCX, XLSX, etc.) with custom filenames and captions. Perfect for sharing files and documents in conversations.', action: 'Send a document file via whats app', }, { name: 'Send Audio', value: 'sendAudio', description: 'Send audio messages as voice notes (PTT) or audio files. Supports OGG Opus format with voice note functionality for natural communication.', action: 'Send an audio voice message via whats app', }, { name: 'Send Video', value: 'sendVideo', description: 'Send video files (MP4, AVI, MOV) with captions. Optimized for WhatsApp video compression and playback compatibility.', action: 'Send a video message via whats app', }, { name: 'Send Location', value: 'sendLocation', description: 'Share geographic locations with latitude/longitude coordinates and optional location names. Useful for meeting points and navigation.', action: 'Send location coordinates via whats app', }, { name: 'Send Contact', value: 'sendContact', description: 'Share contact information using vCard format. Send business cards and contact details seamlessly in conversations.', action: 'Send contact v card via whats app', }, { name: 'Send Sticker', value: 'sendSticker', description: 'Send animated or static stickers in WebP format. Add personality and emotion to conversations with custom stickers.', action: 'Send a sticker via whats app', }, { name: 'Send Buttons', value: 'sendButtons', description: 'Create interactive messages with clickable buttons for user engagement. Perfect for quick responses and menu selections.', action: 'Send interactive buttons via whats app', }, { name: 'Send List', value: 'sendList', description: 'Create structured list messages with multiple selectable options. Ideal for menus, catalogs, and organized choices.', action: 'Send interactive list via whats app', }, { name: 'Send Poll', value: 'sendPoll', description: 'Create polls with multiple choice options for group voting and feedback collection. Great for decision making and surveys.', action: 'Send a poll via whats app', }, { name: 'Send Link', value: 'sendLink', description: 'Send link messages with automatic preview generation. Share URLs with rich previews and optional captions for better engagement.', action: 'Send a link message with preview via whats app', }, { name: 'Send Status', value: 'sendStatus', description: 'Broadcast status updates (text, image, video, audio) visible to your contacts for 24 hours. Share moments and updates.', action: 'Send whats app status update', }, { name: 'Get Status', value: 'getStatus', description: 'Retrieve current WhatsApp session connection status and health information. Monitor connection state and session validity.', action: 'Get whats app session status', }, { name: 'Check User', value: 'checkUser', description: 'Verify if phone numbers have active WhatsApp accounts. Validate recipients before sending messages to prevent errors.', action: 'Verify whats app account existence', }, { name: 'Get Avatar', value: 'getAvatar', description: 'Download profile pictures from users, groups, newsletters, or LIDs. Retrieve avatars in preview or full quality for analysis.', action: 'Download whats app profile picture', }, { name: 'List Groups', value: 'listGroups', description: 'Retrieve comprehensive list of WhatsApp groups with metadata including names, descriptions, participant counts, and admin status', action: 'List all whats app groups', }, { name: 'List Newsletters', value: 'listNewsletters', description: 'Get complete list of subscribed newsletters/channels with details like names, descriptions, subscriber counts, and activity status', action: 'List subscribed newsletters channels', }, { name: 'Get User Info', value: 'getUserInfo', description: 'Fetch detailed user information including presence status, profile data, last seen, and verification status for contacts', action: 'Get detailed user information', }, { name: 'Get Business Profile', value: 'getBusinessProfile', description: 'Get complete business profile information including business hours, categories, and contact details', action: 'Get business profile information', }, { name: 'Get My Status', value: 'getMyStatus', description: 'Get current user status message and status settings', action: 'Get my status message', }, ], default: 'sendText', }, // Phone Number / Recipient { displayName: 'Recipient', name: 'phoneNumber', type: 'string', default: '', placeholder: '5491155553934 or 120363312246943103@g.us or 120363025246943103@newsletter or user@lid', description: 'Phone number, Group ID (@g.us), Newsletter ID (@newsletter), or LID (@lid)', required: true, displayOptions: { show: { operation: [ 'sendText', 'sendImage', 'sendDocument', 'sendAudio', 'sendVideo', 'sendLocation', 'sendContact', 'sendSticker', 'sendButtons', 'sendList', 'sendPoll', 'sendLink' ], }, }, }, // User Phone for info operations { displayName: 'Phone Number', name: 'userPhone', type: 'string', default: '', placeholder: '5491155553934', description: 'Phone number in international format (without +)', required: true, displayOptions: { show: { operation: ['getUserInfo', 'checkUser'], }, }, }, // Business Profile Phone { displayName: 'Phone Number', name: 'businessPhoneNumber', type: 'string', default: '', placeholder: '5491155553934', description: 'Phone number of the business account to get profile for', required: true, displayOptions: { show: { operation: ['getBusinessProfile'], }, }, }, // Avatar target (supports users, groups, newsletters, LIDs) { displayName: 'Target', name: 'avatarTarget', type: 'string', default: '', placeholder: '5491155553934 or 120363312246943103@g.us or 120363025246943103@newsletter or user@lid', description: 'Phone number, Group ID (@g.us), Newsletter ID (@newsletter), or LID (@lid) to get avatar from (uses universal /user/avatar endpoint)', required: true, displayOptions: { show: { operation: ['getAvatar'], }, }, }, // List Groups Options { displayName: 'Ignore Participants', name: 'ignoreParticipants', type: 'boolean', default: false, description: 'Whether to ignore participant details for better performance (groups will still be listed but without participant information)', displayOptions: { show: { operation: ['listGroups'], }, }, }, // Status message fields { displayName: 'Status Type', name: 'statusType', type: 'options', default: 'text', options: [ { name: 'Text', value: 'text', description: 'Send a text status', }, { name: 'Image', value: 'image', description: 'Send an image status', }, { name: 'Video', value: 'video', description: 'Send a video status', }, { name: 'Audio', value: 'audio', description: 'Send an audio status', }, ], displayOptions: { show: { operation: ['sendStatus'], }, }, }, { displayName: 'Status Text', name: 'statusText', type: 'string', default: '', placeholder: 'Your status message', description: 'The text content for the status', required: true, displayOptions: { show: { operation: ['sendStatus'], statusType: ['text'], }, }, }, { displayName: 'Background Color', name: 'backgroundColor', type: 'color', default: '', placeholder: '4294967295', description: 'Background color in ARGB decimal format (optional)', displayOptions: { show: { operation: ['sendStatus'], statusType: ['text'], }, }, }, { displayName: 'Text Color', name: 'textColor', type: 'color', default: '', placeholder: '4278190080', description: 'Text color in ARGB decimal format (optional)', displayOptions: { show: { operation: ['sendStatus'], statusType: ['text'], }, }, }, { displayName: 'Font', name: 'font', type: 'number', default: 0, typeOptions: { minValue: 0, maxValue: 10, }, description: 'Font type (0-10)', displayOptions: { show: { operation: ['sendStatus'], statusType: ['text'], }, }, }, // Status Media Source { displayName: 'Media Source', name: 'statusMediaSource', type: 'options', default: 'binary', options: [ { name: 'Binary Data', value: 'binary', description: 'Use binary data from previous node', }, { name: 'Base64', value: 'base64', description: 'Provide base64 encoded media', }, { name: 'URL', value: 'url', description: 'Provide URL to media file', }, ], displayOptions: { show: { operation: ['sendStatus'], statusType: ['image', 'video', 'audio'], }, }, }, { displayName: 'Binary Property', name: 'statusBinaryProperty', type: 'string', default: 'data', description: 'Name of the binary property containing the media', displayOptions: { show: { operation: ['sendStatus'], statusType: ['image', 'video', 'audio'], statusMediaSource: ['binary'], }, }, }, { displayName: 'Base64 Media', name: 'statusBase64', type: 'string', default: '', placeholder: 'data:image/jpeg;base64,iVBORw0... or data:audio/ogg;base64,T2dnU...', description: 'Base64 encoded media with data URL prefix', required: true, displayOptions: { show: { operation: ['sendStatus'], statusType: ['image', 'video', 'audio'], statusMediaSource: ['base64'], }, }, }, { displayName: 'Media URL', name: 'statusUrl', type: 'string', default: '', placeholder: 'https://example.com/media.jpg or https://example.com/audio.ogg', description: 'URL to the media file', required: true, displayOptions: { show: { operation: ['sendStatus'], statusType: ['image', 'video', 'audio'], statusMediaSource: ['url'], }, }, }, { displayName: 'Voice Note (PTT)', name: 'statusPTT', type: 'boolean', default: true, description: 'Whether to send as voice note (PTT) or audio file', displayOptions: { show: { operation: ['sendStatus'], statusType: ['audio'], }, }, }, { displayName: 'Status Caption', name: 'statusCaption', type: 'string', default: '', placeholder: 'Caption for your status', description: 'Caption text for image/video/audio status', displayOptions: { show: { operation: ['sendStatus'], statusType: ['image', 'video', 'audio'], }, }, }, // Avatar options { displayName: 'Preview', name: 'preview', type: 'boolean', default: true, description: 'Whether to get thumbnail (true) or full picture (false)', displayOptions: { show: { operation: ['getAvatar'], }, }, }, { displayName: 'Save as Binary', name: 'saveAsBinary', type: 'boolean', default: false, description: 'Whether to save the avatar as binary data', displayOptions: { show: { operation: ['getAvatar'], }, }, }, { displayName: 'Binary Property Name', name: 'binaryPropertyName', type: 'string', default: 'avatar', description: 'Name of the binary property to store the avatar', displayOptions: { show: { operation: ['getAvatar'], saveAsBinary: [true], }, }, }, // Text Message { displayName: 'Message', name: 'message', type: 'string', displayOptions: { show: { operation: ['sendText', 'sendButtons'], }, }, default: '', description: 'The text message to send', required: true, }, // Image fields - complete implementation { displayName: 'Image Source', name: 'imageSource', type: 'options', default: 'url', options: [ { name: 'Binary Data', value: 'binary', description: 'Use binary data from previous node', }, { name: 'Base64', value: 'base64', description: 'Provide base64 encoded image', }, { name: 'URL', value: 'url', description: 'Provide URL to image file', }, ], displayOptions: { show: { operation: ['sendImage'], }, }, }, { displayName: 'Binary Property', name: 'imageBinaryProperty', type: 'string', default: 'data', description: 'Name of the binary property containing the image', displayOptions: { show: { operation: ['sendImage'], imageSource: ['binary'], }, }, }, { displayName: 'Base64 Image', name: 'imageBase64', type: 'string', default: '', placeholder: 'data:image/jpeg;base64,iVBORw0...', description: 'Base64 encoded image with data URL prefix', displayOptions: { show: { operation: ['sendImage'], imageSource: ['base64'], }, }, required: true, }, { displayName: 'Image URL', name: 'imageUrl', type: 'string', default: '', placeholder: 'https://example.com/image.jpg', description: 'URL to the image file', displayOptions: { show: { operation: ['sendImage'], imageSource: ['url'], }, }, required: true, }, // Video fields - complete implementation { displayName: 'Video Source', name: 'videoSource', type: 'options', default: 'url', options: [ { name: 'Binary Data', value: 'binary', description: 'Use binary data from previous node', }, { name: 'Base64', value: 'base64', description: 'Provide base64 encoded video', }, { name: 'URL', value: 'url', description: 'Provide URL to video file', }, ], displayOptions: { show: { operation: ['sendVideo'], }, }, }, { displayName: 'Binary Property', name: 'videoBinaryProperty', type: 'string', default: 'data', description: 'Name of the binary property containing the video', displayOptions: { show: { operation: ['sendVideo'], videoSource: ['binary'], }, }, }, { displayName: 'Base64 Video', name: 'videoBase64', type: 'string', default: '', placeholder: 'data:video/mp4;base64,iVBORw0...', description: 'Base64 encoded video (H.264 codec, AAC audio)', displayOptions: { show: { operation: ['sendVideo'], videoSource: ['base64'], }, }, required: true, }, { displayName: 'Video URL', name: 'videoUrl', type: 'string', default: '', placeholder: 'https://example.com/video.mp4', description: 'URL to the video file', displayOptions: { show: { operation: ['sendVideo'], videoSource: ['url'], }, }, required: true, }, // Document fields - complete implementation { displayName: 'Document Source', name: 'documentSource', type: 'options', default: 'url', options: [ { name: 'Binary Data', value: 'binary', description: 'Use binary data from previous node', }, { name: 'Base64', value: 'base64', description: 'Provide base64 encoded document', }, { name: 'URL', value: 'url', description: 'Provide URL to document file', }, ], displayOptions: { show: { operation: ['sendDocument'], }, }, }, { displayName: 'Binary Property', name: 'documentBinaryProperty', type: 'string', default: 'data', description: 'Name of the binary property containing the document', displayOptions: { show: { operation: ['sendDocument'], documentSource: ['binary'], }, }, }, { displayName: 'Base64 Document', name: 'documentBase64', type: 'string', default: '', placeholder: 'data:application/pdf;base64,iVBORw0...', description: 'Base64 encoded document', displayOptions: { show: { operation: ['sendDocument'], documentSource: ['base64'], }, }, required: true, }, { displayName: 'Document URL', name: 'documentUrl', type: 'string', default: '', placeholder: 'https://example.com/document.pdf', description: 'URL to the document file', displayOptions: { show: { operation: ['sendDocument'], documentSource: ['url'], }, }, required: true, }, { displayName: 'File Name', name: 'fileName', type: 'string', displayOptions: { show: { operation: ['sendDocument'], }, }, default: '', placeholder: 'document.pdf', description: 'Name of the document file', required: true, }, // Audio fields - complete implementation { displayName: 'Audio Source', name: 'audioSource', type: 'options', default: 'url', options: [ { name: 'Binary Data', value: 'binary', description: 'Use binary data from previous node', }, { name: 'Base64', value: 'base64', description: 'Provide base64 encoded audio', }, { name: 'URL', value: 'url', description: 'Provide URL to audio file', }, ], displayOptions: { show: { operation: ['sendAudio'], }, }, }, { displayName: 'Binary Property', name: 'audioBinaryProperty', type: 'string', default: 'data', description: 'Name of the binary property containing the audio', displayOptions: { show: { operation: ['sendAudio'], audioSource: ['binary'], }, }, }, { displayName: 'Base64 Audio', name: 'audioBase64', type: 'string', default: '', placeholder: 'data:audio/ogg;base64,iVBORw0...', description: 'Base64 encoded audio in opus format', displayOptions: { show: { operation: ['sendAudio'], audioSource: ['base64'], }, }, required: true, }, { displayName: 'Audio URL', name: 'audioUrl', type: 'string', default: '', placeholder: 'https://example.com/audio.ogg', description: 'URL to the audio file', displayOptions: { show: { operation: ['sendAudio'], audioSource: ['url'], }, }, required: true, }, { displayName: 'Voice Note (PTT)', name: 'ptt', type: 'boolean', default: true, description: 'Whether to send as voice note (PTT) or audio file', displayOptions: { show: { operation: ['sendAudio'], }, }, }, // Sticker fields - complete implementation { displayName: 'Sticker Source', name: 'stickerSource', type: 'options', default: 'url', options: [ { name: 'Binary Data', value: 'binary', description: 'Use binary data from previous node', }, { name: 'Base64', value: 'base64', description: 'Provide base64 encoded sticker', }, { name: 'URL', value: 'url', description: 'Provide URL to sticker file', }, ], displayOptions: { show: { operation: ['sendSticker'], }, }, }, { displayName: 'Binary Property', name: 'stickerBinaryProperty', type: 'string', default: 'data', description: 'Name of the binary property containing the sticker', displayOptions: { show: { operation: ['sendSticker'], stickerSource: ['binary'], }, }, }, { displayName: 'Base64 Sticker', name: 'stickerBase64', type: 'string', default: '', placeholder: 'data:image/webp;base64,iVBORw0...', description: 'Base64 encoded sticker in WebP format', displayOptions: { show: { operation: ['sendSticker'], stickerSource: ['base64'], }, }, required: true, }, { displayName: 'Sticker URL', name: 'stickerUrl', type: 'string', default: '', placeholder: 'https://example.com/sticker.webp', description: 'URL to the sticker file', displayOptions: { show: { operation: ['sendSticker'], stickerSource: ['url'], }, }, required: true, }, // Caption for media { displayName: 'Caption', name: 'caption', type: 'string', displayOptions: { show: { operation: ['sendImage', 'sendDocument', 'sendVideo'], }, }, default: '', description: 'Caption for the media file', }, // Location fields { displayName: 'Latitude', name: 'latitude', type: 'number', displayOptions: { show: { operation: ['sendLocation'], }, }, default: 0, description: 'Latitude coordinate', required: true, }, { displayName: 'Longitude', name: 'longitude', type: 'number', displayOptions: { show: { operation: ['sendLocation'], }, }, default: 0, description: 'Longitude coordinate', required: true, }, { displayName: 'Location Name', name: 'locationName', type: 'string', displayOptions: { show: { operation: ['sendLocation'], }, }, default: '', description: 'Name of the location', }, // Contact fields { displayName: 'Contact Name', name: 'contactName', type: 'string', displayOptions: { show: { operation: ['sendContact'], }, }, default: '', description: 'Name of the contact', required: true, }, { displayName: 'VCard', name: 'vcard', type: 'string', displayOptions: { show: { operation: ['sendContact'], }, }, default: '', placeholder: 'BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+1234567890\nEND:VCARD', description: 'VCard data for the contact', required: true, }, // List fields { displayName: 'Button Text', name: 'buttonText', type: 'string', default: '', placeholder: 'Click here', description: 'Text for the list button', required: true, displayOptions: { show: { operation: ['sendList'], }, }, }, { displayName: 'Description', name: 'description', type: 'string', default: '', placeholder: 'Choose an option', description: 'Description of the list', required: true, displayOptions: { show: { operation: ['sendList'], }, }, }, { displayName: 'Top Text', name: 'topText', type: 'string', default: '', placeholder: 'Header text', description: 'Text to show above the list', required: true, displayOptions: { show: { operation: ['sendList'], }, }, }, { displayName: 'Footer Text', name: 'footerText', type: 'string', default: '', placeholder: 'Footer text', description: 'Text to show below the list', displayOptions: { show: { operation: ['sendList'], }, }, }, { displayName: 'List Items', name: 'listItems', type: 'fixedCollection', typeOptions: { multipleValues: true, }, default: {}, description: 'Items in the list', required: true, displayOptions: { show: { operation: ['sendList'], }, }, options: [ { name: 'item', displayName: 'Item', values: [ { displayName: 'Title', name: 'title', type: 'string', default: '', description: 'Title of the list item', required: true, }, { displayName: 'Description', name: 'desc', type: 'string', default: '', description: 'Description of the list item', }, { displayName: 'Row ID', name: 'rowId', type: 'string', default: '', description: 'Unique identifier for the row', required: true, }, ], }, ], }, // Poll fields { displayName: 'Poll Question', name: 'pollHeader', type: 'string', default: '', placeholder: "What's your favorite color?", required: true, displayOptions: { show: { operation: ['sendPoll'], }, }, }, { displayName: 'Poll Options', name: 'pollOptions', type: 'string', default: '', placeholder: 'Red,Blue,Green,Yellow', description: 'Comma-separated list of poll options', required: true, displayOptions: { show: { operation: ['sendPoll'], }, }, }, // Link fields { displayName: 'Link URL', name: 'linkUrl', type: 'string', default: '', placeholder: 'https://example.com', description: 'URL to share (automatically adds https:// if missing)', required: true, displayOptions: { show: { operation: ['sendLink'], }, }, }, { displayName: 'Link Caption', name: 'linkCaption', type: 'string', default: '', placeholder: 'Check out this amazing website!', description: 'Caption for the link message', displayOptions: { show: { operation: ['sendLink'], }, }, }, // Additional Options for all message types { displayName: 'Additional Options', name: 'additionalOptions', type: 'collection', placeholder: 'Add Option', default: {}, displayOptions: { show: { operation: [ 'sendText', 'sendImage', 'sendDocument', 'sendAudio', 'sendVideo', 'sendLocation', 'sendContact', 'sendSticker', 'sendButtons', 'sendList', 'sendPoll', 'sendLink' ], }, }, options: [ { displayName: 'Message ID', name: 'id', type: 'string', default: '', description: 'Custom message ID (auto-generated if not provided)', }, { displayName: 'Presence Simulation', name: 'presence', type: 'number', default: 0, typeOptions: { minValue: 0, maxValue: 30000, }, description: 'Simulate typing/recording for specified milliseconds (0-30000ms). Shows typing indicator for text/documents, recording for audio/video.', }, { displayName: 'Message Duration', name: 'duration', type: 'options', default: 0, options: [ { name: 'No Expiration', value: 0, description: 'Message will not disappear', }, { name: '24 Hours', value: 86400,