Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"extends": [
|
||||
"../../../../.eslintrc.base.json"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"!**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts",
|
||||
"*.tsx",
|
||||
"*.js",
|
||||
"*.jsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.ts",
|
||||
"*.tsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.js",
|
||||
"*.jsx"
|
||||
],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# pieces-whatsapp
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Building
|
||||
|
||||
Run `nx build pieces-whatsapp` to build the library.
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "@activepieces/piece-whatsapp",
|
||||
"version": "0.1.6"
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "pieces-whatsapp",
|
||||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "packages/pieces/community/whatsapp/src",
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"outputs": [
|
||||
"{options.outputPath}"
|
||||
],
|
||||
"options": {
|
||||
"outputPath": "dist/packages/pieces/community/whatsapp",
|
||||
"tsConfig": "packages/pieces/community/whatsapp/tsconfig.lib.json",
|
||||
"packageJson": "packages/pieces/community/whatsapp/package.json",
|
||||
"main": "packages/pieces/community/whatsapp/src/index.ts",
|
||||
"assets": [
|
||||
"packages/pieces/community/whatsapp/*.md",
|
||||
{
|
||||
"input": "packages/pieces/community/whatsapp/src/i18n",
|
||||
"output": "./src/i18n",
|
||||
"glob": "**/!(i18n.json)"
|
||||
}
|
||||
],
|
||||
"buildableProjectDepsInPackageJsonType": "dependencies",
|
||||
"updateBuildableProjectDepsInPackageJson": true
|
||||
},
|
||||
"dependsOn": [
|
||||
"^build",
|
||||
"prebuild"
|
||||
]
|
||||
},
|
||||
"publish": {
|
||||
"command": "node tools/scripts/publish.mjs pieces-whatsapp {args.ver} {args.tag}",
|
||||
"dependsOn": [
|
||||
"build"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": [
|
||||
"{options.outputFile}"
|
||||
]
|
||||
},
|
||||
"prebuild": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/pieces/community/whatsapp",
|
||||
"command": "bun install --no-save --silent"
|
||||
},
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"WhatsApp Business": "WhatsApp Business",
|
||||
"Manage your WhatsApp business account": "Manage your WhatsApp business account",
|
||||
"System User Access Token": "System User Access Token",
|
||||
"Business Account ID": "Business Account ID",
|
||||
"The system user access token of your WhatsApp business account.": "The system user access token of your WhatsApp business account.",
|
||||
"The business account ID of your WhatsApp business account.": "The business account ID of your WhatsApp business account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Send Message",
|
||||
"Send Media": "Send Media",
|
||||
"Send Template Message": "Send Template Message",
|
||||
"Send a text message through WhatsApp": "Send a text message through WhatsApp",
|
||||
"Send a media message through WhatsApp": "Send a media message through WhatsApp",
|
||||
"Sends a template message.": "Sends a template message.",
|
||||
"Phone Number ID": "Phone Number ID",
|
||||
"To": "To",
|
||||
"Message": "Message",
|
||||
"Type": "Type",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Caption",
|
||||
"Filename": "Filename",
|
||||
"Message Template ID": "Message Template ID",
|
||||
"Template Fields": "Template Fields",
|
||||
"Phone number ID that will be used to send the message.": "Phone number ID that will be used to send the message.",
|
||||
"The recipient of the message": "The recipient of the message",
|
||||
"The message to send": "The message to send",
|
||||
"The type of media to send": "The type of media to send",
|
||||
"The URL of the media to send": "The URL of the media to send",
|
||||
"A caption for the media": "A caption for the media",
|
||||
"Filename of the document to send": "Filename of the document to send",
|
||||
"Recipient phone number.": "Recipient phone number."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Verwalten Sie Ihr WhatsApp Business-Konto",
|
||||
"System User Access Token": "Systembenutzer-Zugangs-Token",
|
||||
"Business Account ID": "Business-Konto-ID",
|
||||
"The system user access token of your WhatsApp business account.": "Der Systembenutzer-Zugangs-Token Ihres WhatsApp Business-Kontos.",
|
||||
"The business account ID of your WhatsApp business account.": "Die Business-Konto-ID Ihres WhatsApp-Geschäftskontos.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nUm eine Rufnummernnummer und ein Permanent System User Access Token zu erhalten, folgen Sie diesen Schritten:\n. Gehen Sie zu https://developers.facebook. om/\n2. Machen Sie eine neue App, wählen Sie Andere für usecase.\n3. Wählen Sie Unternehmen als den Typ der App.\n4. Neues Produkt -> WhatsApp hinzufügen.\n5. Navigieren Sie zu WhatsApp Einstellungen > API Setup.\n6. Kopieren Sie die Business-Konto-ID.\n7. Melden Sie sich bei Ihrem [Meta Business Manager](https://business.facebook.com/).\n8. Klicken Sie auf Einstellungen.\n9. Erstellen Sie einen neuen Systembenutzer mit Zugriff über die App und kopieren Sie den Zugriffstok. \n",
|
||||
"Send Message": "Nachricht senden",
|
||||
"Send Media": "Medien senden",
|
||||
"Send Template Message": "Vorlagennachricht senden",
|
||||
"Send a text message through WhatsApp": "Senden Sie eine Textnachricht über WhatsApp",
|
||||
"Send a media message through WhatsApp": "Eine Medien-Nachricht über WhatsApp senden",
|
||||
"Sends a template message.": "Sendet eine Vorlagennachricht.",
|
||||
"Phone Number ID": "Telefonnummer ID",
|
||||
"To": "An",
|
||||
"Message": "Nachricht",
|
||||
"Type": "Typ",
|
||||
"Media URL": "Medien-URL",
|
||||
"Caption": "Überschrift",
|
||||
"Filename": "Dateiname",
|
||||
"Message Template ID": "Nachrichtenvorlagen-ID",
|
||||
"Template Fields": "Vorlagenfelder",
|
||||
"Phone number ID that will be used to send the message.": "Telefonnummer ID, die verwendet wird, um die Nachricht zu senden.",
|
||||
"The recipient of the message": "Der Empfänger der Nachricht",
|
||||
"The message to send": "Die Nachricht zum Senden",
|
||||
"The type of media to send": "Die Art der Medien zu senden",
|
||||
"The URL of the media to send": "Die URL der zu sendenden Medien",
|
||||
"A caption for the media": "Eine Überschrift für die Medien",
|
||||
"Filename of the document to send": "Dateiname des zu sendenden Dokuments",
|
||||
"Recipient phone number.": "Empfänger-Telefonnummer."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Administra tu cuenta de negocios de WhatsApp",
|
||||
"System User Access Token": "Token de acceso de usuario del sistema",
|
||||
"Business Account ID": "ID de cuenta comercial",
|
||||
"The system user access token of your WhatsApp business account.": "El token de acceso de usuario del sistema de tu cuenta de negocios de WhatsApp.",
|
||||
"The business account ID of your WhatsApp business account.": "El ID de la cuenta comercial de tu cuenta de negocios de WhatsApp.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Enviar mensaje",
|
||||
"Send Media": "Enviar medios",
|
||||
"Send Template Message": "Enviar mensaje de plantilla",
|
||||
"Send a text message through WhatsApp": "Enviar un mensaje de texto a través de WhatsApp",
|
||||
"Send a media message through WhatsApp": "Enviar un mensaje multimedia a través de WhatsApp",
|
||||
"Sends a template message.": "Envía un mensaje de plantilla.",
|
||||
"Phone Number ID": "ID de número de teléfono",
|
||||
"To": "A",
|
||||
"Message": "Mensaje",
|
||||
"Type": "Tipo",
|
||||
"Media URL": "URL de medios",
|
||||
"Caption": "Leyenda",
|
||||
"Filename": "Nombre de archivo",
|
||||
"Message Template ID": "ID de plantilla de mensaje",
|
||||
"Template Fields": "Campos de plantilla",
|
||||
"Phone number ID that will be used to send the message.": "ID del número de teléfono que se utilizará para enviar el mensaje.",
|
||||
"The recipient of the message": "El destinatario del mensaje",
|
||||
"The message to send": "El mensaje a enviar",
|
||||
"The type of media to send": "El tipo de medio a enviar",
|
||||
"The URL of the media to send": "La URL de los medios a enviar",
|
||||
"A caption for the media": "Un título para los medios",
|
||||
"Filename of the document to send": "Nombre de archivo del documento a enviar",
|
||||
"Recipient phone number.": "Número de teléfono del destinatario."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Gérez votre compte WhatsApp Business",
|
||||
"System User Access Token": "Jeton d'accès utilisateur système",
|
||||
"Business Account ID": "ID du compte professionnel",
|
||||
"The system user access token of your WhatsApp business account.": "Le jeton d'accès utilisateur du système de votre compte WhatsApp.",
|
||||
"The business account ID of your WhatsApp business account.": "L'ID du compte professionnel de votre compte WhatsApp.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Envoyer un message",
|
||||
"Send Media": "Envoyer un média",
|
||||
"Send Template Message": "Envoyer un message de modèle",
|
||||
"Send a text message through WhatsApp": "Envoyer un SMS via WhatsApp",
|
||||
"Send a media message through WhatsApp": "Envoyer un message média via WhatsApp",
|
||||
"Sends a template message.": "Envoie un message de modèle.",
|
||||
"Phone Number ID": "ID du numéro de téléphone",
|
||||
"To": "À",
|
||||
"Message": "Message",
|
||||
"Type": "Type de texte",
|
||||
"Media URL": "URL du média",
|
||||
"Caption": "Légende",
|
||||
"Filename": "Nom du fichier",
|
||||
"Message Template ID": "ID du modèle de message",
|
||||
"Template Fields": "Champs du modèle",
|
||||
"Phone number ID that will be used to send the message.": "ID du numéro de téléphone qui sera utilisé pour envoyer le message.",
|
||||
"The recipient of the message": "Destinataire du message",
|
||||
"The message to send": "Le message à envoyer",
|
||||
"The type of media to send": "Le type de média à envoyer",
|
||||
"The URL of the media to send": "L'URL du média à envoyer",
|
||||
"A caption for the media": "Une légende pour le média",
|
||||
"Filename of the document to send": "Nom du fichier du document à envoyer",
|
||||
"Recipient phone number.": "Numéro de téléphone du destinataire."
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"WhatsApp Business": "WhatsApp Business",
|
||||
"Manage your WhatsApp business account": "Manage your WhatsApp business account",
|
||||
"System User Access Token": "System User Access Token",
|
||||
"Business Account ID": "Business Account ID",
|
||||
"The system user access token of your WhatsApp business account.": "The system user access token of your WhatsApp business account.",
|
||||
"The business account ID of your WhatsApp business account.": "The business account ID of your WhatsApp business account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Send Message",
|
||||
"Send Media": "Send Media",
|
||||
"Send Template Message": "Send Template Message",
|
||||
"Send a text message through WhatsApp": "Send a text message through WhatsApp",
|
||||
"Send a media message through WhatsApp": "Send a media message through WhatsApp",
|
||||
"Sends a template message.": "Sends a template message.",
|
||||
"Phone Number ID": "Phone Number ID",
|
||||
"To": "To",
|
||||
"Message": "Message",
|
||||
"Type": "Type",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Caption",
|
||||
"Filename": "Filename",
|
||||
"Message Template ID": "Message Template ID",
|
||||
"Template Fields": "Template Fields",
|
||||
"Phone number ID that will be used to send the message.": "Phone number ID that will be used to send the message.",
|
||||
"The recipient of the message": "The recipient of the message",
|
||||
"The message to send": "The message to send",
|
||||
"The type of media to send": "The type of media to send",
|
||||
"The URL of the media to send": "The URL of the media to send",
|
||||
"A caption for the media": "A caption for the media",
|
||||
"Filename of the document to send": "Filename of the document to send",
|
||||
"Recipient phone number.": "Recipient phone number."
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"WhatsApp Business": "WhatsApp Business",
|
||||
"Manage your WhatsApp business account": "Manage your WhatsApp business account",
|
||||
"System User Access Token": "System User Access Token",
|
||||
"Business Account ID": "Business Account ID",
|
||||
"The system user access token of your WhatsApp business account.": "The system user access token of your WhatsApp business account.",
|
||||
"The business account ID of your WhatsApp business account.": "The business account ID of your WhatsApp business account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Send Message",
|
||||
"Send Media": "Send Media",
|
||||
"Send Template Message": "Send Template Message",
|
||||
"Send a text message through WhatsApp": "Send a text message through WhatsApp",
|
||||
"Send a media message through WhatsApp": "Send a media message through WhatsApp",
|
||||
"Sends a template message.": "Sends a template message.",
|
||||
"Phone Number ID": "Phone Number ID",
|
||||
"To": "To",
|
||||
"Message": "Message",
|
||||
"Type": "Type",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Caption",
|
||||
"Filename": "Filename",
|
||||
"Message Template ID": "Message Template ID",
|
||||
"Template Fields": "Template Fields",
|
||||
"Phone number ID that will be used to send the message.": "Phone number ID that will be used to send the message.",
|
||||
"The recipient of the message": "The recipient of the message",
|
||||
"The message to send": "The message to send",
|
||||
"The type of media to send": "The type of media to send",
|
||||
"The URL of the media to send": "The URL of the media to send",
|
||||
"A caption for the media": "A caption for the media",
|
||||
"Filename of the document to send": "Filename of the document to send",
|
||||
"Recipient phone number.": "Recipient phone number."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "WhatsAppビジネスアカウントの管理",
|
||||
"System User Access Token": "システムユーザアクセストークン",
|
||||
"Business Account ID": "ビジネスアカウントID",
|
||||
"The system user access token of your WhatsApp business account.": "WhatsAppビジネスアカウントのシステムユーザーアクセストークン。",
|
||||
"The business account ID of your WhatsApp business account.": "WhatsAppビジネスアカウントのビジネスアカウントID。",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "メッセージを送信",
|
||||
"Send Media": "メディアを送信",
|
||||
"Send Template Message": "テンプレートメッセージを送信",
|
||||
"Send a text message through WhatsApp": "WhatsApp経由でテキストメッセージを送信する",
|
||||
"Send a media message through WhatsApp": "WhatsApp経由でメディアメッセージを送信する",
|
||||
"Sends a template message.": "テンプレートメッセージを送信する。",
|
||||
"Phone Number ID": "電話番号ID",
|
||||
"To": "終了日",
|
||||
"Message": "メッセージ",
|
||||
"Type": "タイプ",
|
||||
"Media URL": "メディア URL",
|
||||
"Caption": "図表番号",
|
||||
"Filename": "ファイル名",
|
||||
"Message Template ID": "メッセージテンプレートID",
|
||||
"Template Fields": "テンプレートフィールド",
|
||||
"Phone number ID that will be used to send the message.": "メッセージの送信に使用される電話番号ID。",
|
||||
"The recipient of the message": "メッセージの受信者",
|
||||
"The message to send": "送信するメッセージ",
|
||||
"The type of media to send": "送信するメディアの種類",
|
||||
"The URL of the media to send": "送信するメディアの URL",
|
||||
"A caption for the media": "メディアの説明",
|
||||
"Filename of the document to send": "送信するドキュメントのファイル名",
|
||||
"Recipient phone number.": "受信者の電話番号"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Beheer je WhatsApp business account",
|
||||
"System User Access Token": "Systeem gebruikers toegangstoken",
|
||||
"Business Account ID": "Zakelijk account ID",
|
||||
"The system user access token of your WhatsApp business account.": "De toegangstoken voor de systeemgebruiker van uw WhatsApp-zakelijk account.",
|
||||
"The business account ID of your WhatsApp business account.": "Het bedrijfs-account ID van je WhatsApp-zakelijke account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nOm een Telefoonnummer ID en een permanent systeem toegangstoken voor gebruikers te verkrijgen, volg deze stappen:\n. Ga naar https://developers.facebook.\n2. Maak een nieuwe app, selecteer een andere voor usecase.\n3. Kies Business als type app.\n4. Voeg nieuw Product -> WhatsApp toe.\n5. Navigeer naar WhatsApp Instellingen > API Setup.\n6. Kopieer het Business Account ID.\n7. Log in op uw [Meta Business Manager](https://business.facebook.com/).\n8. Klik op Instellingen.\n9. Maak een nieuwe systeemgebruiker aan met toegang over de app en kopieer het toegangstoken. \n",
|
||||
"Send Message": "Verstuur bericht",
|
||||
"Send Media": "Media versturen",
|
||||
"Send Template Message": "Verstuur sjabloonbericht",
|
||||
"Send a text message through WhatsApp": "Stuur een sms via WhatsApp",
|
||||
"Send a media message through WhatsApp": "Een media-bericht verzenden via WhatsApp",
|
||||
"Sends a template message.": "Stuurt een template bericht.",
|
||||
"Phone Number ID": "Telefoonnummer ID",
|
||||
"To": "tot",
|
||||
"Message": "bericht",
|
||||
"Type": "Type",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Onderschrift",
|
||||
"Filename": "Bestandsnaam",
|
||||
"Message Template ID": "Bericht sjabloon ID",
|
||||
"Template Fields": "Sjabloon velden",
|
||||
"Phone number ID that will be used to send the message.": "Telefoonnummer ID dat zal worden gebruikt om het bericht te verzenden.",
|
||||
"The recipient of the message": "De ontvanger van het bericht",
|
||||
"The message to send": "Het te verzenden bericht",
|
||||
"The type of media to send": "Het te verzenden type media",
|
||||
"The URL of the media to send": "De URL van de te verzenden media",
|
||||
"A caption for the media": "Een onderschrift voor de media",
|
||||
"Filename of the document to send": "Bestandsnaam van het te verzenden document",
|
||||
"Recipient phone number.": "Geadresseerd telefoonnummer"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Gerencie sua conta empresarial do WhatsApp",
|
||||
"System User Access Token": "Token de acesso ao usuário do sistema",
|
||||
"Business Account ID": "ID da Conta Comercial",
|
||||
"The system user access token of your WhatsApp business account.": "O token de acesso do usuário do sistema da sua conta de negócio do WhatsApp.",
|
||||
"The business account ID of your WhatsApp business account.": "O ID da conta empresarial da sua conta empresarial do WhatsApp.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Enviar mensagem",
|
||||
"Send Media": "Enviar Mídia",
|
||||
"Send Template Message": "Enviar Mensagem de Modelo",
|
||||
"Send a text message through WhatsApp": "Envie uma mensagem de texto pelo WhatsApp",
|
||||
"Send a media message through WhatsApp": "Enviar uma mensagem de mídia pelo WhatsApp",
|
||||
"Sends a template message.": "Envia uma mensagem de modelo.",
|
||||
"Phone Number ID": "ID do número de telefone",
|
||||
"To": "Para",
|
||||
"Message": "mensagem",
|
||||
"Type": "tipo",
|
||||
"Media URL": "URL da Mídia",
|
||||
"Caption": "Legenda",
|
||||
"Filename": "Nome",
|
||||
"Message Template ID": "ID do Modelo de Mensagem",
|
||||
"Template Fields": "Campos do Template",
|
||||
"Phone number ID that will be used to send the message.": "ID do número de telefone que será usado para enviar a mensagem.",
|
||||
"The recipient of the message": "O destinatário da mensagem",
|
||||
"The message to send": "A mensagem a enviar",
|
||||
"The type of media to send": "O tipo de mídia a enviar",
|
||||
"The URL of the media to send": "A URL da mídia a ser enviada",
|
||||
"A caption for the media": "Uma legenda para a mídia",
|
||||
"Filename of the document to send": "Nome do arquivo do documento a enviar",
|
||||
"Recipient phone number.": "Número de telefone destinatário."
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"WhatsApp Business": "WhatsApp бизнес",
|
||||
"Manage your WhatsApp business account": "Управление вашим бизнес-аккаунтом WhatsApp",
|
||||
"System User Access Token": "Токен доступа системного пользователя",
|
||||
"Business Account ID": "ID бизнес-счета",
|
||||
"The system user access token of your WhatsApp business account.": "Токен доступа к вашему бизнес-аккаунту WhatsApp.",
|
||||
"The business account ID of your WhatsApp business account.": "ID вашего бизнес-аккаунта WhatsApp.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nДля получения номера телефона и ключа постоянного доступа системного пользователя, выполните следующие шаги:\n. Перейдите на https://developers.facebook. om/\n2. Создайте новое приложение, выберите другое для использования.\n3. Выберите бизнес как тип приложения.\n4. Добавьте новый продукт -> WhatsApp.\n5. Перейдите в Настройки WhatsApp > Настройка API.\n6. Скопируйте ID бизнес-аккаунта.\n7. Войдите в [Meta Business Manager](https://business.facebook.com/).\n8. Нажмите на Настройки.\nСоздайте нового системного пользователя с доступом через приложение и скопируйте маркер доступа. \n",
|
||||
"Send Message": "Отправить сообщение",
|
||||
"Send Media": "Отправить медиа",
|
||||
"Send Template Message": "Отправить шаблон сообщения",
|
||||
"Send a text message through WhatsApp": "Отправить текстовое сообщение через WhatsApp",
|
||||
"Send a media message through WhatsApp": "Отправить медиа сообщение через WhatsApp",
|
||||
"Sends a template message.": "Отправляет шаблон.",
|
||||
"Phone Number ID": "Номер телефона",
|
||||
"To": "Кому",
|
||||
"Message": "Сообщение",
|
||||
"Type": "Тип",
|
||||
"Media URL": "URL-адрес медиа",
|
||||
"Caption": "Подпись",
|
||||
"Filename": "Имя файла",
|
||||
"Message Template ID": "ID шаблона сообщения",
|
||||
"Template Fields": "Поля шаблона",
|
||||
"Phone number ID that will be used to send the message.": "Номер телефона, который будет использоваться для отправки сообщения.",
|
||||
"The recipient of the message": "Получатель сообщения",
|
||||
"The message to send": "Сообщение для отправки",
|
||||
"The type of media to send": "Тип файла для отправки",
|
||||
"The URL of the media to send": "URL-адрес медиа для отправки",
|
||||
"A caption for the media": "Заголовок для медиа",
|
||||
"Filename of the document to send": "Имя файла документа для отправки",
|
||||
"Recipient phone number.": "Номер телефона получателя."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Manage your WhatsApp business account",
|
||||
"System User Access Token": "System User Access Token",
|
||||
"Business Account ID": "Business Account ID",
|
||||
"The system user access token of your WhatsApp business account.": "The system user access token of your WhatsApp business account.",
|
||||
"The business account ID of your WhatsApp business account.": "The business account ID of your WhatsApp business account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Send Message",
|
||||
"Send Media": "Send Media",
|
||||
"Send Template Message": "Send Template Message",
|
||||
"Send a text message through WhatsApp": "Send a text message through WhatsApp",
|
||||
"Send a media message through WhatsApp": "Send a media message through WhatsApp",
|
||||
"Sends a template message.": "Sends a template message.",
|
||||
"Phone Number ID": "Phone Number ID",
|
||||
"To": "To",
|
||||
"Message": "Message",
|
||||
"Type": "Type",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Caption",
|
||||
"Filename": "Filename",
|
||||
"Message Template ID": "Message Template ID",
|
||||
"Template Fields": "Template Fields",
|
||||
"Phone number ID that will be used to send the message.": "Phone number ID that will be used to send the message.",
|
||||
"The recipient of the message": "The recipient of the message",
|
||||
"The message to send": "The message to send",
|
||||
"The type of media to send": "The type of media to send",
|
||||
"The URL of the media to send": "The URL of the media to send",
|
||||
"A caption for the media": "A caption for the media",
|
||||
"Filename of the document to send": "Filename of the document to send",
|
||||
"Recipient phone number.": "Recipient phone number."
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"WhatsApp Business": "WhatsApp Business",
|
||||
"Manage your WhatsApp business account": "Manage your WhatsApp business account",
|
||||
"System User Access Token": "System User Access Token",
|
||||
"Business Account ID": "Business Account ID",
|
||||
"The system user access token of your WhatsApp business account.": "The system user access token of your WhatsApp business account.",
|
||||
"The business account ID of your WhatsApp business account.": "The business account ID of your WhatsApp business account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Send Message",
|
||||
"Send Media": "Send Media",
|
||||
"Send Template Message": "Send Template Message",
|
||||
"Send a text message through WhatsApp": "Send a text message through WhatsApp",
|
||||
"Send a media message through WhatsApp": "Send a media message through WhatsApp",
|
||||
"Sends a template message.": "Sends a template message.",
|
||||
"Phone Number ID": "Phone Number ID",
|
||||
"To": "To",
|
||||
"Message": "Message",
|
||||
"Type": "Type",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Caption",
|
||||
"Filename": "Filename",
|
||||
"Message Template ID": "Message Template ID",
|
||||
"Template Fields": "Template Fields",
|
||||
"Phone number ID that will be used to send the message.": "Phone number ID that will be used to send the message.",
|
||||
"The recipient of the message": "The recipient of the message",
|
||||
"The message to send": "The message to send",
|
||||
"The type of media to send": "The type of media to send",
|
||||
"The URL of the media to send": "The URL of the media to send",
|
||||
"A caption for the media": "A caption for the media",
|
||||
"Filename of the document to send": "Filename of the document to send",
|
||||
"Recipient phone number.": "Recipient phone number."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"Manage your WhatsApp business account": "Manage your WhatsApp business account",
|
||||
"System User Access Token": "System User Access Token",
|
||||
"Business Account ID": "Business Account ID",
|
||||
"The system user access token of your WhatsApp business account.": "The system user access token of your WhatsApp business account.",
|
||||
"The business account ID of your WhatsApp business account.": "The business account ID of your WhatsApp business account.",
|
||||
"\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n": "\nTo Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:\n\n1. Go to https://developers.facebook.com/\n2. Make a new app, Select Other for usecase.\n3. Choose Business as the type of app.\n4. Add new Product -> WhatsApp.\n5. Navigate to WhatsApp Settings > API Setup.\n6. Copy the Business Account ID.\n7. Login to your [Meta Business Manager](https://business.facebook.com/).\n8. Click on Settings.\n9. Create a new System User with access over the app and copy the access token.\n",
|
||||
"Send Message": "Send Message",
|
||||
"Send Media": "Send Media",
|
||||
"Send Template Message": "Send Template Message",
|
||||
"Send a text message through WhatsApp": "Send a text message through WhatsApp",
|
||||
"Send a media message through WhatsApp": "Send a media message through WhatsApp",
|
||||
"Sends a template message.": "Sends a template message.",
|
||||
"Phone Number ID": "Phone Number ID",
|
||||
"To": "To",
|
||||
"Message": "Message",
|
||||
"Type": "类型",
|
||||
"Media URL": "Media URL",
|
||||
"Caption": "Caption",
|
||||
"Filename": "Filename",
|
||||
"Message Template ID": "Message Template ID",
|
||||
"Template Fields": "Template Fields",
|
||||
"Phone number ID that will be used to send the message.": "Phone number ID that will be used to send the message.",
|
||||
"The recipient of the message": "The recipient of the message",
|
||||
"The message to send": "The message to send",
|
||||
"The type of media to send": "The type of media to send",
|
||||
"The URL of the media to send": "The URL of the media to send",
|
||||
"A caption for the media": "A caption for the media",
|
||||
"Filename of the document to send": "Filename of the document to send",
|
||||
"Recipient phone number.": "Recipient phone number."
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { createPiece, PieceAuth, Property } from '@activepieces/pieces-framework';
|
||||
import { sendMessage } from './lib/actions/send-message';
|
||||
import { sendMedia } from './lib/actions/send-media';
|
||||
import { sendTemplateMessageAction } from './lib/actions/send-from-template';
|
||||
|
||||
const markdown = `
|
||||
To Obtain a Phone Number ID and a Permanent System User Access Token, follow these steps:
|
||||
|
||||
1. Go to https://developers.facebook.com/
|
||||
2. Make a new app, Select Other for usecase.
|
||||
3. Choose Business as the type of app.
|
||||
4. Add new Product -> WhatsApp.
|
||||
5. Navigate to WhatsApp Settings > API Setup.
|
||||
6. Copy the Business Account ID.
|
||||
7. Login to your [Meta Business Manager](https://business.facebook.com/).
|
||||
8. Click on Settings.
|
||||
9. Create a new System User with access over the app and copy the access token.
|
||||
`;
|
||||
|
||||
export const whatsappAuth = PieceAuth.CustomAuth({
|
||||
required: true,
|
||||
description: markdown,
|
||||
props: {
|
||||
access_token: PieceAuth.SecretText({
|
||||
displayName: 'System User Access Token',
|
||||
description: 'The system user access token of your WhatsApp business account.',
|
||||
required: true,
|
||||
}),
|
||||
businessAccountId: Property.ShortText({
|
||||
displayName: 'Business Account ID',
|
||||
description: 'The business account ID of your WhatsApp business account.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const whatsapp = createPiece({
|
||||
displayName: 'WhatsApp Business',
|
||||
description: 'Manage your WhatsApp business account',
|
||||
auth: whatsappAuth,
|
||||
minimumSupportedRelease: '0.30.0',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/whatsapp.png',
|
||||
authors: ['LevwTech', 'kishanprmr'],
|
||||
actions: [sendMessage, sendMedia, sendTemplateMessageAction],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
import { whatsappAuth } from '../..';
|
||||
import { AuthenticationType, httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { commonProps } from '../common/utils';
|
||||
|
||||
export const sendTemplateMessageAction = createAction({
|
||||
auth: whatsappAuth,
|
||||
name: 'send-template-message',
|
||||
displayName: 'Send Template Message',
|
||||
description: 'Sends a template message.',
|
||||
props: {
|
||||
phone_number_id: commonProps.phone_number_id,
|
||||
to: Property.ShortText({
|
||||
displayName: 'To',
|
||||
description: 'Recipient phone number.',
|
||||
required: true,
|
||||
}),
|
||||
message_template_id: commonProps.message_template_id,
|
||||
message_template_fields: commonProps.message_template_fields,
|
||||
},
|
||||
async run(context) {
|
||||
const phoneNumberId = context.propsValue.phone_number_id as string;
|
||||
const recipientPhoneNumber = context.propsValue.to as string;
|
||||
const templateId = context.propsValue.message_template_id as string;
|
||||
const templateFields = context.propsValue.message_template_fields;
|
||||
|
||||
// construct components object
|
||||
// https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#components-object
|
||||
const components = [];
|
||||
const headerParameters = [];
|
||||
const bodyParameters = [];
|
||||
const buttonParameters = [];
|
||||
|
||||
for (const [key, value] of Object.entries(templateFields)) {
|
||||
if (key.startsWith('header_')) {
|
||||
headerParameters.push({ type: 'text', text: value });
|
||||
} else if (key.startsWith('body_')) {
|
||||
bodyParameters.push({ type: 'text', text: value });
|
||||
} else if (key.startsWith('button_')) {
|
||||
buttonParameters.push({ type: 'text', text: value });
|
||||
}
|
||||
}
|
||||
|
||||
if (headerParameters.length) {
|
||||
components.push({
|
||||
type: 'header',
|
||||
parameters: headerParameters,
|
||||
});
|
||||
}
|
||||
if (bodyParameters.length) {
|
||||
components.push({
|
||||
type: 'body',
|
||||
parameters: bodyParameters,
|
||||
});
|
||||
}
|
||||
if (buttonParameters.length) {
|
||||
components.push({
|
||||
type: 'button',
|
||||
sub_type: 'url',
|
||||
index: 0,
|
||||
parameters: buttonParameters,
|
||||
});
|
||||
}
|
||||
|
||||
// fetch template language code
|
||||
const templateData = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url: `https://graph.facebook.com/v20.0/${templateId}`,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: context.auth.props.access_token,
|
||||
},
|
||||
queryParams: {
|
||||
fields: 'id,name,language',
|
||||
},
|
||||
});
|
||||
|
||||
const templateLanguage = templateData.body['language'];
|
||||
const templateName = templateData.body['name'];
|
||||
|
||||
// https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates/#text-based
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `https://graph.facebook.com/v20.0/${phoneNumberId}/messages`,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: context.auth.props.access_token,
|
||||
},
|
||||
body: {
|
||||
messaging_product: 'whatsapp',
|
||||
recipient_type: 'individual',
|
||||
to: recipientPhoneNumber,
|
||||
type: 'template',
|
||||
template: {
|
||||
name: templateName,
|
||||
language: {
|
||||
code: templateLanguage,
|
||||
},
|
||||
components,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return response.body;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { whatsappAuth } from '../..';
|
||||
import {
|
||||
supportedMediaTypes,
|
||||
capitalizeFirstLetter,
|
||||
mediaTypeSupportsCaption,
|
||||
commonProps,
|
||||
} from '../common/utils';
|
||||
|
||||
export const sendMedia = createAction({
|
||||
auth: whatsappAuth,
|
||||
name: 'sendMedia',
|
||||
displayName: 'Send Media',
|
||||
description: 'Send a media message through WhatsApp',
|
||||
props: {
|
||||
phone_number_id: commonProps.phone_number_id,
|
||||
to: Property.ShortText({
|
||||
displayName: 'To',
|
||||
description: 'The recipient of the message',
|
||||
required: true,
|
||||
}),
|
||||
type: Property.Dropdown({
|
||||
auth: whatsappAuth,
|
||||
displayName: 'Type',
|
||||
description: 'The type of media to send',
|
||||
required: true,
|
||||
options: async () => {
|
||||
return {
|
||||
options: supportedMediaTypes.map((type) => ({
|
||||
label: capitalizeFirstLetter(type),
|
||||
value: type,
|
||||
})),
|
||||
};
|
||||
},
|
||||
refreshers: [],
|
||||
}),
|
||||
media: Property.ShortText({
|
||||
displayName: 'Media URL',
|
||||
description: 'The URL of the media to send',
|
||||
required: true,
|
||||
}),
|
||||
caption: Property.LongText({
|
||||
displayName: 'Caption',
|
||||
description: 'A caption for the media',
|
||||
required: false,
|
||||
}),
|
||||
filename: Property.LongText({
|
||||
displayName: 'Filename',
|
||||
description: 'Filename of the document to send',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { to, caption, media, type, filename, phone_number_id } = context.propsValue;
|
||||
const { access_token } = context.auth.props;
|
||||
const body = {
|
||||
messaging_product: 'whatsapp',
|
||||
recipient_type: 'individual',
|
||||
to,
|
||||
type,
|
||||
[type]: {
|
||||
link: media,
|
||||
},
|
||||
};
|
||||
if (caption && mediaTypeSupportsCaption(type)) (body[type] as any).caption = caption;
|
||||
if (filename && type === 'document') (body[type] as any).filename = filename;
|
||||
return await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `https://graph.facebook.com/v17.0/${phone_number_id}/messages`,
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + access_token,
|
||||
},
|
||||
body,
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { whatsappAuth } from '../..';
|
||||
import { commonProps } from '../common/utils';
|
||||
|
||||
export const sendMessage = createAction({
|
||||
auth: whatsappAuth,
|
||||
name: 'sendMessage',
|
||||
displayName: 'Send Message',
|
||||
description: 'Send a text message through WhatsApp',
|
||||
props: {
|
||||
phone_number_id: commonProps.phone_number_id,
|
||||
to: Property.ShortText({
|
||||
displayName: 'To',
|
||||
description: 'The recipient of the message',
|
||||
required: true,
|
||||
}),
|
||||
text: Property.LongText({
|
||||
displayName: 'Message',
|
||||
description: 'The message to send',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { to, text, phone_number_id } = context.propsValue;
|
||||
const { access_token } = context.auth.props;
|
||||
return await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `https://graph.facebook.com/v17.0/${phone_number_id}/messages`,
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + access_token,
|
||||
},
|
||||
body: {
|
||||
messaging_product: 'whatsapp',
|
||||
recipient_type: 'individual',
|
||||
to,
|
||||
type: 'text',
|
||||
text: {
|
||||
body: text,
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,225 @@
|
||||
import {
|
||||
AuthenticationType,
|
||||
httpClient,
|
||||
HttpMethod,
|
||||
QueryParams,
|
||||
} from '@activepieces/pieces-common';
|
||||
import { whatsappAuth } from '../../';
|
||||
import {
|
||||
Property,
|
||||
PiecePropValueSchema,
|
||||
DynamicPropsValue,
|
||||
DropdownOption,
|
||||
} from '@activepieces/pieces-framework';
|
||||
|
||||
export const supportedMediaTypes = ['image', 'audio', 'document', 'sticker', 'video'];
|
||||
export const capitalizeFirstLetter = (word: string) => word.charAt(0).toUpperCase() + word.slice(1);
|
||||
export const mediaTypeSupportsCaption = (type: string) =>
|
||||
['image', 'video', 'document'].includes(type);
|
||||
|
||||
export const commonProps = {
|
||||
phone_number_id: Property.Dropdown({
|
||||
auth: whatsappAuth,
|
||||
displayName: 'Phone Number ID',
|
||||
description: 'Phone number ID that will be used to send the message.',
|
||||
refreshers: [],
|
||||
required: true,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
placeholder: 'Please connect account first',
|
||||
disabled: true,
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const authValue = auth.props;
|
||||
|
||||
const options: DropdownOption<string>[] = [];
|
||||
|
||||
let hasMore = false;
|
||||
let cursor;
|
||||
|
||||
do {
|
||||
const qs: QueryParams = {
|
||||
fields: 'verified_name,id,display_phone_number',
|
||||
limit: '1',
|
||||
};
|
||||
if (cursor) qs['after'] = cursor;
|
||||
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url: `https://graph.facebook.com/v20.0/${authValue.businessAccountId}/phone_numbers`,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: authValue.access_token,
|
||||
},
|
||||
queryParams: qs,
|
||||
});
|
||||
|
||||
for (const phoneNumber of response.body.data) {
|
||||
options.push({
|
||||
label: `${phoneNumber.verified_name as string} : ${
|
||||
phoneNumber.display_phone_number as string
|
||||
}`,
|
||||
value: phoneNumber.id as string,
|
||||
});
|
||||
}
|
||||
|
||||
if (response.body.paging.next) {
|
||||
(hasMore = true), (cursor = response.body.paging.cursors.after);
|
||||
} else {
|
||||
hasMore = false;
|
||||
}
|
||||
} while (hasMore);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options,
|
||||
};
|
||||
},
|
||||
}),
|
||||
message_template_id: Property.Dropdown({
|
||||
displayName: 'Message Template ID',
|
||||
refreshers: [],
|
||||
required: true,
|
||||
auth: whatsappAuth,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
placeholder: 'Please connect account first',
|
||||
disabled: true,
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const authValue = auth.props;
|
||||
|
||||
const options: DropdownOption<string>[] = [];
|
||||
|
||||
let hasMore = false;
|
||||
let cursor;
|
||||
|
||||
do {
|
||||
const qs: QueryParams = {
|
||||
fields: 'id,name,language',
|
||||
limit: '1',
|
||||
};
|
||||
if (cursor) qs['after'] = cursor;
|
||||
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url: `https://graph.facebook.com/v20.0/${authValue.businessAccountId}/message_templates`,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: authValue.access_token,
|
||||
},
|
||||
queryParams: qs,
|
||||
});
|
||||
|
||||
for (const template of response.body.data) {
|
||||
options.push({
|
||||
label: `${template.name as string} (${template.language as string})`,
|
||||
value: template.id as string,
|
||||
});
|
||||
}
|
||||
|
||||
if (response.body.paging.next) {
|
||||
(hasMore = true), (cursor = response.body.paging.cursors.after);
|
||||
} else {
|
||||
hasMore = false;
|
||||
}
|
||||
} while (hasMore);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options,
|
||||
};
|
||||
},
|
||||
}),
|
||||
|
||||
message_template_fields: Property.DynamicProperties({
|
||||
displayName: 'Template Fields',
|
||||
refreshers: ['message_template_id'],
|
||||
required: true,
|
||||
auth: whatsappAuth,
|
||||
props: async ({ auth, message_template_id }) => {
|
||||
if (!auth) return {};
|
||||
if (!message_template_id) return {};
|
||||
|
||||
const authValue = auth.props;
|
||||
const templateId = message_template_id as unknown as string;
|
||||
|
||||
const response = await httpClient.sendRequest({
|
||||
url: `https://graph.facebook.com/v20.0/${templateId}`,
|
||||
method: HttpMethod.GET,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: authValue.access_token,
|
||||
},
|
||||
});
|
||||
|
||||
const bodyComponentFields: DynamicPropsValue = {};
|
||||
const headerComponentFields: DynamicPropsValue = {};
|
||||
const buttonComponentFields: DynamicPropsValue = {};
|
||||
|
||||
for (const component of response.body.components) {
|
||||
if (component.type === 'BODY') {
|
||||
// https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components#syntax
|
||||
bodyComponentFields['BODY_markdown'] = Property.MarkDown({
|
||||
value: `
|
||||
**Body :**
|
||||
${component.text}`,
|
||||
});
|
||||
|
||||
const bodyTextVariables = component.text?.match(/{{(\d+)}}/g) ?? [];
|
||||
|
||||
for (let i = 0; i < bodyTextVariables.length; i++) {
|
||||
bodyComponentFields[`body_{{${i + 1}}}`] = Property.ShortText({
|
||||
displayName: `Body {{${i + 1}}}`,
|
||||
required: false,
|
||||
});
|
||||
}
|
||||
} else if (component.type === 'HEADER' && component.format === 'TEXT') {
|
||||
// https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components#text-headers
|
||||
headerComponentFields['HEADER_markdown'] = Property.MarkDown({
|
||||
value: `
|
||||
**Header :**
|
||||
${component.text}`,
|
||||
});
|
||||
|
||||
const headerTextVariables = component.text?.match(/{{(\d+)}}/g) ?? [];
|
||||
|
||||
for (let i = 0; i < headerTextVariables.length; i++) {
|
||||
headerComponentFields[`header_{{${i + 1}}}`] = Property.ShortText({
|
||||
displayName: `Header {{${i + 1}}}`,
|
||||
required: false,
|
||||
});
|
||||
}
|
||||
} else if (component.type === 'BUTTONS') {
|
||||
// https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components#url-buttons
|
||||
for (const button of component.buttons) {
|
||||
if (button.type === 'URL') {
|
||||
const buttonURLTextVariables = button.url?.match(/{{(\d+)}}/g) ?? [];
|
||||
|
||||
for (let i = 0; i < buttonURLTextVariables.length; i++) {
|
||||
buttonComponentFields[`button_{{${i + 1}}}`] = Property.ShortText({
|
||||
displayName: button.text,
|
||||
required: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const templateFields: DynamicPropsValue = {
|
||||
...headerComponentFields,
|
||||
...bodyComponentFields,
|
||||
...buttonComponentFields,
|
||||
};
|
||||
|
||||
return templateFields;
|
||||
},
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"outDir": "../../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts", "src/lib/actions/common/utils.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user