Untitled
unknown
plain_text
a month ago
1.4 kB
1
Indexable
Never
function doPost(e) { // Clear any existing cache related to the Rekap message CacheService.getScriptCache().remove('rekapMessage'); // Parse the incoming POST data from PushWA in JSON format const body = e.postData.contents; const parsedData = JSON.parse(body); // Extract relevant data from the parsed JSON const device = parsedData.deviceNumber; // The device number that received the message const fromNumber = parsedData.from; // The sender's WhatsApp number, e.g., '628123456789' const messageBody = parsedData.message ? parsedData.message.trim().toLowerCase() : ''; // Converts the message to lowercase for case-insensitive matching // Check if the message body contains the keyword 'Rekap' if (messageBody == 'rekap') { // Generate the Rekap message const rekapMessage = generateRekapMessage(); // This will generate a fresh message every time // Send the Rekap message back to the sender sendMessagePushWA(fromNumber, rekapMessage); } const cache = CacheService.getScriptCache(); cache.remove('rekapMessage'); // Ensure no cached version is being used // Prepare and return a JSON response to PushWA const res = { "message": "Berubah Ga?" // Custom response message }; return ContentService.createTextOutput(JSON.stringify(res)).setMimeType(ContentService.MimeType.JSON); }
Leave a Comment