From 3b725c7a25bacc477c6f39ccc4d9444a2bb04047 Mon Sep 17 00:00:00 2001 From: sudtanj <17475015+sudtanj@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:37:27 +0000 Subject: [PATCH] Dec 7, 2024, 9:37 PM --- lib/callmebot_whatsapp_service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/callmebot_whatsapp_service.ts b/lib/callmebot_whatsapp_service.ts index 43395b1..98dd726 100644 --- a/lib/callmebot_whatsapp_service.ts +++ b/lib/callmebot_whatsapp_service.ts @@ -16,17 +16,19 @@ export class CallMeBotWhatsAppAPI { * @throws Error if the API key is not found in script properties or an error occurs during the API request. */ public static async sendMessage(message: string): Promise { + // get api key from properties services const apiKey = PropertiesService.getScriptProperties().getProperty('call_me_bot_api_key'); if (!apiKey) { throw new Error('API key not found in script properties. Please set the "call_me_bot_api_key" property.'); } + // get phone number from properties services const targetPhoneNumber = PropertiesService.getScriptProperties().getProperty('call_me_bot_target_phone'); if (!targetPhoneNumber) { throw new Error('Target phone number not found in script properties. Please set the "call_me_bot_target_phone" property.'); } - const url = `https://api.callmebot.com/whatsapp.php?phone=${phoneNumber}&text=${message}&apikey=${apiKey}`; + const url = `https://api.callmebot.com/whatsapp.php?phone=${targetPhoneNumber}&text=${message}&apikey=${apiKey}`; try { const response = await fetch(url);