Skip to content

Commit

Permalink
Dec 7, 2024, 9:37 PM
Browse files Browse the repository at this point in the history
  • Loading branch information
sudtanj committed Dec 7, 2024
1 parent f7c9233 commit 3b725c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/callmebot_whatsapp_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
// 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);
Expand Down

0 comments on commit 3b725c7

Please sign in to comment.