diff --git a/functions/src/definitions/checkerHandlers.ts b/functions/src/definitions/checkerHandlers.ts index 82138576..c02d5412 100644 --- a/functions/src/definitions/checkerHandlers.ts +++ b/functions/src/definitions/checkerHandlers.ts @@ -22,10 +22,11 @@ if (!admin.apps.length) { admin.initializeApp() } +const db = admin.firestore() + const checkerHandlerWhatsapp = async function (message: Message) { const from = message.from // extract the phone number from the webhook payload const type = message.type - const db = admin.firestore() let responses switch (type) { @@ -99,7 +100,6 @@ const checkerHandlerWhatsapp = async function (message: Message) { async function onSignUp(from: string, platform = "whatsapp") { const responses = await getResponsesObj("factChecker") - const db = admin.firestore() let res = await sendTextMessage( "factChecker", from, @@ -135,7 +135,6 @@ async function onMsgReplyReceipt( platform = "whatsapp" ) { const responses = await getResponsesObj("factChecker") - const db = admin.firestore() const factCheckerSnap = await db.collection("factCheckers").doc(from).get() if (factCheckerSnap.get("getNameMessageId") === messageId) { await factCheckerSnap.ref.update({ @@ -164,7 +163,6 @@ async function onFactCheckerYes( from: string, platform = "whatsapp" ) { - const db = admin.firestore() if (!voteRequestPath.includes("/")) { throw new Error("The voteRequestPath does not contain a forward slash (/).") } @@ -430,7 +428,6 @@ async function onTextListReceipt( } async function onContinue(factCheckerId: string) { - const db = admin.firestore() await db.collection("factCheckers").doc(factCheckerId).update({ isActive: true, }) diff --git a/functions/src/definitions/common/utils.ts b/functions/src/definitions/common/utils.ts index 3aa3778e..a042e75b 100644 --- a/functions/src/definitions/common/utils.ts +++ b/functions/src/definitions/common/utils.ts @@ -33,6 +33,13 @@ const checkUrl = function (urlString: string) { return url.protocol === "http:" || url.protocol === "https:" } +async function checkMessageId(messageId: string) { + const db = admin.firestore() + const messageRef = db.collection("messageIds").doc(messageId) + const messageSnap = await messageRef.get() + return messageSnap.exists +} + function stripPhone(originalStr: string, includePlaceholder = false) { const phoneNumbers = findPhoneNumbersInText(originalStr) let newStr = originalStr @@ -91,4 +98,5 @@ export { getThresholds, checkUrl, normalizeSpaces, + checkMessageId, } diff --git a/functions/src/definitions/userHandlers.ts b/functions/src/definitions/userHandlers.ts index 8d877ea2..5bc77614 100644 --- a/functions/src/definitions/userHandlers.ts +++ b/functions/src/definitions/userHandlers.ts @@ -9,7 +9,12 @@ import { sendWhatsappContactMessage, } from "./common/sendWhatsappMessage" import { sendDisputeNotification } from "./common/sendMessage" -import { sleep, hashMessage, normalizeSpaces } from "./common/utils" +import { + sleep, + hashMessage, + normalizeSpaces, + checkMessageId, +} from "./common/utils" import { getResponsesObj, sendMenuMessage, @@ -44,6 +49,15 @@ const hashids = new Hashids(salt) const db = admin.firestore() const userHandlerWhatsapp = async function (message: Message) { + if (!message?.id) { + functions.logger.error("No message id") + return + } + if (await checkMessageId(message.id)) { + functions.logger.warn(`Message ${message.id} already exists`) + return + } + let from = message.from // extract the phone number from the webhook payload let type = message.type const responses = await getResponsesObj("user") @@ -161,7 +175,7 @@ const userHandlerWhatsapp = async function (message: Message) { step = await newTextInstanceHandler({ text: message.text.body, timestamp: messageTimestamp, - id: message.id || null, + id: message.id, from: from || null, isForwarded: message?.context?.forwarded || null, isFrequentlyForwarded: message?.context?.frequently_forwarded || null, @@ -173,7 +187,7 @@ const userHandlerWhatsapp = async function (message: Message) { step = await newImageInstanceHandler({ caption: message?.image?.caption || null, timestamp: messageTimestamp, - id: message.id || null, + id: message.id, mediaId: message?.image?.id || null, mimeType: message?.image?.mime_type || null, from: from || null, @@ -253,14 +267,15 @@ async function newTextInstanceHandler({ }: { text: string timestamp: Timestamp - id: string | null + id: string from: string | null isForwarded: boolean | null isFrequentlyForwarded: boolean | null isFirstTimeUser: boolean }) { let hasMatch = false - let messageRef + let messageRef: FirebaseFirestore.DocumentReference | null = null + let messageUpdateObj: Object | null = null const machineCategory = (await classifyText(text)) ?? "error" if (from && isFirstTimeUser && machineCategory.includes("irrelevant")) { await db.collection("users").doc(from).update({ @@ -286,7 +301,7 @@ async function newTextInstanceHandler({ let bestMatchingDocumentRef let bestMatchingText let similarityScore = 0 - let matchedParentMessageRef + let matchedParentMessageRef = null if ( similarity.ref && @@ -306,7 +321,8 @@ async function newTextInstanceHandler({ } if (!hasMatch) { - let writeResult = await db.collection("messages").add({ + messageRef = db.collection("messages").doc() + messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: !!( machineCategory && @@ -349,17 +365,18 @@ async function newTextInstanceHandler({ : null, customReply: null, //string instanceCount: 0, - }) - messageRef = writeResult + } } else { messageRef = matchedParentMessageRef } if (!messageRef) { - throw new Error( + functions.logger.error( `No messageRef created or matched for whatsapp message with id ${id}` ) + return } - const _ = await messageRef.collection("instances").add({ + const instanceRef = messageRef.collection("instances").doc() + const instanceUpdateObj = { source: "whatsapp", id: id || null, //taken from webhook object, needed to reply timestamp: timestamp, //timestamp, taken from webhook object (firestore timestamp data type) @@ -394,7 +411,15 @@ async function newTextInstanceHandler({ }, isSatisfactionSurveySent: null, satisfactionScore: null, - }) + } + await addInstanceToDb( + id, + hasMatch, + messageRef, + messageUpdateObj, + instanceRef, + instanceUpdateObj + ) return Promise.resolve(`text_machine_${machineCategory}`) } @@ -413,14 +438,15 @@ async function newImageInstanceHandler({ mediaId: string | null mimeType: string | null timestamp: Timestamp - id: string | null + id: string from: string | null isForwarded: boolean | null isFrequentlyForwarded: boolean | null isFirstTimeUser: boolean }) { let filename - let messageRef + let messageRef: FirebaseFirestore.DocumentReference | null = null + let messageUpdateObj: Object | null = null let hasMatch = false let matchType = "none" // will be set to either "similarity" or "image" or "none" let matchedInstanceSnap @@ -512,7 +538,7 @@ async function newImageInstanceHandler({ let bestMatchingDocumentRef let bestMatchingText let similarityScore = 0 - let matchedParentMessageRef + let matchedParentMessageRef = null let textHash = null if (ocrSuccess && isConvo && !!extractedMessage && !hasMatch) { @@ -547,7 +573,8 @@ async function newImageInstanceHandler({ } if (!hasMatch || (!matchedInstanceSnap && !matchedParentMessageRef)) { - let writeResult = await db.collection("messages").add({ + messageRef = db.collection("messages").doc() + messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: !!( machineCategory && @@ -587,8 +614,7 @@ async function newImageInstanceHandler({ : null, customReply: null, //string instanceCount: 0, - }) - messageRef = writeResult + } } else { if (matchType === "image" && matchedInstanceSnap) { messageRef = matchedInstanceSnap.ref.parent.parent @@ -600,11 +626,13 @@ async function newImageInstanceHandler({ } } if (!messageRef) { - throw new Error( + functions.logger.error( `No messageRef created or matched for whatsapp message with id ${id}` ) + return } - const _ = await messageRef.collection("instances").add({ + const instanceRef = messageRef.collection("instances").doc() + const instanceUpdateObj = { source: "whatsapp", id: id || null, //taken from webhook object, needed to reply timestamp: timestamp, //timestamp, taken from webhook object (firestore timestamp data type) @@ -644,7 +672,15 @@ async function newImageInstanceHandler({ }, isSatisfactionSurveySent: null, satisfactionScore: null, - }) + } + await addInstanceToDb( + id, + hasMatch, + messageRef, + messageUpdateObj, + instanceRef, + instanceUpdateObj + ) return Promise.resolve("image") } @@ -792,6 +828,33 @@ async function onTextListReceipt(messageObj: Message, platform = "whatsapp") { return Promise.resolve(step) } +async function addInstanceToDb( + id: string, + hasMatch: boolean, + messageRef: FirebaseFirestore.DocumentReference | null, + messageUpdateObj: Object | null = null, + instanceRef: FirebaseFirestore.DocumentReference, + instanceUpdateObj: Object +) { + const messageIdRef = db.collection("messageIds").doc(id) + try { + await db.runTransaction(async (t) => { + const doc = await t.get(messageIdRef) + if (doc.exists) { + return + } + if (!hasMatch && !!messageRef && !!messageUpdateObj) { + t.set(messageRef, messageUpdateObj) + } + t.set(instanceRef, instanceUpdateObj) + t.set(messageIdRef, { instanceRef: instanceRef }) + }) + functions.logger.log(`Transaction success for messageId ${id}!`) + } catch (e) { + functions.logger.error(`Transaction failure for messageId ${id}!`, e) + } +} + async function createNewUser( userRef: admin.firestore.DocumentReference, messageTimestamp: Timestamp diff --git a/functions/src/definitions/webhookHandler.ts b/functions/src/definitions/webhookHandler.ts index 5b8c8751..95caf7b0 100644 --- a/functions/src/definitions/webhookHandler.ts +++ b/functions/src/definitions/webhookHandler.ts @@ -5,6 +5,7 @@ import { defineString } from "firebase-functions/params" import { handleSpecialCommands } from "./specialCommands" import { publishToTopic } from "./common/pubsub" import { onRequest } from "firebase-functions/v2/https" +import { checkMessageId } from "./common/utils" const runtimeEnvironment = defineString("ENVIRONMENT") const testUserPhoneNumberId = defineString( @@ -57,6 +58,18 @@ app.post("/whatsapp", async (req, res) => { //handle db commands await handleSpecialCommands(message) } else { + if (message?.id) { + //if message has been processed before, don't even put it in queue. + if (await checkMessageId(message.id)) { + functions.logger.warn(`message ${message.id} already processed`) + res.sendStatus(200) + return + } + } else { + functions.logger.error(`message ${message.id} has no id`) + res.sendStatus(200) + return + } if ( (type == "button" || type == "interactive" || type == "text") && phoneNumberId === checkerPhoneNumberId @@ -122,21 +135,6 @@ app.get("/whatsapp", (req, res) => { } }) -const webhookHandler = functions - .region("asia-southeast1") - .runWith({ - secrets: [ - "WHATSAPP_USER_BOT_PHONE_NUMBER_ID", - "WHATSAPP_CHECKERS_BOT_PHONE_NUMBER_ID", - "WHATSAPP_TOKEN", - "VERIFY_TOKEN", - "TYPESENSE_TOKEN", - "ML_SERVER_TOKEN", - "TELEGRAM_REPORT_BOT_TOKEN", - ], - }) - .https.onRequest(app) - const webhookHandlerV2 = onRequest( { secrets: [ @@ -148,4 +146,4 @@ const webhookHandlerV2 = onRequest( app ) -export { app, webhookHandlerV2, webhookHandler } +export { app, webhookHandlerV2 } diff --git a/functions/src/index.ts b/functions/src/index.ts index 7aa9888c..34ec40ec 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -7,7 +7,6 @@ export { onInstanceCreate } from "./definitions/onInstanceCreate" export { onInstanceDelete } from "./definitions/onInstanceDelete" export { onInstanceUpdate } from "./definitions/onInstanceUpdate" export { onMessageUpdate } from "./definitions/onMessageUpdate" -export { webhookHandler } from "./definitions/webhookHandler" export { webhookHandlerV2 } from "./definitions/webhookHandler" export { onVoteRequestUpdate } from "./definitions/onVoteRequestUpdate" export { healthcheck } from "./definitions/healthcheck" diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 97c164ec..8a91ecbc 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,11186 +1,13299 @@ { - "info": { - "_postman_id": "103b9282-6f00-47a0-8170-35734cf20265", - "name": "checkmate", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "25230076" - }, - "item": [ - { - "name": "000_Healthcheck", - "item": [ - { - "name": "Healthcheck", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", - "host": ["{{FUNCTIONS_URL}}"], - "path": ["checkmate-373101", "asia-southeast1", "healthcheck"] - } - }, - "response": [] - } - ] - }, - { - "name": "001_Mock_Db", - "item": [ - { - "name": "Create mock firestore DB", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"Test User\"\r\n },\r\n \"wa_id\": \"88888888\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"88888888\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/mockdb\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get mock db collection IDs", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check number of collections /mockdb command creates in Firestore\", function () {\r", - " const jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData?.collectionIds?.length).to.eql(2);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "default" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents:listCollectionIds" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "002_Add_Checkers", - "item": [ - { - "name": "Checker 2 Onboarding", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_1 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_1,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"whatsapp\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 input name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_2 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const CHECKER_2_NAME = pm.variables.get(\"CHECKER_2_NAME\");\r", - " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_2_NAME);\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_2\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"privacyOk\",\r", - " \"title\": \"Got it!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 press \"Got it!\" button", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"privacyOk\",\r\n \"title\": \"Got it!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_3 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_3 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3\")\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_3\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"typeformDone\",\r", - " \"title\": \"I've done the quiz!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 press \"Ive done the quiz!\" button", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"typeformDone\",\r\n \"title\": \"I've done the quiz!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_4 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_4 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4\")\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_4,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 3 Onboarding", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_1 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", - " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_1,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_3_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"whatsapp\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 3 input name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_2 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", - " const CHECKER_3_NAME = pm.variables.get(\"CHECKER_3_NAME\");\r", - " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_3_NAME);\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_3_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_2\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"privacyOk\",\r", - " \"title\": \"Got it!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "003_New_User", - "item": [ - { - "name": "Send WhatsApp message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"F\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that has is created\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralId = jsonData.fields.referralId.stringValue\r", - " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", - " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", - " pm.expect(referralId.length).to.be.above(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "004_Irrelevant_Message", - "item": [ - { - "name": "Send WhatsApp message (7 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"1234567\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (IRRELEVANT_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message auto-categorised as irrelevant returns correct menu\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\",\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": \"Dispute Assessment\",\r", - " \"description\": \"Dispute CheckMate's assesment of this message\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " // get the id of \"Dispute Assessment\" for validation\r", - " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", - " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", - " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", - "\r", - " // remove the id of \"Dispute Assessment\" for comparison\r", - " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", - " if (row.title === \"Dispute Assessment\") {\r", - " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", - " } else {\r", - " return row;\r", - " }\r", - " });\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Dispute Categorisation\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (telegram blast)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"On dispute, message is sent out to Telegram group chat\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const DISPUTED_INSTANCE_PATH = pm.collectionVariables.get(\"disputedInstancePath\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/botTELEGRAM_REPORT_BOT_TOKEN/sendMessage\",\r", - " \"body\": {\r", - " \"chat_id\": \"111111111\",\r", - " \"text\": `${USER_1_NUMBER} has disputed the assessment of a message sent by them.\\n \\nmessage/instance path: ${DISPUTED_INSTANCE_PATH}\\n\\ntype: text\\n\\ntext: 1234567\\n\\ncategory: irrelevant`\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get last message (DISPUTE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005_Spam_Human", - "item": [ - { - "name": "005a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a sp-am message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005b_Interim_Message", - "item": [ - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"spamInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{spamMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"No it's not\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_NOT_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_NOT_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update again", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"legitimate\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005d_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SPAM", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SPAM final reply sent to checker 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SPAM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const spamResponse = getFinalResponseText(SPAM)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": spamResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": SATISFACTION_SURVEY\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Tap to respond\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": \"Extremely likely 🤩\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"9\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"8\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"7\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"6\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"5\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"4\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"3\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"2\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"1\",\r", - " \"description\": \"Not at all likely 😥\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Votes 10", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY_THANKS", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const SATISFACTION_SURVEY_THANKS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": SATISFACTION_SURVEY_THANKS,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check instance updated", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const isSatisfactionSurveySent = jsonData.fields.isSatisfactionSurveySent.booleanValue\r", - " const satisfactionScore = parseInt(jsonData.fields.satisfactionScore.integerValue) //for some reason integerValue returns string\r", - "\r", - " pm.expect(isSatisfactionSurveySent).to.be.true;\r", - " pm.expect(satisfactionScore).to.equal(10);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{spamMessageId}}", - "instances", - "{{spamInstanceId}}" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "ALREADY_REPLIED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const ALREADY_REPLIED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ALREADY_REPLIED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005e_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"66.67% of our CheckMates thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "006_Info_Machine_Human", - "item": [ - { - "name": "006a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoMessageId`, messageId);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"1\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER1}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"infoInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances", - "{{infoInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "006b_2nd_Voter_1", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"1\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER2}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "UNTRUE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"UNTRUE final reply sent to checker 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const UNTRUE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNTRUE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006c_3rd_Voter_5", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"5\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER3}}_5\",\r\n \"title\": \"5\",\r\n \"description\": \"Totally true\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006d_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "007_Unsure_Human", - "item": [ - { - "name": "007a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureMessageId`, messageId);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"unsure\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_unsure\",\r\n \"title\": \"I'm Unsure\",\r\n \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007b_Interim_Message", - "item": [ - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"unsureInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007c_1st Voter Change To Legitimate", - "item": [ - { - "name": "First checker selects \"legitimate\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007d_2nd Voter Info \"3\"", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"info\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_info\",\r\n \"title\": \"News/Information/Opinion\",\r\n \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_NEXT_POLL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_NEXT_POLL message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const HOLD_FOR_NEXT_POLL = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_NEXT_POLL,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"3\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_3\",\r\n \"title\": \"3\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007e_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " //console.log(JSON.stringify(expected,null,2))\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"UNSURE final reply sent to user 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNSURE\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNSURE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007f_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"33.33% of our CheckMates thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "008_Menu_Message", - "item": [ - { - "name": "Send WhatApp message (\"Menu\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (GENERIC_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Check/Report\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (PROCEED_TO_SEND)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Help\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_help\",\r\n \"title\": \"Get Help\",\r\n \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (HOW_TO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"About CheckMate\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_about\",\r\n \"title\": \"About CheckMate\",\r\n \"description\": \"Learn more about CheckMate and the team behind it\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (LEARN_MORE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Send Feedback\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_feedback\",\r\n \"title\": \"Send Feedback\",\r\n \"description\": \"Send us feedback on anything to do with CheckMate\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (FEEDBACK)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Contact\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (contact type)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"contacts\",\r", - " \"contacts\": [\r", - " {\r", - " \"name\": {\r", - " \"formatted_name\": \"CheckMate\",\r", - " \"suffix\": \"CheckMate\"\r", - " },\r", - " \"urls\": [\r", - " {\r", - " \"url\": \"https://checkmate.sg\"\r", - " }\r", - " ],\r", - " \"phones\": [\r", - " {\r", - " \"phone\": \"+1 555-093-3685\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get last message (CONTACT)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.CONTACT\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Referral\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_referral\",\r\n \"title\": \"Get Referral Link\",\r\n \"description\": \"Get referral link to forward to others\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (REFERRAL)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL\");\r", - " const link = pm.variables.get(\"referralLink_USER1\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const referralMessage = BODY_TEXT.replace(\"{{link}}\", link)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": referralMessage,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "009_Scam_Autocategorise", - "item": [ - { - "name": "User sends scam message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a scam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SCAM, IMMEDIATE, NOT MATCHED, AUTO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"scam immediate autocategorised no matched response\", function () {\r", - " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SCAM\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": BODY_TEXT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"Yes\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"No\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - "\r", - " let reply_id_yes = jsonData.body.interactive.action.buttons[0].reply.id;\r", - " let reply_id_no = jsonData.body.interactive.action.buttons[1].reply.id;\r", - " let [, scamInstancePath , ] = reply_id_yes.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(reply_id_yes).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_consent/);\r", - " pm.expect(reply_id_no).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_decline/);\r", - " pm.collectionVariables.set(\"scamInstancePath\", scamInstancePath);\r", - "\r", - " jsonData.body.interactive.action.buttons[0].reply.id = \"ID\"\r", - " jsonData.body.interactive.action.buttons[1].reply.id = \"ID\"\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "010_Spam_Autocategorise", - "item": [ - { - "name": "User sends spam message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a spam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SPAM, IMMEDIATE, NOT MATCHED, AUTO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"spam immediate autocategorised no matched response\", function () {\r", - " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "011_Check_Steps_logging", - "item": [ - { - "name": "[DB CALL] Check steps", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", - " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", - " const expected = [\r", - " \"text_machine_irrelevant_length\",\r", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"satisfactionSurvey_10\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_info\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_contact\",\r", - " \"menu_referral\",\r", - " \"text_machine_scam\",\r", - " \"text_machine_spam\",\r", - " ]\r", - " pm.expect(actions).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "012_New_User_Referral", - "item": [ - { - "name": "Send WhatsApp message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that referral count is incremented to 1\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralCount = jsonData.fields.referralCount.integerValue\r", - " pm.expect(parseInt(referralCount)).to.eql(1);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - }, - { - "name": "Send 2nd referral message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (REFERRAL_INVALID)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"REFERRAL_INVALID response received\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID\");\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [""] - } - } - ], - "variable": [ - { - "key": "disputedMessagePath", - "value": "" - }, - { - "key": "disputedMessageTextListId", - "value": "" - }, - { - "key": "disputedInstancePath", - "value": "" - }, - { - "key": "scamInstancePath", - "value": "" - }, - { - "key": "spamVoteRequestPath", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "spamMessageId_CHECKER3", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "spamMessageId_CHECKER2", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "spamMessageId_CHECKER1", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "spamMessageId", - "value": "" - }, - { - "key": "spamInstanceId", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "infoMessageId", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "infoInstanceId", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "unsureInstanceId", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "unsureMessageId", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "user_1_referralId", - "value": "" - }, - { - "key": "referralLink_USER1", - "value": "" - }, - { - "key": "referralId_USER1", - "value": "" - } - ] -} + "info": { + "_postman_id": "5218f5ab-c512-43d1-b8a3-0831e12514c1", + "name": "checkmate", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "25230076" + }, + "item": [ + { + "name": "000_Healthcheck", + "item": [ + { + "name": "Healthcheck", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.collectionVariables.set(\"messageCounter\", 0);\r", + "\r", + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "healthcheck" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "001_Mock_Db", + "item": [ + { + "name": "Create mock firestore DB", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 1\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"Test User\"\r\n },\r\n \"wa_id\": \"88888888\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"88888888\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/mockdb\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get mock db collection IDs", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check number of collections /mockdb command creates in Firestore\", function () {\r", + " const jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData?.collectionIds?.length).to.eql(2);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "default" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:listCollectionIds" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "002_Add_Checkers", + "item": [ + { + "name": "Checker 2 Onboarding", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 2\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_2}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_1 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_1,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"whatsapp\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 input name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 3\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"{{MOCK_WHATSAPP_MSG_ID}}\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_3}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_2 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const CHECKER_2_NAME = pm.variables.get(\"CHECKER_2_NAME\");\r", + " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_2_NAME);\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_2\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"privacyOk\",\r", + " \"title\": \"Got it!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 press \"Got it!\" button", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 4\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"{{MOCK_WHATSAPP_MSG_ID}}\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_4}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"privacyOk\",\r\n \"title\": \"Got it!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_3 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_3 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3\")\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_3\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"typeformDone\",\r", + " \"title\": \"I've done the quiz!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 press \"Ive done the quiz!\" button", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 5\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_5}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"typeformDone\",\r\n \"title\": \"I've done the quiz!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_4 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_4 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4\")\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_4,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 3 Onboarding", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 6\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_6}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_1 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", + " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_1,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_3_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"whatsapp\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 3 input name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 7\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_7}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_2 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", + " const CHECKER_3_NAME = pm.variables.get(\"CHECKER_3_NAME\");\r", + " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_3_NAME);\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_3_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_2\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"privacyOk\",\r", + " \"title\": \"Got it!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "003_New_User", + "item": [ + { + "name": "Send WhatsApp message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 8\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_8}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"F\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that has is created\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralId = jsonData.fields.referralId.stringValue\r", + " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", + " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", + " pm.expect(referralId.length).to.be.above(0);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "004_Irrelevant_Message", + "item": [ + { + "name": "Send WhatsApp message (7 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 9\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_9}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"1234567\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (IRRELEVANT_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message auto-categorised as irrelevant returns correct menu\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\",\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_dispute_messages/*/instances/*\",\r", + " \"title\": \"Dispute Assessment\",\r", + " \"description\": \"Dispute CheckMate's assesment of this message\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " // get the id of \"Dispute Assessment\" for validation\r", + " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", + " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", + " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", + "\r", + " // remove the id of \"Dispute Assessment\" for comparison\r", + " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", + " if (row.title === \"Dispute Assessment\") {\r", + " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", + " } else {\r", + " return row;\r", + " }\r", + " });\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Dispute Categorisation\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 10\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_10}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (telegram blast)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"On dispute, message is sent out to Telegram group chat\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const DISPUTED_INSTANCE_PATH = pm.collectionVariables.get(\"disputedInstancePath\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/botTELEGRAM_REPORT_BOT_TOKEN/sendMessage\",\r", + " \"body\": {\r", + " \"chat_id\": \"111111111\",\r", + " \"text\": `${USER_1_NUMBER} has disputed the assessment of a message sent by them.\\n \\nmessage/instance path: ${DISPUTED_INSTANCE_PATH}\\n\\ntype: text\\n\\ntext: 1234567\\n\\ncategory: irrelevant`\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (DISPUTE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005_Spam_Human", + "item": [ + { + "name": "005a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 11\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_11}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a sp-am message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 5000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005b_Interim_Message", + "item": [ + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 12\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_12}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"spamInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{spamMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 13\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_13}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 14\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"No it's not\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_NOT_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_NOT_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update again", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 15\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005c_2nd Voter Legitimate", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"legitimate\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 16\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_16}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005d_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "SPAM", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SPAM final reply sent to checker 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SPAM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const spamResponse = getFinalResponseText(SPAM)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": spamResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": SATISFACTION_SURVEY\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Tap to respond\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"10\",\r", + " \"description\": \"Extremely likely 🤩\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"9\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"8\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"7\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"6\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"5\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"4\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"3\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"2\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"1\",\r", + " \"description\": \"Not at all likely 😥\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Votes 10", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY_THANKS", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const SATISFACTION_SURVEY_THANKS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": SATISFACTION_SURVEY_THANKS,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check instance updated", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance data updated correctly\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const isSatisfactionSurveySent = jsonData.fields.isSatisfactionSurveySent.booleanValue\r", + " const satisfactionScore = parseInt(jsonData.fields.satisfactionScore.integerValue) //for some reason integerValue returns string\r", + "\r", + " pm.expect(isSatisfactionSurveySent).to.be.true;\r", + " pm.expect(satisfactionScore).to.equal(10);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{spamMessageId}}", + "instances", + "{{spamInstanceId}}" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 17\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{{{whatsapp_id_17}}}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "ALREADY_REPLIED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const ALREADY_REPLIED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ALREADY_REPLIED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005e_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 18\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_18}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"66.67% of our CheckMates thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "006_Info_Machine_Human", + "item": [ + { + "name": "006a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 19\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoMessageId`, messageId);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"1\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER1}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"infoInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 20\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_20}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 21\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_21}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances", + "{{infoInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006b_2nd_Voter_1", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"1\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER2}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "UNTRUE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"UNTRUE final reply sent to checker 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const UNTRUE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const response = getFinalResponseText(UNTRUE)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": response\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006c_3rd_Voter_5", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"5\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER3}}_5\",\r\n \"title\": \"5\",\r\n \"description\": \"Totally true\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006d_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 22\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_22}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "007_Unsure_Human", + "item": [ + { + "name": "007a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 23\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_23}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureMessageId`, messageId);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"unsure\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_unsure\",\r\n \"title\": \"I'm Unsure\",\r\n \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007b_Interim_Message", + "item": [ + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 24\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_24}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"unsureInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 25\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_25}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007c_1st Voter Change To Legitimate", + "item": [ + { + "name": "First checker selects \"legitimate\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 26\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_26}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 27\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_27}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007d_2nd Voter Info \"3\"", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"info\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_info\",\r\n \"title\": \"News/Information/Opinion\",\r\n \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_NEXT_POLL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_NEXT_POLL message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const HOLD_FOR_NEXT_POLL = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_NEXT_POLL,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"3\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_3\",\r\n \"title\": \"3\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 28\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_28}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007e_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " //console.log(JSON.stringify(expected,null,2))\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"UNSURE final reply sent to user 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNSURE\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const response = getFinalResponseText(UNSURE)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": response\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007f_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 29\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_29}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"33.33% of our CheckMates thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "008_Menu_Message", + "item": [ + { + "name": "Send WhatApp message (\"Menu\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 30\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_30}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (GENERIC_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Check/Report\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 31\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_31}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (PROCEED_TO_SEND)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Help\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 32\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_32}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_help\",\r\n \"title\": \"Get Help\",\r\n \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (HOW_TO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"About CheckMate\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 33\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_33}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_about\",\r\n \"title\": \"About CheckMate\",\r\n \"description\": \"Learn more about CheckMate and the team behind it\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (LEARN_MORE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Send Feedback\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 34\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_34}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_feedback\",\r\n \"title\": \"Send Feedback\",\r\n \"description\": \"Send us feedback on anything to do with CheckMate\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (FEEDBACK)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Contact\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 35\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_35}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (contact type)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"contacts\",\r", + " \"contacts\": [\r", + " {\r", + " \"name\": {\r", + " \"formatted_name\": \"CheckMate\",\r", + " \"suffix\": \"CheckMate\"\r", + " },\r", + " \"urls\": [\r", + " {\r", + " \"url\": \"https://checkmate.sg\"\r", + " }\r", + " ],\r", + " \"phones\": [\r", + " {\r", + " \"phone\": \"+1 555-093-3685\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 5000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (CONTACT)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.CONTACT\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Referral\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 36\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_36}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_referral\",\r\n \"title\": \"Get Referral Link\",\r\n \"description\": \"Get referral link to forward to others\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (REFERRAL)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL\");\r", + " const link = pm.variables.get(\"referralLink_USER1\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const referralMessage = BODY_TEXT.replace(\"{{link}}\", link)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": referralMessage,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "009_Scam_Autocategorise", + "item": [ + { + "name": "User sends scam message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 37\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_37}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a scam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SCAM, IMMEDIATE, NOT MATCHED, AUTO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"scam immediate autocategorised no matched response\", function () {\r", + " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SCAM\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_37\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": BODY_TEXT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"Yes\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"No\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + "\r", + " let reply_id_yes = jsonData.body.interactive.action.buttons[0].reply.id;\r", + " let reply_id_no = jsonData.body.interactive.action.buttons[1].reply.id;\r", + " let [, scamInstancePath , ] = reply_id_yes.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(reply_id_yes).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_consent/);\r", + " pm.expect(reply_id_no).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_decline/);\r", + " pm.collectionVariables.set(\"scamInstancePath\", scamInstancePath);\r", + "\r", + " jsonData.body.interactive.action.buttons[0].reply.id = \"ID\"\r", + " jsonData.body.interactive.action.buttons[1].reply.id = \"ID\"\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "010_Spam_Autocategorise", + "item": [ + { + "name": "User sends spam message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 38\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_38}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a spam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SPAM, IMMEDIATE, NOT MATCHED, AUTO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"spam immediate autocategorised no matched response\", function () {\r", + " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_38\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "011_Check_Steps_logging", + "item": [ + { + "name": "[DB CALL] Check steps", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance data updated correctly\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", + " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", + " const expected = [\r", + " \"text_machine_irrelevant_length\",\r", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"feedbackInterim_no\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"satisfactionSurvey_10\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_info\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_contact\",\r", + " \"menu_referral\",\r", + " \"text_machine_scam\",\r", + " \"text_machine_spam\",\r", + " ]\r", + " pm.expect(actions).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "012_New_User_Referral", + "item": [ + { + "name": "Send WhatsApp message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 39\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_39}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that referral count is incremented to 1\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralCount = jsonData.fields.referralCount.integerValue\r", + " pm.expect(parseInt(referralCount)).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + }, + { + "name": "Send 2nd referral message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 40\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_40}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (REFERRAL_INVALID)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"REFERRAL_INVALID response received\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID\");\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_40\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "013_Duplicate_wamid", + "item": [ + { + "name": "[DB CALL] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Info Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.documents.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "Duplicate Info Message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that message count did not increase\", function () {\r", + " var jsonData = pm.response.json();\r", + " const count = pm.variables.get(\"messageCount\")\r", + " pm.expect(jsonData.documents.length).to.eql(count);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Info Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that info instance count did not increase\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "New unsure message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 41\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_41}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a whatever message that will be voted on 24601\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Mocked immediate retry", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_41}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a whatever message that will be voted on 24601\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB QUERY] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that only 1 message was created\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"structuredQuery\": {\r\n \"from\": [{\r\n \"collectionId\": \"messages\"\r\n }],\r\n \"where\": {\r\n \"fieldFilter\": {\r\n \"field\": {\r\n \"fieldPath\": \"text\"\r\n },\r\n \"op\": \"EQUAL\",\r\n \"value\": {\r\n \"stringValue\": \"This is a whatever message that will be voted on 24601\"\r\n }\r\n }\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:runQuery" + ] + } + }, + "response": [] + }, + { + "name": "[DB COLLECTIONGROUP QUERY] Get Count of Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that only 1 instance was created\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"structuredQuery\": {\r\n \"from\": [{\r\n \"collectionId\": \"instances\",\r\n \"allDescendants\": true\r\n }],\r\n \"where\": {\r\n \"fieldFilter\": {\r\n \"field\": {\r\n \"fieldPath\": \"text\"\r\n },\r\n \"op\": \"EQUAL\",\r\n \"value\": {\r\n \"stringValue\": \"This is a whatever message that will be voted on 24601\"\r\n }\r\n }\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:runQuery" + ] + } + }, + "response": [] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "disputedMessagePath", + "value": "" + }, + { + "key": "disputedMessageTextListId", + "value": "" + }, + { + "key": "disputedInstancePath", + "value": "" + }, + { + "key": "scamInstancePath", + "value": "" + }, + { + "key": "spamVoteRequestPath", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "spamMessageId_CHECKER3", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "spamMessageId_CHECKER2", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "spamMessageId_CHECKER1", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "spamMessageId", + "value": "" + }, + { + "key": "spamInstanceId", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "infoMessageId", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "infoInstanceId", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "unsureInstanceId", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "unsureMessageId", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "user_1_referralId", + "value": "" + }, + { + "key": "referralLink_USER1", + "value": "" + }, + { + "key": "referralId_USER1", + "value": "" + }, + { + "key": "messageCounter", + "value": "" + }, + { + "key": "whatsapp_id_1", + "value": "" + }, + { + "key": "whatsapp_id_2", + "value": "" + }, + { + "key": "whatsapp_id_3", + "value": "" + }, + { + "key": "whatsapp_id_4", + "value": "" + }, + { + "key": "whatsapp_id_5", + "value": "" + }, + { + "key": "whatsapp_id_6", + "value": "" + }, + { + "key": "whatsapp_id_7", + "value": "" + }, + { + "key": "whatsapp_id_8", + "value": "" + }, + { + "key": "whatsapp_id_9", + "value": "" + }, + { + "key": "whatsapp_id_10", + "value": "" + }, + { + "key": "whatsapp_id_11", + "value": "" + }, + { + "key": "whatsapp_id_12", + "value": "" + }, + { + "key": "whatsapp_id_13", + "value": "" + }, + { + "key": "whatsapp_id_14", + "value": "" + }, + { + "key": "whatsapp_id_15", + "value": "" + }, + { + "key": "whatsapp_id_39", + "value": "" + }, + { + "key": "whatsapp_id_40", + "value": "" + }, + { + "key": "whatsapp_id_16", + "value": "" + }, + { + "key": "whatsapp_id_17", + "value": "" + }, + { + "key": "whatsapp_id_18", + "value": "" + }, + { + "key": "whatsapp_id_19", + "value": "" + }, + { + "key": "whatsapp_id_20", + "value": "" + }, + { + "key": "whatsapp_id_21", + "value": "" + }, + { + "key": "whatsapp_id_22", + "value": "" + }, + { + "key": "whatsapp_id_23", + "value": "" + }, + { + "key": "whatsapp_id_24", + "value": "" + }, + { + "key": "whatsapp_id_25", + "value": "" + }, + { + "key": "whatsapp_id_26", + "value": "" + }, + { + "key": "whatsapp_id_27", + "value": "" + }, + { + "key": "whatsapp_id_28", + "value": "" + }, + { + "key": "whatsapp_id_29", + "value": "" + }, + { + "key": "whatsapp_id_30", + "value": "" + }, + { + "key": "whatsapp_id_31", + "value": "" + }, + { + "key": "whatsapp_id_32", + "value": "" + }, + { + "key": "whatsapp_id_33", + "value": "" + }, + { + "key": "whatsapp_id_34", + "value": "" + }, + { + "key": "whatsapp_id_35", + "value": "" + }, + { + "key": "whatsapp_id_36", + "value": "" + }, + { + "key": "whatsapp_id_37", + "value": "" + }, + { + "key": "whatsapp_id_38", + "value": "" + }, + { + "key": "messageCount", + "value": "" + }, + { + "key": "whatsapp_id_41", + "value": "" + } + ] +} \ No newline at end of file diff --git a/integration-tests/env.json b/integration-tests/env.json index 587eb4fe..40ae6c11 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -8,6 +8,11 @@ "type": "default", "enabled": true }, + { + "key": "MOCK_WHATSAPP_MSG_ID", + "value": "wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==", + "enabled": true + }, { "key": "FIRESTORE_URL", "value": "http://localhost:18080", @@ -377,4 +382,4 @@ "_postman_variable_scope": "environment", "_postman_exported_at": "2023-04-30T14:17:56.196Z", "_postman_exported_using": "Postman/10.13.0" -} \ No newline at end of file +} diff --git a/integration-tests/package.json b/integration-tests/package.json index 40c5552a..24d39a08 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "newman run checkmate.postman_collection.json -g ./env.json --delay-request 2000", + "test": "newman run checkmate.postman_collection.json -g ./env.json", "update-env": "ts-node ./update-env.ts" }, "author": "",