From 90cb4a680efdc3db69f1223d04b7d40f3b3b99de Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 16:58:49 +0800 Subject: [PATCH 01/13] put telegram handler into pubsub as well --- functions/src/definitions/common/pubsub.ts | 13 ++++- .../eventHandlers/checkerHandlerTelegram.ts | 55 +++++++++++++++++++ ...rHandlers.ts => checkerHandlerWhatsapp.ts} | 6 +- .../{whatsapp.ts => handler.ts} | 36 ++++++++---- .../definitions/webhookHandlers/telegram.ts | 31 ----------- .../webhookHandlers/whatsappTest.ts | 2 +- functions/src/index.ts | 6 +- 7 files changed, 98 insertions(+), 51 deletions(-) create mode 100644 functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts rename functions/src/definitions/eventHandlers/{checkerHandlers.ts => checkerHandlerWhatsapp.ts} (98%) rename functions/src/definitions/webhookHandlers/{whatsapp.ts => handler.ts} (84%) delete mode 100644 functions/src/definitions/webhookHandlers/telegram.ts diff --git a/functions/src/definitions/common/pubsub.ts b/functions/src/definitions/common/pubsub.ts index 5d5be0d0..cf1e212f 100644 --- a/functions/src/definitions/common/pubsub.ts +++ b/functions/src/definitions/common/pubsub.ts @@ -13,7 +13,11 @@ if (env === "PROD") { }) } -async function publishToTopic(topicName: string, messageData: object) { +async function publishToTopic( + topicName: string, + messageData: object, + source: string +) { if (env !== "PROD") { const [exists] = await pubsub.topic(topicName).exists() //Doesn't seem to autocreate in emulator if (!exists) { @@ -23,7 +27,12 @@ async function publishToTopic(topicName: string, messageData: object) { const topic = pubsub.topic(topicName) try { // Publish the message - const messageId = await topic.publishMessage({ json: messageData }) + const messageId = await topic.publishMessage({ + json: messageData, + attributes: { + source: source, + }, + }) functions.logger.log(`Message ${messageId} published.`) } catch (error) { functions.logger.log(`Error publishing message: ${error}`) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts new file mode 100644 index 00000000..1a758e40 --- /dev/null +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -0,0 +1,55 @@ +//TODO TONGYING: Implement webhook here! +import * as admin from "firebase-admin" +import * as functions from "firebase-functions" + +import TelegramBot, { Update } from "node-telegram-bot-api" +import { onMessagePublished } from "firebase-functions/v2/pubsub" + +const TOKEN = String(process.env.TELEGRAM_CHECKER_BOT_TOKEN) +const bot = new TelegramBot(TOKEN) + +// More bot handlers can go here... + +// General message handler +bot.on("message", (msg) => { + if (msg.text && !msg.text.startsWith("/")) { + // Ignore commands as they are handled separately + const chatId = msg.chat.id + // Echo the message text back to the same chat + bot.sendMessage(chatId, `You said: ${msg.text}`) + } +}) + +const checkerHandlerTelegram = async function (body: Update) { + bot.processUpdate(body) + return +} + +const onCheckerPublishTelegram = onMessagePublished( + { + topic: "checkerEvents", + secrets: [ + "TYPESENSE_TOKEN", + "ML_SERVER_TOKEN", + "TELEGRAM_REPORT_BOT_TOKEN", + "TELEGRAM_CHECKER_BOT_TOKEN", + ], + }, + async (event) => { + if ( + event.data.message.json && + event.data.message.attributes.source === "telegram" + ) { + functions.logger.log(`Processing ${event.data.message.messageId}`) + await checkerHandlerTelegram(event.data.message.json) + } else { + if (!event.data.message.json) { + functions.logger.warn( + `Unknown message type for messageId ${event.data.message.messageId})` + ) + } + } + } +) + +export { onCheckerPublishTelegram } diff --git a/functions/src/definitions/eventHandlers/checkerHandlers.ts b/functions/src/definitions/eventHandlers/checkerHandlerWhatsapp.ts similarity index 98% rename from functions/src/definitions/eventHandlers/checkerHandlers.ts rename to functions/src/definitions/eventHandlers/checkerHandlerWhatsapp.ts index f5e0bc4e..0748763c 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlers.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerWhatsapp.ts @@ -463,8 +463,10 @@ const onCheckerPublish = onMessagePublished( }, async (event) => { if (event.data.message.json) { - functions.logger.log(`Processing ${event.data.message.messageId}`) - await checkerHandlerWhatsapp(event.data.message.json) + if (event.data.message.attributes.source === "whatsapp") { + functions.logger.log(`Processing ${event.data.message.messageId}`) + await checkerHandlerWhatsapp(event.data.message.json) + } } else { functions.logger.warn( `Unknown message type for messageId ${event.data.message.messageId})` diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/handler.ts similarity index 84% rename from functions/src/definitions/webhookHandlers/whatsapp.ts rename to functions/src/definitions/webhookHandlers/handler.ts index 7b7b0455..5062051b 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/handler.ts @@ -10,7 +10,8 @@ import { Request, Response } from "express" const runtimeEnvironment = defineString("ENVIRONMENT") -const webhookPath = process.env.WEBHOOK_PATH +const webhookPathWhatsapp = process.env.WEBHOOK_PATH_WHATSAPP +const webhookPathTelegram = process.env.WEBHOOK_PATH_TELEGRAM const ingressSetting = process.env.ENVIRONMENT === "PROD" ? "ALLOW_INTERNAL_AND_GCLB" : "ALLOW_ALL" @@ -19,7 +20,7 @@ if (!admin.apps.length) { } const app = express() -const getHandler = async (req: Request, res: Response) => { +const getHandlerWhatsapp = async (req: Request, res: Response) => { /** * UPDATE YOUR VERIFY TOKEN *This will be the Verify Token value when you set up webhook @@ -46,7 +47,7 @@ const getHandler = async (req: Request, res: Response) => { } } -const postHandler = async (req: Request, res: Response) => { +const postHandlerWhatsapp = async (req: Request, res: Response) => { if (req.body.object) { if (req?.body?.entry?.[0]?.changes?.[0]?.value) { let value = req.body.entry[0].changes[0].value @@ -94,11 +95,11 @@ const postHandler = async (req: Request, res: Response) => { phoneNumberId === checkerPhoneNumberId ) { //put into checker queue - await publishToTopic("checkerEvents", message) + await publishToTopic("checkerEvents", message, "whatsapp") } if (phoneNumberId === userPhoneNumberId) { //put into user queue - await publishToTopic("userEvents", message) + await publishToTopic("userEvents", message, "whatsapp") } } res.sendStatus(200) @@ -141,15 +142,25 @@ const postHandler = async (req: Request, res: Response) => { } } +const postHandlerTelegram = async (req: Request, res: Response) => { + if ( + req.header("x-telegram-bot-api-secret-token") === + process.env.TELEGRAM_WEBHOOK_TOKEN + ) { + await publishToTopic("checkerEvents", req.body, "telegram") + } else { + functions.logger.warn( + "Telegram handler endpoint was called from unexpected source" + ) + } + res.sendStatus(200) +} + // Accepts POST requests at /{webhookPath} endpoint -app.post(`/${webhookPath}`, postHandler) -app.get(`/${webhookPath}`, getHandler) +app.post(`/${webhookPathWhatsapp}`, postHandlerWhatsapp) +app.get(`/${webhookPathWhatsapp}`, getHandlerWhatsapp) -app.post("/telegram", async (req, res) => { - const db = admin.firestore() - console.log(JSON.stringify(req.body)) - res.sendStatus(200) -}) +app.post(`/${webhookPathTelegram}`, postHandlerTelegram) // Accepts GET requests at the /webhook endpoint. You need this URL to setup webhook initially. // info on verification request payload: https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests @@ -163,6 +174,7 @@ const webhookHandlerV2 = onRequest( "VERIFY_TOKEN", "WHATSAPP_CHECKERS_WABA_ID", "WHATSAPP_USERS_WABA_ID", + "TELEGRAM_WEBHOOK_TOKEN", ], }, app diff --git a/functions/src/definitions/webhookHandlers/telegram.ts b/functions/src/definitions/webhookHandlers/telegram.ts deleted file mode 100644 index 60291b09..00000000 --- a/functions/src/definitions/webhookHandlers/telegram.ts +++ /dev/null @@ -1,31 +0,0 @@ -//TODO TONGYING: Implement webhook here! -import * as admin from "firebase-admin" -import * as functions from "firebase-functions" -import express from "express" -import TelegramBot from "node-telegram-bot-api" -import { onRequest } from "firebase-functions/v2/https" - -const TOKEN = String(process.env.TELEGRAM_CHECKER_BOT_TOKEN) -const bot = new TelegramBot(TOKEN) - -const app = express() - -bot.onText(/\/start/, (message) => { - bot.sendMessage(message.chat.id, "Welcome to the bot!") -}) - -// More bot handlers can go here... - -app.post("/", async (req, res) => { - bot.processUpdate(req.body) - res.sendStatus(200) -}) - -const telegramHandler = onRequest( - { - secrets: ["TELEGRAM_CHECKER_BOT_TOKEN"], - }, - app -) - -export { telegramHandler } diff --git a/functions/src/definitions/webhookHandlers/whatsappTest.ts b/functions/src/definitions/webhookHandlers/whatsappTest.ts index 1e841ed9..48e1d129 100644 --- a/functions/src/definitions/webhookHandlers/whatsappTest.ts +++ b/functions/src/definitions/webhookHandlers/whatsappTest.ts @@ -1,4 +1,4 @@ -import { app } from "./whatsapp" +import { app } from "./handler" import { agent } from "supertest" process.env.VERIFY_TOKEN = "testToken" diff --git a/functions/src/index.ts b/functions/src/index.ts index 5a3b12ee..601ec172 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -7,13 +7,13 @@ export { onInstanceCreate } from "./definitions/eventHandlers/onInstanceCreate" export { onInstanceDelete } from "./definitions/eventHandlers/onInstanceDelete" export { onInstanceUpdate } from "./definitions/eventHandlers/onInstanceUpdate" export { onMessageUpdate } from "./definitions/eventHandlers/onMessageUpdate" -export { webhookHandlerV2 } from "./definitions/webhookHandlers/whatsapp" +export { webhookHandlerV2 } from "./definitions/webhookHandlers/handler" export { onVoteRequestUpdate } from "./definitions/eventHandlers/onVoteRequestUpdate" export { healthcheck } from "./definitions/healthcheck" export { onMessageWrite } from "./definitions/eventHandlers/updateTypesense" export { onUserPublish } from "./definitions/eventHandlers/userHandlers" -export { onCheckerPublish } from "./definitions/eventHandlers/checkerHandlers" +export { onCheckerPublish } from "./definitions/eventHandlers/checkerHandlerWhatsapp" export { telegramAuthHandler } from "./definitions/api/authentication" -export { telegramHandler } from "./definitions/webhookHandlers/telegram" +export { onCheckerPublishTelegram } from "./definitions/eventHandlers/checkerHandlerTelegram" export { apiHandler } from "./definitions/api/api" export { batchJobs } From 049f0defefaa0e169f83962187336d5a6f80e97b Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 11:42:21 +0800 Subject: [PATCH 02/13] updated npm run serve --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05c1b5e5..be4fb26d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,6 @@ "scripts": { "lint": "eslint . --ext js,jsx,ts,tsx --fix", "postinstall": "cd functions && npm install && cd ../checkers-app && npm install", - "serve": "firebase emulators:start --import ./local-data --export-on-exit ./local-data" + "serve": "firebase emulators:start --project checkmate-uat --import ./local-data --export-on-exit ./local-data" } } From 5bef4c5949aada7a56e6a761ed2457c302ec1895 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:12:07 +0800 Subject: [PATCH 03/13] removed feedback from interim responses --- .../common/parameters/userResponses.json | 16 +--- .../src/definitions/common/responseUtils.ts | 85 ++----------------- .../definitions/eventHandlers/userHandlers.ts | 5 -- integration-tests/env.json | 36 +------- 4 files changed, 13 insertions(+), 129 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 5134f414..0ecac0a6 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -76,8 +76,8 @@ "cn": "另外{{second}}%的人认为这条短信{{category}}{{info_placeholder}}。" }, "INTERIM_TEMPLATE": { - "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think that this is {{prelim_assessment}}{{info_placeholder}}. \n\nNOTE: This is a *preliminary result*. We aim to provide you with a more credible final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.{{get_feedback}}", - "cn": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。{{get_feedback}}" + "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think that this is {{prelim_assessment}}{{info_placeholder}}. \n\nNOTE: This is a *preliminary result*. We aim to provide you with a more credible final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.", + "cn": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。" }, "INFO_PLACEHOLDER": { "en": ", with an average score of {{score}} on a scale of 0-5 (5 = completely true)", @@ -87,22 +87,10 @@ "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. Unfortunately, our CheckMates either have not reached any clear consensus, or are still unsure how to assess the message at this time.\n\nIf you haven't done so, you could send in the message with more context, e.g. sending in a screenshot containing the sender's number.", "cn": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。不幸的是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。" }, - "INTERIM_FEEDBACK": { - "en": "\n\nThanks for trusting CheckMate! 👋🏼 If this interim update was useful to you, we'd appreciate it if you'd let us know by tapping on “Yes, it's useful” below. Otherwise, tap on “No, it's not” to continue waiting for the final result. Either way, you can continue to request more updates as more votes come in.", - "cn": "感谢您对查友的信任!👋🏼 如果这个初步结果对您有帮助,请点击“有帮助”。否则,请点击“没帮助”以继续等待最终结果。您可以在最终结果发布之前随时要求最新的初步结果。" - }, "INTERIM_PROMPT": { "en": "Thanks for waiting! We are currently still pending the assessment from some of our network of trusted CheckMate volunteers and will only be able to provide a credible final result once enough votes have come in. \n\nYou may press the button below *to get an interim update of the preliminary result*. However, do note that there may be discrepancies between the preliminary and the final result, and *the preliminary result should be interpreted with caution*. We appreciate your patience and hope to deliver the final result to you soon! 💪🏼", "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼" }, - "INTERIM_USEFUL": { - "en": "Thanks for your valuable feedback! We will provide you with the final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.\n\nIn the meantime, if you'd like another update after more votes come in, just tap the button below to request one.", - "cn": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。" - }, - "INTERIM_NOT_USEFUL": { - "en": "Sorry to hear that, but thanks anyway for your valuable feedback! We will provide you with the final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.\n\nIf you'd like still another update after more votes come in, just tap the button below to request one.", - "cn": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,尽快为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。" - }, "ALREADY_REPLIED": { "en": "CheckMate has already provided a final response to this message.", "cn": "查友已经对这条短信做出最终回应。" diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index 3aa18535..13fd54dd 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -76,43 +76,6 @@ function getInfoLiner(truthScore: null | number, infoPlaceholder: string) { ) } -async function respondToInterimFeedback( - instancePath: string, - isUseful: string -) { - const instanceRef = db.doc(instancePath) - const instanceSnap = await instanceRef.get() - const data = instanceSnap.data() - const from = data?.from ?? null - const responses = await getResponsesObj("user", from) - if (!data) { - functions.logger.log("Missing data in respondToInterimFeedback") - return - } - const buttons = [ - { - type: "reply", - reply: { - id: `sendInterim_${instancePath}`, - title: responses.BUTTON_ANOTHER_UPDATE, - }, - }, - ] - let response - switch (isUseful) { - case "yes": - response = responses?.INTERIM_USEFUL - await instanceRef.update({ isInterimUseful: true }) - break - default: - response = responses?.INTERIM_NOT_USEFUL - await instanceRef.update({ isInterimUseful: false }) - break - } - - await sendWhatsappButtonMessage("user", from, response, buttons, data.id) -} - async function respondToRationalisationFeedback( instancePath: string, isUseful: string @@ -558,18 +521,13 @@ async function sendInterimUpdate(instancePath: string) { return } const updateObj: { - isInterimUseful?: boolean isMeaningfulInterimReplySent?: boolean prelimAssessment?: string isInterimReplySent?: boolean } = {} let finalResponse - let isFirstMeaningfulReply = false if (primaryCategory === "unsure") { finalResponse = responses.INTERIM_TEMPLATE_UNSURE - if (data.isInterimUseful === null) { - updateObj.isInterimUseful = false - } if (data.isMeaningfulInterimReplySent === null) { updateObj.isMeaningfulInterimReplySent = false } @@ -577,48 +535,22 @@ async function sendInterimUpdate(instancePath: string) { finalResponse = responses.INTERIM_TEMPLATE if (!data.isMeaningfulInterimReplySent) { updateObj.isMeaningfulInterimReplySent = true - isFirstMeaningfulReply = true } } - const getFeedback = - (data.isInterimUseful === null || isFirstMeaningfulReply) && - primaryCategory !== "unsure" && - FEEDBACK_FEATURE_FLAG finalResponse = finalResponse .replace("{{prelim_assessment}}", prelimAssessment) .replace("{{info_placeholder}}", infoPlaceholder) .replace("{{%voted}}", percentageVoted) - .replace("{{get_feedback}}", getFeedback ? responses.INTERIM_FEEDBACK : "") - let buttons - if (getFeedback) { - buttons = [ - { - type: "reply", - reply: { - id: `feedbackInterim_${instancePath}_yes`, - title: responses.BUTTON_USEFUL, - }, - }, - { - type: "reply", - reply: { - id: `feedbackInterim_${instancePath}_no`, - title: responses.BUTTON_NOT_USEFUL, - }, - }, - ] - } else { - buttons = [ - { - type: "reply", - reply: { - id: `sendInterim_${instancePath}`, - title: responses.BUTTON_ANOTHER_UPDATE, - }, + const buttons = [ + { + type: "reply", + reply: { + id: `sendInterim_${instancePath}`, + title: responses.BUTTON_ANOTHER_UPDATE, }, - ] - } + }, + ] await sendWhatsappButtonMessage("user", from, finalResponse, buttons, data.id) if (!instanceSnap.get("isInterimReplySent")) { updateObj.isInterimReplySent = true @@ -917,7 +849,6 @@ export { sendInterimUpdate, sendVotingStats, sendReferralMessage, - respondToInterimFeedback, sendRationalisation, respondToRationalisationFeedback, updateLanguageAndSendMenu, diff --git a/functions/src/definitions/eventHandlers/userHandlers.ts b/functions/src/definitions/eventHandlers/userHandlers.ts index a8b7da9b..f3739d35 100644 --- a/functions/src/definitions/eventHandlers/userHandlers.ts +++ b/functions/src/definitions/eventHandlers/userHandlers.ts @@ -20,7 +20,6 @@ import { sendInterimUpdate, sendVotingStats, sendReferralMessage, - respondToInterimFeedback, sendRationalisation, respondToRationalisationFeedback, updateLanguageAndSendMenu, @@ -753,10 +752,6 @@ async function onButtonReply(messageObj: Message, platform = "whatsapp") { ;[instancePath] = rest await sendInterimUpdate(instancePath) break - case "feedbackInterim": - ;[instancePath, selection] = rest - await respondToInterimFeedback(instancePath, selection) - break case "rationalisation": ;[instancePath] = rest await sendRationalisation(instancePath) diff --git a/integration-tests/env.json b/integration-tests/env.json index 091aa869..087667fa 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -315,12 +315,12 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.en", - "value": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think that this is {{prelim_assessment}}{{info_placeholder}}. \n\nNOTE: This is a *preliminary result*. We aim to provide you with a more credible final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.{{get_feedback}}", + "value": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think that this is {{prelim_assessment}}{{info_placeholder}}. \n\nNOTE: This is a *preliminary result*. We aim to provide you with a more credible final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.cn", - "value": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。{{get_feedback}}", + "value": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。", "enabled": true }, { @@ -333,16 +333,6 @@ "value": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。不幸的是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。", "enabled": true }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en", - "value": "\n\nThanks for trusting CheckMate! 👋🏼 If this interim update was useful to you, we'd appreciate it if you'd let us know by tapping on “Yes, it's useful” below. Otherwise, tap on “No, it's not” to continue waiting for the final result. Either way, you can continue to request more updates as more votes come in.", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.cn", - "value": "感谢您对查友的信任!👋🏼 如果这个初步结果对您有帮助,请点击“有帮助”。否则,请点击“没帮助”以继续等待最终结果。您可以在最终结果发布之前随时要求最新的初步结果。", - "enabled": true - }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT.en", "value": "Thanks for waiting! We are currently still pending the assessment from some of our network of trusted CheckMate volunteers and will only be able to provide a credible final result once enough votes have come in. \n\nYou may press the button below *to get an interim update of the preliminary result*. However, do note that there may be discrepancies between the preliminary and the final result, and *the preliminary result should be interpreted with caution*. We appreciate your patience and hope to deliver the final result to you soon! 💪🏼", @@ -353,26 +343,6 @@ "value": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼", "enabled": true }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.en", - "value": "Thanks for your valuable feedback! We will provide you with the final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.\n\nIn the meantime, if you'd like another update after more votes come in, just tap the button below to request one.", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.cn", - "value": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL.en", - "value": "Sorry to hear that, but thanks anyway for your valuable feedback! We will provide you with the final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.\n\nIf you'd like still another update after more votes come in, just tap the button below to request one.", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL.cn", - "value": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,尽快为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。", - "enabled": true - }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED.en", "value": "CheckMate has already provided a final response to this message.", @@ -990,7 +960,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.cn", - "value": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。", + "value": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n", "enabled": true }, { From 3afd95e94ae733b64f16ce2143e2f5a14180c140 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:13:45 +0800 Subject: [PATCH 04/13] removed isInterimUseful field --- functions/src/definitions/eventHandlers/userHandlers.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/src/definitions/eventHandlers/userHandlers.ts b/functions/src/definitions/eventHandlers/userHandlers.ts index f3739d35..fb8b19ed 100644 --- a/functions/src/definitions/eventHandlers/userHandlers.ts +++ b/functions/src/definitions/eventHandlers/userHandlers.ts @@ -400,7 +400,6 @@ async function newTextInstanceHandler({ isFrequentlyForwarded: isFrequentlyForwarded, //boolean, taken from webhook object isReplied: false, isInterimPromptSent: null, - isInterimUseful: null, isInterimReplySent: null, isMeaningfulInterimReplySent: null, isRationalisationSent: null, @@ -679,7 +678,6 @@ async function newImageInstanceHandler({ isFrequentlyForwarded: isFrequentlyForwarded, //boolean, taken from webhook object isReplied: false, isInterimPromptSent: null, - isInterimUseful: null, isInterimReplySent: null, isMeaningfulInterimReplySent: null, isRationalisationSent: null, From dedf1ffda00be8d7ef7f5d7f64906810f98380a1 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:16:43 +0800 Subject: [PATCH 05/13] changed message --- .../src/definitions/common/parameters/userResponses.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 0ecac0a6..b00eda28 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -108,8 +108,8 @@ "cn": "Hello and welcome to CheckMate! We're glad you've joined us to battle scams and misinformation😊." }, "NEW_USER_PREFIX_CN": { - "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", - "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n" + "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n", + "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n\n" }, "LANGUAGE_SELECTION": { "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。", From 18e58c444320c1bbd033ac52339d6ab488babebb Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:19:07 +0800 Subject: [PATCH 06/13] modified env.json --- integration-tests/env.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/env.json b/integration-tests/env.json index 087667fa..4165905a 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -955,12 +955,12 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en", - "value": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", + "value": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.cn", - "value": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n", + "value": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n\n", "enabled": true }, { From 8fd81cd2ed068774926f7cf2f57297782e5f01db Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:30:47 +0800 Subject: [PATCH 07/13] updated userResponses --- .../common/parameters/userResponses.json | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 6850da4c..10636c2c 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -13,7 +13,7 @@ }, "ERROR": { "en": "Oops, we encountered an error assessing this message.\n\nYou can try sending the message in again, or report the error via our form at https://bit.ly/checkmate-feedback. Sorry about that! 😔", - "cn": "抱歉,查友在评估您提供的短信时发生问题。\n\n欢迎您稍后重试,或者通过这份表格向我们反馈:https://bit.ly/checkmate-feedback。对此造成的不便,我们非常抱歉!😔" + "cn": "抱歉,查友在评估您提供的短信时发生了问题。\n\n欢迎您稍后重试,或者通过这份表格向我们反馈:https://bit.ly/checkmate-feedback。对此造成的不便,我们非常抱歉!😔" }, "MESSAGE_NOT_YET_ASSESSED": { "en": "Hello! 👋 Thanks for sending this in! Our *CheckMates🕵🏻 will review this* and *provide the results soon*.", @@ -29,7 +29,7 @@ }, "SPAM": { "en": "{{thanks}}{{matched}}{{methodology}}spam!🚧{{image_caveat}}\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", - "cn": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然它看似无害,但仍然请您保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然它看似无害,但请仍然保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!" }, "LEGITIMATE": { "en": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}}\n\nThank you for keeping Singapore safe!", @@ -76,8 +76,8 @@ "cn": "另外{{second}}%的人认为这条短信{{category}}{{info_placeholder}}。" }, "INTERIM_TEMPLATE": { - "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think that this is {{prelim_assessment}}{{info_placeholder}}. \n\nNOTE: This is a *preliminary result*. We aim to provide you with a more credible final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.{{get_feedback}}", - "cn": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。{{get_feedback}}" + "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think that this is {{prelim_assessment}}{{info_placeholder}}. \n\nNOTE: This is a *preliminary result*. We aim to provide you with a more credible final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.", + "cn": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。" }, "INFO_PLACEHOLDER": { "en": ", with an average score of {{score}} on a scale of 0-5 (5 = completely true)", @@ -85,23 +85,11 @@ }, "INTERIM_TEMPLATE_UNSURE": { "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. Unfortunately, our CheckMates either have not reached any clear consensus, or are still unsure how to assess the message at this time.\n\nIf you haven't done so, you could send in the message with more context, e.g. sending in a screenshot containing the sender's number.", - "cn": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。不幸的是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。" - }, - "INTERIM_FEEDBACK": { - "en": "\n\nThanks for trusting CheckMate! 👋🏼 If this interim update was useful to you, we'd appreciate it if you'd let us know by tapping on “Yes, it's useful” below. Otherwise, tap on “No, it's not” to continue waiting for the final result. Either way, you can continue to request more updates as more votes come in.", - "cn": "感谢您对查友的信任!👋🏼 如果这个初步结果对您有帮助,请点击“有帮助”。否则,请点击“没帮助”以继续等待最终结果。您可以在最终结果发布之前随时要求最新的初步结果。" + "cn": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。但是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。" }, "INTERIM_PROMPT": { "en": "Thanks for waiting! We are currently still pending the assessment from some of our network of trusted CheckMate volunteers and will only be able to provide a credible final result once enough votes have come in. \n\nYou may press the button below *to get an interim update of the preliminary result*. However, do note that there may be discrepancies between the preliminary and the final result, and *the preliminary result should be interpreted with caution*. We appreciate your patience and hope to deliver the final result to you soon! 💪🏼", - "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼" - }, - "INTERIM_USEFUL": { - "en": "Thanks for your valuable feedback! We will provide you with the final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.\n\nIn the meantime, if you'd like another update after more votes come in, just tap the button below to request one.", - "cn": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。" - }, - "INTERIM_NOT_USEFUL": { - "en": "Sorry to hear that, but thanks anyway for your valuable feedback! We will provide you with the final result as soon as more of our CheckMates have voted, or when 24 hours has lapsed since you sent in your message.\n\nIf you'd like still another update after more votes come in, just tap the button below to request one.", - "cn": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,尽快为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。" + "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击“获取初步结果”。请注意,初步结果和最终结果可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并会尽快提供最终结果!💪🏼" }, "ALREADY_REPLIED": { "en": "CheckMate has already provided a final response to this message.", @@ -113,15 +101,15 @@ }, "MENU": { "en": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"Menu\" below to see what CheckMate can do! 👈\n\nDo note that CheckMate *is designed to check dubious messages you send in. It cannot converse freely with you*.\n\nAnytime you need a refresher on what CheckMate can do, type \"menu\" to get here again! 😊", - "cn": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友仅能评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊" + "cn": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友只评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊" }, "NEW_USER_PREFIX_EN": { "en": "Hello and welcome to CheckMate! We're glad you've joined us to battle scams and misinformation😊.", "cn": "Hello and welcome to CheckMate! We're glad you've joined us to battle scams and misinformation😊." }, "NEW_USER_PREFIX_CN": { - "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", - "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。" + "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n", + "cn": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n" }, "LANGUAGE_SELECTION": { "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。", @@ -141,7 +129,7 @@ }, "PROCEED_TO_SEND": { "en": "Nice! Just send/forward us the message. We'll help you check and/or report it! ✅✅\n\nIf you like, you can also send in screenshots 📷 or other images 🖼️! This can help to capture the sender's number, or a full conversation, which could help our CheckMates' assessment.\n\nOne last thing: by continuing to use CheckMate, you're agreeing to our privacy policy, which can be found at https://checkmate.sg/privacy-policy. In short, we only collect the messages sent to us and your number to facilitate a response!", - "cn": "好的!您只需将短信发送给查友,我们会对其进行评估!✅✅\n\n除了文字信息,您也可以发送截图📷或其他图片🖼️!这有助于查哥查妹通过发信人号码或完整的对话内容做出判断。\n\n最后,使用查友即表示您已同意我们的隐私政策。您可在 https://checkmate.sg/privacy-policy 查看我们的隐私政策。基本上,我们只收集您发送的消息以及您的手机号码,以便回复您!" + "cn": "好的!您只需将短信发送给查友,我们会对此进行评估!✅✅\n\n除了文字信息,您也可以发送截图📷或其他图片🖼️!这有助于查哥查妹通过发信人号码或完整的对话内容做出评判。\n\n最后,使用查友即表示您已同意我们的隐私政策。您可在 https://checkmate.sg/privacy-policy 查看我们的隐私政策。基本上,我们只收集您发送的消息以及您的手机号码,以便回复您!" }, "HOW_TO": { "en": "Check out https://youtube.com/shorts/gFeO_qFOchs?feature=share to see how CheckMate works!\n\nDone? You're now ready to use CheckMate! Let's do our part in the fight against scams and misinformation! 💪", @@ -168,12 +156,12 @@ "cn": "您是否已经开始使用查友?点击此链接进行注册!{{link}}" }, "REFERRAL_PREPOPULATED_PREFIX": { - "en": "Welcome to CheckMate! Send in this entire message (including the code) to get started, and credit your friend with your referral. Code:", - "cn": "欢迎使用查友!请发送这条短信(包括推荐人代码)以开始使用。代码:" + "en": "Welcome to CheckMate! Send in this message to get started, and credit your friend with your referral.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", + "cn": "Welcome to CheckMate! Send in this message to get started, and credit your friend with your referral.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:" }, "GENERIC_PREPOPULATED_PREFIX": { - "en": "Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:", - "cn": "欢迎使用查友!请发送这条短信(包括代码)以开始使用。代码:" + "en": "Welcome to CheckMate! Send in this message to get started.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", + "cn": "Welcome to CheckMate! Send in this message to get started.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:" }, "REFERRAL_INVALID": { "en": "Sorry, referrals are only credited upon your first interaction with CheckMate.", From df14443f306e3eaada4d99e88087a60fd4ac6c66 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:31:52 +0800 Subject: [PATCH 08/13] updated tests --- .../checkmate.postman_collection.json | 854 +++--------------- 1 file changed, 104 insertions(+), 750 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index d8d70522..87dd3ebf 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -2974,7 +2974,7 @@ "response": [] }, { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", @@ -2987,12 +2987,10 @@ " 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\");\r", - " const BUTTON_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en\");\r", - " const BUTTON_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en\")\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\")\r", " const expected = {\r", " \"hostname\": \"resultserver\",\r", " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", @@ -3011,15 +3009,8 @@ " {\r", " \"type\": \"reply\",\r", " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": BUTTON_USEFUL\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": BUTTON_NOT_USEFUL\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": BUTTON_ANOTHER_UPDATE\r", " }\r", " }\r", " ]\r", @@ -3065,7 +3056,7 @@ "response": [] }, { - "name": "Press button \"Yes it's useful\"", + "name": "Press button to get interim update again", "event": [ { "listen": "test", @@ -3083,7 +3074,7 @@ "script": { "exec": [ "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 14\r", + "let messageCounter = 15\r", "\r", "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", "\r", @@ -3105,7 +3096,7 @@ "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}", + "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" @@ -3128,22 +3119,23 @@ "response": [] }, { - "name": "INTERIM_USEFUL", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + "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_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.en\");\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.en\");\r", " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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", @@ -3155,7 +3147,7 @@ " \"interactive\": {\r", " \"type\": \"button\",\r", " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", + " \"text\": interimResponse\r", " },\r", " \"action\": {\r", " \"buttons\": [\r", @@ -3176,6 +3168,7 @@ " \"method\": \"POST\"\r", " }\r", " var jsonData = pm.response.json();\r", + " \r", " pm.expect(jsonData).to.eql(expected);\r", "});" ], @@ -3206,9 +3199,14 @@ } }, "response": [] - }, + } + ] + }, + { + "name": "005c_2nd Voter Legitimate", + "item": [ { - "name": "Press button \"No it's not\"", + "name": "Second checker clicks yes", "event": [ { "listen": "test", @@ -3220,15 +3218,6 @@ ], "type": "text/javascript" } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } } ], "request": { @@ -3236,7 +3225,7 @@ "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}", + "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" @@ -3259,53 +3248,27 @@ "response": [] }, { - "name": "INTERIM_NOT_USEFUL", + "name": "Message to Check Sent", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + "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 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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_ANOTHER_UPDATE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\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", - " \"method\": \"POST\"\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", "});" @@ -3339,120 +3302,68 @@ "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", + "name": "L1_ASSESSMENT_PROMPT", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", + "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 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\")\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\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_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\": BUTTON_ANOTHER_UPDATE\r", - " }\r", - " }\r", - " ]\r", - " }\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", - " \"context\": {\r", - " \"message_id\": wamid\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", - " \"method\": \"POST\"\r", - " }\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", " var jsonData = pm.response.json();\r", - " \r", " pm.expect(jsonData).to.eql(expected);\r", "});" ], @@ -3463,7 +3374,7 @@ "listen": "prerequest", "script": { "exec": [ - "setTimeout(() => {}, 3000);" + "" ], "type": "text/javascript" } @@ -3483,14 +3394,9 @@ } }, "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ + }, { - "name": "Second checker clicks yes", + "name": "Second checker selects \"It's something else\"", "event": [ { "listen": "test", @@ -3509,7 +3415,7 @@ "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}", + "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" @@ -3532,213 +3438,23 @@ "response": [] }, { - "name": "Message to Check Sent", + "name": "HOLD_FOR_L2_CATEGORISATION", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", + "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\": \"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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", " \"preview_url\": false\r", " },\r", " \"to\": CHECKER_PHONE_NUMBERS[1],\r", @@ -5349,7 +5065,6 @@ " },\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", "});" @@ -6468,7 +6183,7 @@ "response": [] }, { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", @@ -6481,12 +6196,10 @@ " 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\");\r", - " const BUTTON_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en\");\r", - " const BUTTON_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en\")\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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 interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\")\r", " const expected = {\r", " \"hostname\": \"resultserver\",\r", " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", @@ -6505,15 +6218,8 @@ " {\r", " \"type\": \"reply\",\r", " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": BUTTON_USEFUL\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": BUTTON_NOT_USEFUL\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": BUTTON_ANOTHER_UPDATE\r", " }\r", " }\r", " ]\r", @@ -6557,55 +6263,6 @@ } }, "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances", - "{{infoInstanceId}}" - ] - } - }, - "response": [] } ] }, @@ -8938,55 +8595,6 @@ } }, "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] } ] }, @@ -9223,7 +8831,7 @@ "response": [] }, { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", @@ -9237,211 +8845,9 @@ " 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\")\r", - " const BUTTON_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en\");\r", - " const BUTTON_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"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\": BUTTON_USEFUL\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": BUTTON_NOT_USEFUL\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " console.log(JSON.stringify(expected,null,2))\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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\r", " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"legitimate✅\").replace(\"{{info_placeholder}}\",\"\")\r", " const expected = {\r", " \"hostname\": \"resultserver\",\r", " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", @@ -9453,7 +8859,7 @@ " \"interactive\": {\r", " \"type\": \"button\",\r", " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", + " \"text\": interimResponse\r", " },\r", " \"action\": {\r", " \"buttons\": [\r", @@ -9474,6 +8880,7 @@ " \"method\": \"POST\"\r", " }\r", " var jsonData = pm.response.json();\r", + " \r", " pm.expect(jsonData).to.eql(expected);\r", "});" ], @@ -9504,55 +8911,6 @@ } }, "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] } ] }, @@ -10417,7 +9775,6 @@ " },\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", "});" @@ -12662,8 +12019,6 @@ " \"menu_dispute\",\r", " \"text_machine_unsure\",\r", " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", " \"sendInterim\",\r", " \"sendInterim\",\r", " \"satisfactionSurvey_10\",\r", @@ -12675,7 +12030,6 @@ " \"text_machine_unsure\",\r", " \"sendInterim\",\r", " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", " \"sendInterim\",\r", " \"votingResults\",\r", " \"text_menu\",\r", From 57d7d899c2c3296bdaa8ce8567b7f16892226879 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:35:37 +0800 Subject: [PATCH 09/13] updated userresponses --- .../common/parameters/userResponses.json | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index b00eda28..c1f62232 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -13,7 +13,7 @@ }, "ERROR": { "en": "Oops, we encountered an error assessing this message.\n\nYou can try sending the message in again, or report the error via our form at https://bit.ly/checkmate-feedback. Sorry about that! 😔", - "cn": "抱歉,查友在评估您提供的短信时发生问题。\n\n欢迎您稍后重试,或者通过这份表格向我们反馈:https://bit.ly/checkmate-feedback。对此造成的不便,我们非常抱歉!😔" + "cn": "抱歉,查友在评估您提供的短信时发生了问题。\n\n欢迎您稍后重试,或者通过这份表格向我们反馈:https://bit.ly/checkmate-feedback。对此造成的不便,我们非常抱歉!😔" }, "MESSAGE_NOT_YET_ASSESSED": { "en": "Hello! 👋 Thanks for sending this in! Our *CheckMates🕵🏻 will review this* and *provide the results soon*.", @@ -29,7 +29,7 @@ }, "SPAM": { "en": "{{thanks}}{{matched}}{{methodology}}spam!🚧{{image_caveat}}\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", - "cn": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然它看似无害,但仍然请您保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然它看似无害,但请仍然保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!" }, "LEGITIMATE": { "en": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}}\n\nThank you for keeping Singapore safe!", @@ -85,11 +85,11 @@ }, "INTERIM_TEMPLATE_UNSURE": { "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. Unfortunately, our CheckMates either have not reached any clear consensus, or are still unsure how to assess the message at this time.\n\nIf you haven't done so, you could send in the message with more context, e.g. sending in a screenshot containing the sender's number.", - "cn": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。不幸的是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。" + "cn": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。但是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。" }, "INTERIM_PROMPT": { "en": "Thanks for waiting! We are currently still pending the assessment from some of our network of trusted CheckMate volunteers and will only be able to provide a credible final result once enough votes have come in. \n\nYou may press the button below *to get an interim update of the preliminary result*. However, do note that there may be discrepancies between the preliminary and the final result, and *the preliminary result should be interpreted with caution*. We appreciate your patience and hope to deliver the final result to you soon! 💪🏼", - "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼" + "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击“获取初步结果”。请注意,初步结果和最终结果可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并会尽快提供最终结果!💪🏼" }, "ALREADY_REPLIED": { "en": "CheckMate has already provided a final response to this message.", @@ -101,7 +101,7 @@ }, "MENU": { "en": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"Menu\" below to see what CheckMate can do! 👈\n\nDo note that CheckMate *is designed to check dubious messages you send in. It cannot converse freely with you*.\n\nAnytime you need a refresher on what CheckMate can do, type \"menu\" to get here again! 😊", - "cn": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友仅能评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊" + "cn": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友只评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊" }, "NEW_USER_PREFIX_EN": { "en": "Hello and welcome to CheckMate! We're glad you've joined us to battle scams and misinformation😊.", @@ -109,7 +109,7 @@ }, "NEW_USER_PREFIX_CN": { "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n", - "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n\n" + "cn": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n" }, "LANGUAGE_SELECTION": { "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。", @@ -129,7 +129,7 @@ }, "PROCEED_TO_SEND": { "en": "Nice! Just send/forward us the message. We'll help you check and/or report it! ✅✅\n\nIf you like, you can also send in screenshots 📷 or other images 🖼️! This can help to capture the sender's number, or a full conversation, which could help our CheckMates' assessment.\n\nOne last thing: by continuing to use CheckMate, you're agreeing to our privacy policy, which can be found at https://checkmate.sg/privacy-policy. In short, we only collect the messages sent to us and your number to facilitate a response!", - "cn": "好的!您只需将短信发送给查友,我们会对其进行评估!✅✅\n\n除了文字信息,您也可以发送截图📷或其他图片🖼️!这有助于查哥查妹通过发信人号码或完整的对话内容做出判断。\n\n最后,使用查友即表示您已同意我们的隐私政策。您可在 https://checkmate.sg/privacy-policy 查看我们的隐私政策。基本上,我们只收集您发送的消息以及您的手机号码,以便回复您!" + "cn": "好的!您只需将短信发送给查友,我们会对此进行评估!✅✅\n\n除了文字信息,您也可以发送截图📷或其他图片🖼️!这有助于查哥查妹通过发信人号码或完整的对话内容做出评判。\n\n最后,使用查友即表示您已同意我们的隐私政策。您可在 https://checkmate.sg/privacy-policy 查看我们的隐私政策。基本上,我们只收集您发送的消息以及您的手机号码,以便回复您!" }, "HOW_TO": { "en": "Check out https://youtube.com/shorts/gFeO_qFOchs?feature=share to see how CheckMate works!\n\nDone? You're now ready to use CheckMate! Let's do our part in the fight against scams and misinformation! 💪", @@ -156,12 +156,12 @@ "cn": "您是否已经开始使用查友?点击此链接进行注册!{{link}}" }, "REFERRAL_PREPOPULATED_PREFIX": { - "en": "Welcome to CheckMate! Send in this entire message (including the code) to get started, and credit your friend with your referral. Code:", - "cn": "欢迎使用查友!请发送这条短信(包括推荐人代码)以开始使用。代码:" + "en": "Welcome to CheckMate! Send in this message to get started, and credit your friend with your referral.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", + "cn": "Welcome to CheckMate! Send in this message to get started, and credit your friend with your referral.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:" }, "GENERIC_PREPOPULATED_PREFIX": { - "en": "Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:", - "cn": "欢迎使用查友!请发送这条短信(包括代码)以开始使用。代码:" + "en": "Welcome to CheckMate! Send in this message to get started.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", + "cn": "Welcome to CheckMate! Send in this message to get started.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:" }, "REFERRAL_INVALID": { "en": "Sorry, referrals are only credited upon your first interaction with CheckMate.", @@ -343,4 +343,4 @@ "en": "too difficult to assess", "cn": "很难做评估" } -} +} \ No newline at end of file From 76d5bb06166d85bfebf9b0487d25bd4d2c47cb29 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 20:45:00 +0800 Subject: [PATCH 10/13] updated tests --- .../checkmate.postman_collection.json | 854 +++--------------- 1 file changed, 104 insertions(+), 750 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index d8d70522..87dd3ebf 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -2974,7 +2974,7 @@ "response": [] }, { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", @@ -2987,12 +2987,10 @@ " 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\");\r", - " const BUTTON_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en\");\r", - " const BUTTON_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en\")\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\")\r", " const expected = {\r", " \"hostname\": \"resultserver\",\r", " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", @@ -3011,15 +3009,8 @@ " {\r", " \"type\": \"reply\",\r", " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": BUTTON_USEFUL\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": BUTTON_NOT_USEFUL\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": BUTTON_ANOTHER_UPDATE\r", " }\r", " }\r", " ]\r", @@ -3065,7 +3056,7 @@ "response": [] }, { - "name": "Press button \"Yes it's useful\"", + "name": "Press button to get interim update again", "event": [ { "listen": "test", @@ -3083,7 +3074,7 @@ "script": { "exec": [ "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 14\r", + "let messageCounter = 15\r", "\r", "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", "\r", @@ -3105,7 +3096,7 @@ "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}", + "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" @@ -3128,22 +3119,23 @@ "response": [] }, { - "name": "INTERIM_USEFUL", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + "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_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.en\");\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.en\");\r", " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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", @@ -3155,7 +3147,7 @@ " \"interactive\": {\r", " \"type\": \"button\",\r", " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", + " \"text\": interimResponse\r", " },\r", " \"action\": {\r", " \"buttons\": [\r", @@ -3176,6 +3168,7 @@ " \"method\": \"POST\"\r", " }\r", " var jsonData = pm.response.json();\r", + " \r", " pm.expect(jsonData).to.eql(expected);\r", "});" ], @@ -3206,9 +3199,14 @@ } }, "response": [] - }, + } + ] + }, + { + "name": "005c_2nd Voter Legitimate", + "item": [ { - "name": "Press button \"No it's not\"", + "name": "Second checker clicks yes", "event": [ { "listen": "test", @@ -3220,15 +3218,6 @@ ], "type": "text/javascript" } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } } ], "request": { @@ -3236,7 +3225,7 @@ "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}", + "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" @@ -3259,53 +3248,27 @@ "response": [] }, { - "name": "INTERIM_NOT_USEFUL", + "name": "Message to Check Sent", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + "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 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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_ANOTHER_UPDATE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\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", - " \"method\": \"POST\"\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", "});" @@ -3339,120 +3302,68 @@ "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", + "name": "L1_ASSESSMENT_PROMPT", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", + "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 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\")\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\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_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\": BUTTON_ANOTHER_UPDATE\r", - " }\r", - " }\r", - " ]\r", - " }\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", - " \"context\": {\r", - " \"message_id\": wamid\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", - " \"method\": \"POST\"\r", - " }\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", " var jsonData = pm.response.json();\r", - " \r", " pm.expect(jsonData).to.eql(expected);\r", "});" ], @@ -3463,7 +3374,7 @@ "listen": "prerequest", "script": { "exec": [ - "setTimeout(() => {}, 3000);" + "" ], "type": "text/javascript" } @@ -3483,14 +3394,9 @@ } }, "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ + }, { - "name": "Second checker clicks yes", + "name": "Second checker selects \"It's something else\"", "event": [ { "listen": "test", @@ -3509,7 +3415,7 @@ "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}", + "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" @@ -3532,213 +3438,23 @@ "response": [] }, { - "name": "Message to Check Sent", + "name": "HOLD_FOR_L2_CATEGORISATION", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", + "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\": \"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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", " \"preview_url\": false\r", " },\r", " \"to\": CHECKER_PHONE_NUMBERS[1],\r", @@ -5349,7 +5065,6 @@ " },\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", "});" @@ -6468,7 +6183,7 @@ "response": [] }, { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", @@ -6481,12 +6196,10 @@ " 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\");\r", - " const BUTTON_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en\");\r", - " const BUTTON_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en\")\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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 interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\")\r", " const expected = {\r", " \"hostname\": \"resultserver\",\r", " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", @@ -6505,15 +6218,8 @@ " {\r", " \"type\": \"reply\",\r", " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": BUTTON_USEFUL\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": BUTTON_NOT_USEFUL\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": BUTTON_ANOTHER_UPDATE\r", " }\r", " }\r", " ]\r", @@ -6557,55 +6263,6 @@ } }, "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances", - "{{infoInstanceId}}" - ] - } - }, - "response": [] } ] }, @@ -8938,55 +8595,6 @@ } }, "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] } ] }, @@ -9223,7 +8831,7 @@ "response": [] }, { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "name": "INTERIM_TEMPLATE", "event": [ { "listen": "test", @@ -9237,211 +8845,9 @@ " 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.en\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.en\")\r", - " const BUTTON_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en\");\r", - " const BUTTON_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"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\": BUTTON_USEFUL\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": BUTTON_NOT_USEFUL\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " console.log(JSON.stringify(expected,null,2))\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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\r", " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"legitimate✅\").replace(\"{{info_placeholder}}\",\"\")\r", " const expected = {\r", " \"hostname\": \"resultserver\",\r", " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", @@ -9453,7 +8859,7 @@ " \"interactive\": {\r", " \"type\": \"button\",\r", " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", + " \"text\": interimResponse\r", " },\r", " \"action\": {\r", " \"buttons\": [\r", @@ -9474,6 +8880,7 @@ " \"method\": \"POST\"\r", " }\r", " var jsonData = pm.response.json();\r", + " \r", " pm.expect(jsonData).to.eql(expected);\r", "});" ], @@ -9504,55 +8911,6 @@ } }, "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] } ] }, @@ -10417,7 +9775,6 @@ " },\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", "});" @@ -12662,8 +12019,6 @@ " \"menu_dispute\",\r", " \"text_machine_unsure\",\r", " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", " \"sendInterim\",\r", " \"sendInterim\",\r", " \"satisfactionSurvey_10\",\r", @@ -12675,7 +12030,6 @@ " \"text_machine_unsure\",\r", " \"sendInterim\",\r", " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", " \"sendInterim\",\r", " \"votingResults\",\r", " \"text_menu\",\r", From 8febd1c1a7fe6faf846634bfd2f2e58c0c055a69 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 21:00:57 +0800 Subject: [PATCH 11/13] changed env variables --- functions/.env.local.test | 3 +- .../checkmate.postman_collection.json | 25968 ++++++++-------- integration-tests/env.json | 9 +- 3 files changed, 12589 insertions(+), 13391 deletions(-) diff --git a/functions/.env.local.test b/functions/.env.local.test index 9b774d21..a5a211f6 100644 --- a/functions/.env.local.test +++ b/functions/.env.local.test @@ -13,4 +13,5 @@ EMBEDDER_HOST=http://embedder-server:12344 TELEGRAM_REPORT_CHANNEL_ID=111111111 TEST_IMAGE_URL=TEST HASHIDS_SALT=SALT -WEBHOOK_PATH=whatsapp \ No newline at end of file +WEBHOOK_PATH_WHATSAPP=whatsapp +WEBHOOK_PATH_TELEGRAM=telegram \ No newline at end of file diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 87dd3ebf..2a3f0f56 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,13389 +1,12581 @@ { - "info": { - "_postman_id": "c96bcaae-e133-42b3-b840-ed90f0840413", - "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}}/{{PROJECT_ID}}/asia-southeast1/healthcheck", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "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_USER_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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/{{PROJECT_ID}}/databases/(default)/documents:listCollectionIds", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SELECT LANGUAGE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Select language\", function () {\r", - " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", - " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", - " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", - " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", - " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", - " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", - " \"title\": BUTTON_ENGLISH\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_cn\",\r", - " \"title\": BUTTON_CHINESE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - " }\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 English 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": [ - "" - ], - "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": MENU_TITLE_DISPUTE,\r", - " \"description\": MENU_DESCRIPTION_DISPUTE\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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", - " // 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en\");\r", - " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", - " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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.en\");\r", - " const NPS_MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NPS_MENU_BUTTON.en\");\r", - " const MENU_DESCRIPTION_NPS_LIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_LIKELY.en\");\r", - " const MENU_DESCRIPTION_NPS_UNLIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.en\");\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\": NPS_MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": MENU_DESCRIPTION_NPS_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\": MENU_DESCRIPTION_NPS_UNLIKELY\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", - " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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", - " const STATS_TEMPLATE_1 = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.en\")\r", - " const PLACEHOLDER_MISLEADING = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_MISLEADING.en\")\r", - " const expectedBody = STATS_TEMPLATE_1.replace(\"{{top}}\", \"100.00\").replace(\"{{category}}\",PLACEHOLDER_MISLEADING).replace(\"{{info_placeholder}}\",\", with an average score of 2.33 on a scale of 0-5 (5 = completely true)\")\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\": expectedBody,\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en\");\r", - " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"legitimate✅\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - "\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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", - " 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", - " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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 (\"Select Language\")", - "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_language\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en}}\",\r\n \"description\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en}}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SELECT LANGUAGE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Select language\", function () {\r", - " const NEW_USER_PREFIX_EN = \"\"\r", - " const NEW_USER_PREFIX_CN = \"\"\r", - " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", - " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", - " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", - " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", - " \"title\": BUTTON_ENGLISH\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_cn\",\r", - " \"title\": BUTTON_CHINESE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - " }\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 English 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": [ - "" - ], - "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\")\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\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}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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\": BUTTON_RATIONALISATION\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": BUTTON_DECLINE_REPORT\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_rationalisation = jsonData.body.interactive.action.buttons[0].reply.id;\r", - " let reply_id_decline = jsonData.body.interactive.action.buttons[1].reply.id;\r", - " let [, scamInstancePath , ] = reply_id_rationalisation.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(reply_id_rationalisation).to.match(/rationalisation_messages\\/\\w+\\/instances\\/\\w+/);\r", - " pm.expect(reply_id_decline).to.match(/scamshieldDecline_messages\\/\\w+\\/instances\\/\\w+/);\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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", - " \"languageSelection_en\",\r", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\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", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_language\",\r", - " \"languageSelection_en\",\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SELECT LANGUAGE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Select language\", function () {\r", - " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", - " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", - " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", - " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", - " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", - " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"button\",\r", - " \"body\": {\r", - " \"text\": BODY_TEXT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_en\",\r", - " \"title\": BUTTON_ENGLISH\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_cn\",\r", - " \"title\": BUTTON_CHINESE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - " }\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 English 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": [ - "" - ], - "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_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_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\": \"{{USER_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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \r", - " const USER_2_NAME = pm.variables.get(\"USER_2_NAME\")\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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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/{{PROJECT_ID}}/databases/(default)/documents/messages", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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/{{PROJECT_ID}}/databases/(default)/documents/messages", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", - "host": [ - "{{FIRESTORE_URL}}" - ], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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 + "info": { + "_postman_id": "c96bcaae-e133-42b3-b840-ed90f0840413", + "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}}/{{PROJECT_ID}}/asia-southeast1/healthcheck", + "host": ["{{FUNCTIONS_URL}}"], + "path": ["{{PROJECT_ID}}", "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_USER_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents:listCollectionIds", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SELECT LANGUAGE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Select language\", function () {\r", + " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", + " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", + " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", + " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", + " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", + " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + " }\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 English 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": [""], + "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_dispute_messages/*/instances/*\",\r", + " \"title\": MENU_TITLE_DISPUTE,\r", + " \"description\": MENU_DESCRIPTION_DISPUTE\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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", + " // 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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.en\");\r", + " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", + " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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.en\");\r", + " const NPS_MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NPS_MENU_BUTTON.en\");\r", + " const MENU_DESCRIPTION_NPS_LIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_LIKELY.en\");\r", + " const MENU_DESCRIPTION_NPS_UNLIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.en\");\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\": NPS_MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"10\",\r", + " \"description\": MENU_DESCRIPTION_NPS_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\": MENU_DESCRIPTION_NPS_UNLIKELY\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", + " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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", + " const STATS_TEMPLATE_1 = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.en\")\r", + " const PLACEHOLDER_MISLEADING = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_MISLEADING.en\")\r", + " const expectedBody = STATS_TEMPLATE_1.replace(\"{{top}}\", \"100.00\").replace(\"{{category}}\",PLACEHOLDER_MISLEADING).replace(\"{{info_placeholder}}\",\", with an average score of 2.33 on a scale of 0-5 (5 = completely true)\")\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\": expectedBody,\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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.en\");\r", + " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"legitimate✅\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + "\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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", + " 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", + " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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 (\"Select Language\")", + "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_language\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en}}\",\r\n \"description\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en}}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SELECT LANGUAGE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Select language\", function () {\r", + " const NEW_USER_PREFIX_EN = \"\"\r", + " const NEW_USER_PREFIX_CN = \"\"\r", + " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", + " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", + " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", + " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + " }\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 English 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": [""], + "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\")\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\")\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\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}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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\": BUTTON_RATIONALISATION\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": BUTTON_DECLINE_REPORT\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_rationalisation = jsonData.body.interactive.action.buttons[0].reply.id;\r", + " let reply_id_decline = jsonData.body.interactive.action.buttons[1].reply.id;\r", + " let [, scamInstancePath , ] = reply_id_rationalisation.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(reply_id_rationalisation).to.match(/rationalisation_messages\\/\\w+\\/instances\\/\\w+/);\r", + " pm.expect(reply_id_decline).to.match(/scamshieldDecline_messages\\/\\w+\\/instances\\/\\w+/);\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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", + " \"languageSelection_en\",\r", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\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", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_language\",\r", + " \"languageSelection_en\",\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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.en}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SELECT LANGUAGE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Select language\", function () {\r", + " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", + " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", + " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", + " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", + " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", + " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"button\",\r", + " \"body\": {\r", + " \"text\": BODY_TEXT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + " }\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 English 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": [""], + "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_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_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\": \"{{USER_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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \r", + " const USER_2_NAME = pm.variables.get(\"USER_2_NAME\")\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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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.en}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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/{{PROJECT_ID}}/databases/(default)/documents/messages", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", + "host": ["{{FIRESTORE_URL}}"], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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": "" + } + ] +} diff --git a/integration-tests/env.json b/integration-tests/env.json index 4165905a..69276164 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -19,10 +19,15 @@ "enabled": true }, { - "key": "WEBHOOK_PATH", + "key": "WEBHOOK_PATH_WHATSAPP", "value": "whatsapp", "enabled": true }, + { + "key": "WEBHOOK_PATH_TELEGRAM", + "value": "telegram", + "enabled": true + }, { "key": "FIRESTORE_URL", "value": "http://localhost:18080", @@ -1017,4 +1022,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 +} From 090bbf812ac36d913687aea8c822e0fa5c82c9bf Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 21:23:48 +0800 Subject: [PATCH 12/13] updated integration tests for new referral prefix --- .../checkmate.postman_collection.json | 25973 ++++++++-------- integration-tests/env.json | 24 +- 2 files changed, 13405 insertions(+), 12592 deletions(-) diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 2a3f0f56..e89c4e58 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,12581 +1,13394 @@ { - "info": { - "_postman_id": "c96bcaae-e133-42b3-b840-ed90f0840413", - "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}}/{{PROJECT_ID}}/asia-southeast1/healthcheck", - "host": ["{{FUNCTIONS_URL}}"], - "path": ["{{PROJECT_ID}}", "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_USER_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents:listCollectionIds", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SELECT LANGUAGE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Select language\", function () {\r", - " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", - " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", - " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", - " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", - " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", - " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", - " \"title\": BUTTON_ENGLISH\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_cn\",\r", - " \"title\": BUTTON_CHINESE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - " }\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 English 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": [""], - "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": MENU_TITLE_DISPUTE,\r", - " \"description\": MENU_DESCRIPTION_DISPUTE\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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", - " // 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en\");\r", - " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", - " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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.en\");\r", - " const NPS_MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NPS_MENU_BUTTON.en\");\r", - " const MENU_DESCRIPTION_NPS_LIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_LIKELY.en\");\r", - " const MENU_DESCRIPTION_NPS_UNLIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.en\");\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\": NPS_MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": MENU_DESCRIPTION_NPS_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\": MENU_DESCRIPTION_NPS_UNLIKELY\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", - " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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", - " const STATS_TEMPLATE_1 = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.en\")\r", - " const PLACEHOLDER_MISLEADING = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_MISLEADING.en\")\r", - " const expectedBody = STATS_TEMPLATE_1.replace(\"{{top}}\", \"100.00\").replace(\"{{category}}\",PLACEHOLDER_MISLEADING).replace(\"{{info_placeholder}}\",\", with an average score of 2.33 on a scale of 0-5 (5 = completely true)\")\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\": expectedBody,\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en\");\r", - " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"legitimate✅\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - "\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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", - " 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", - " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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 (\"Select Language\")", - "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_language\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en}}\",\r\n \"description\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en}}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SELECT LANGUAGE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Select language\", function () {\r", - " const NEW_USER_PREFIX_EN = \"\"\r", - " const NEW_USER_PREFIX_CN = \"\"\r", - " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", - " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", - " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", - " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", - " \"title\": BUTTON_ENGLISH\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_cn\",\r", - " \"title\": BUTTON_CHINESE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - " }\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 English 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": [""], - "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\")\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\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}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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\": BUTTON_RATIONALISATION\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": BUTTON_DECLINE_REPORT\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_rationalisation = jsonData.body.interactive.action.buttons[0].reply.id;\r", - " let reply_id_decline = jsonData.body.interactive.action.buttons[1].reply.id;\r", - " let [, scamInstancePath , ] = reply_id_rationalisation.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(reply_id_rationalisation).to.match(/rationalisation_messages\\/\\w+\\/instances\\/\\w+/);\r", - " pm.expect(reply_id_decline).to.match(/scamshieldDecline_messages\\/\\w+\\/instances\\/\\w+/);\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", - " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", - " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", - " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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", - " \"languageSelection_en\",\r", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\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", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_language\",\r", - " \"languageSelection_en\",\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_WHATSAPP}}" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SELECT LANGUAGE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Select language\", function () {\r", - " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", - " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", - " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", - " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", - " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", - " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"button\",\r", - " \"body\": {\r", - " \"text\": BODY_TEXT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_en\",\r", - " \"title\": BUTTON_ENGLISH\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"languageSelection_cn\",\r", - " \"title\": BUTTON_CHINESE\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - " }\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 English 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": [""], - "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_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_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\": \"{{USER_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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", - " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", - " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", - " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", - " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", - " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", - " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", - " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", - " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", - " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", - " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", - " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", - " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", - " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", - " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", - " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", - " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", - " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", - " \r", - " const USER_2_NAME = pm.variables.get(\"USER_2_NAME\")\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\": MENU_BUTTON,\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": MENU_TITLE_CHECK,\r", - " \"description\": MENU_DESCRIPTION_CHECK\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": MENU_TITLE_REFERRAL,\r", - " \"description\": MENU_DESCRIPTION_REFERRAL\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": MENU_TITLE_HELP,\r", - " \"description\": MENU_DESCRIPTION_HELP\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": MENU_TITLE_ABOUT,\r", - " \"description\": MENU_DESCRIPTION_ABOUT\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": MENU_TITLE_FEEDBACK,\r", - " \"description\": MENU_DESCRIPTION_FEEDBACK\r", - " },\r", - " {\r", - " \"id\": \"menu_language\",\r", - " \"title\": MENU_TITLE_LANGUAGE,\r", - " \"description\": MENU_DESCRIPTION_LANGUAGE\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": MENU_TITLE_CONTACT,\r", - " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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.en}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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/{{PROJECT_ID}}/databases/(default)/documents/messages", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "{{PROJECT_ID}}", - "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": "" - } - ] -} + "info": { + "_postman_id": "8ea99a98-6462-4c48-a8d0-ae5addd10b81", + "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}}/{{PROJECT_ID}}/asia-southeast1/healthcheck", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "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_USER_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents:listCollectionIds", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SELECT LANGUAGE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Select language\", function () {\r", + " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", + " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", + " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", + " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", + " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", + " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + " }\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 English 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": [ + "" + ], + "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_dispute_messages/*/instances/*\",\r", + " \"title\": MENU_TITLE_DISPUTE,\r", + " \"description\": MENU_DESCRIPTION_DISPUTE\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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", + " // 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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.en\");\r", + " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\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}}\",\"spam🚧\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", + " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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.en\");\r", + " const NPS_MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NPS_MENU_BUTTON.en\");\r", + " const MENU_DESCRIPTION_NPS_LIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_LIKELY.en\");\r", + " const MENU_DESCRIPTION_NPS_UNLIKELY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.en\");\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\": NPS_MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"10\",\r", + " \"description\": MENU_DESCRIPTION_NPS_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\": MENU_DESCRIPTION_NPS_UNLIKELY\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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}}\",\"untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", + " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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", + " const STATS_TEMPLATE_1 = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.en\")\r", + " const PLACEHOLDER_MISLEADING = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_MISLEADING.en\")\r", + " const expectedBody = STATS_TEMPLATE_1.replace(\"{{top}}\", \"100.00\").replace(\"{{category}}\",PLACEHOLDER_MISLEADING).replace(\"{{info_placeholder}}\",\", with an average score of 2.33 on a scale of 0-5 (5 = completely true)\")\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\": expectedBody,\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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_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_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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.en\");\r", + " const BUTTON_GET_INTERIM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en\")\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\": BUTTON_GET_INTERIM\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"legitimate✅\").replace(\"{{info_placeholder}}\",\"\")\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\": BUTTON_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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const BUTTON_ANOTHER_UPDATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + "\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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", + " 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\");\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en\")\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", + " .replace(\"{{image_caveat}}\", isImage ? IMAGE_CAVEAT : \"\")\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\": BUTTON_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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 felt this was *spam🚧*. 33.33% felt 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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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 (\"Select Language\")", + "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_language\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en}}\",\r\n \"description\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en}}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SELECT LANGUAGE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Select language\", function () {\r", + " const NEW_USER_PREFIX_EN = \"\"\r", + " const NEW_USER_PREFIX_CN = \"\"\r", + " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", + " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", + " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", + " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + " }\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 English 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": [ + "" + ], + "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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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": "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en\")\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX.en\")\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\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}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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\": BUTTON_RATIONALISATION\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": BUTTON_DECLINE_REPORT\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_rationalisation = jsonData.body.interactive.action.buttons[0].reply.id;\r", + " let reply_id_decline = jsonData.body.interactive.action.buttons[1].reply.id;\r", + " let [, scamInstancePath , ] = reply_id_rationalisation.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(reply_id_rationalisation).to.match(/rationalisation_messages\\/\\w+\\/instances\\/\\w+/);\r", + " pm.expect(reply_id_decline).to.match(/scamshieldDecline_messages\\/\\w+\\/instances\\/\\w+/);\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en\")\r", + " const BUTTON_RESULTS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en\")\r", + " const BUTTON_DECLINE_REPORT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en\")\r", + " const BUTTON_RATIONALISATION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{image_caveat}}\",\"\")\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", + " \"languageSelection_en\",\r", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\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", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_language\",\r", + " \"languageSelection_en\",\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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", + "\r", + "// Get the variable that contains new lines\r", + "let responseBody = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX.en\");\r", + "// Escape new lines and set it to a new variable\r", + "pm.variables.set(\"escapedPrepopulatedPrefix\", responseBody.replace(/(\\r\\n|\\n|\\r)/gm, \"\\\\n\"));\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\": \"{{escapedPrepopulatedPrefix}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_WHATSAPP}}" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SELECT LANGUAGE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Select language\", function () {\r", + " const NEW_USER_PREFIX_EN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en\")\r", + " const NEW_USER_PREFIX_CN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en\")\r", + " const LANGUAGE_SELECTION = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en\")\r", + " const BUTTON_ENGLISH = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en\")\r", + " const BUTTON_CHINESE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en\")\r", + " const BODY_TEXT = LANGUAGE_SELECTION.replace(\"{{new_user_en}}\",NEW_USER_PREFIX_EN).replace(\"{{new_user_cn}}\",NEW_USER_PREFIX_CN)\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\": \"button\",\r", + " \"body\": {\r", + " \"text\": BODY_TEXT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + " }\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 English 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": [ + "" + ], + "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_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_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\": \"{{USER_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\": \"languageSelection_en\",\r\n \"title\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en}}\"\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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX);\r", + " const MENU_BUTTON = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en\");\r", + " const MENU_TITLE_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en\");\r", + " const MENU_DESCRIPTION_CHECK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en\");\r", + " const MENU_TITLE_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en\");\r", + " const MENU_DESCRIPTION_REFERRAL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en\");\r", + " const MENU_TITLE_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en\");\r", + " const MENU_DESCRIPTION_ABOUT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en\");\r", + " const MENU_TITLE_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en\");\r", + " const MENU_DESCRIPTION_HELP = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en\");\r", + " const MENU_TITLE_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en\");\r", + " const MENU_DESCRIPTION_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en\");\r", + " const MENU_TITLE_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en\")\r", + " const MENU_DESCRIPTION_LANGUAGE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en\")\r", + " const MENU_TITLE_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en\");\r", + " const MENU_DESCRIPTION_CONTACT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en\");\r", + " const MENU_TITLE_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en\")\r", + " const MENU_DESCRIPTION_DISPUTE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en\")\r", + " \r", + " const USER_2_NAME = pm.variables.get(\"USER_2_NAME\")\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\": MENU_BUTTON,\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": MENU_TITLE_CHECK,\r", + " \"description\": MENU_DESCRIPTION_CHECK\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": MENU_TITLE_REFERRAL,\r", + " \"description\": MENU_DESCRIPTION_REFERRAL\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": MENU_TITLE_HELP,\r", + " \"description\": MENU_DESCRIPTION_HELP\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": MENU_TITLE_ABOUT,\r", + " \"description\": MENU_DESCRIPTION_ABOUT\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": MENU_TITLE_FEEDBACK,\r", + " \"description\": MENU_DESCRIPTION_FEEDBACK\r", + " },\r", + " {\r", + " \"id\": \"menu_language\",\r", + " \"title\": MENU_TITLE_LANGUAGE,\r", + " \"description\": MENU_DESCRIPTION_LANGUAGE\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": MENU_TITLE_CONTACT,\r", + " \"description\": MENU_DESCRIPTION_CONTACT\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/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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\": \"{{escapedPrepopulatedPrefix}} {{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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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.en\");\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/{{PROJECT_ID}}/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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/{{PROJECT_ID}}/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH_WHATSAPP}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH_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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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/{{PROJECT_ID}}/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "{{PROJECT_ID}}", + "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 69276164..3921b826 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -195,7 +195,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ERROR.cn", - "value": "抱歉,查友在评估您提供的短信时发生问题。\n\n欢迎您稍后重试,或者通过这份表格向我们反馈:https://bit.ly/checkmate-feedback。对此造成的不便,我们非常抱歉!😔", + "value": "抱歉,查友在评估您提供的短信时发生了问题。\n\n欢迎您稍后重试,或者通过这份表格向我们反馈:https://bit.ly/checkmate-feedback。对此造成的不便,我们非常抱歉!😔", "enabled": true }, { @@ -235,7 +235,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM.cn", - "value": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然它看似无害,但仍然请您保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!", + "value": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然它看似无害,但请仍然保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -335,7 +335,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE.cn", - "value": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。不幸的是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。", + "value": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。但是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。", "enabled": true }, { @@ -345,7 +345,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT.cn", - "value": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼", + "value": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击“获取初步结果”。请注意,初步结果和最终结果可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并会尽快提供最终结果!💪🏼", "enabled": true }, { @@ -415,7 +415,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND.cn", - "value": "好的!您只需将短信发送给查友,我们会对其进行评估!✅✅\n\n除了文字信息,您也可以发送截图📷或其他图片🖼️!这有助于查哥查妹通过发信人号码或完整的对话内容做出判断。\n\n最后,使用查友即表示您已同意我们的隐私政策。您可在 https://checkmate.sg/privacy-policy 查看我们的隐私政策。基本上,我们只收集您发送的消息以及您的手机号码,以便回复您!", + "value": "好的!您只需将短信发送给查友,我们会对此进行评估!✅✅\n\n除了文字信息,您也可以发送截图📷或其他图片🖼️!这有助于查哥查妹通过发信人号码或完整的对话内容做出评判。\n\n最后,使用查友即表示您已同意我们的隐私政策。您可在 https://checkmate.sg/privacy-policy 查看我们的隐私政策。基本上,我们只收集您发送的消息以及您的手机号码,以便回复您!", "enabled": true }, { @@ -480,22 +480,22 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX.en", - "value": "Welcome to CheckMate! Send in this entire message (including the code) to get started, and credit your friend with your referral. Code:", + "value": "Welcome to CheckMate! Send in this message to get started, and credit your friend with your referral.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX.cn", - "value": "欢迎使用查友!请发送这条短信(包括推荐人代码)以开始使用。代码:", + "value": "Welcome to CheckMate! Send in this message to get started, and credit your friend with your referral.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_PREPOPULATED_PREFIX.en", - "value": "Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:", + "value": "Welcome to CheckMate! Send in this message to get started.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_PREPOPULATED_PREFIX.cn", - "value": "欢迎使用查友!请发送这条短信(包括代码)以开始使用。代码:", + "value": "Welcome to CheckMate! Send in this message to get started.\n\n欢迎使用查友!请发送这条短信以开始使用。\n\nCode:", "enabled": true }, { @@ -935,7 +935,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.cn", - "value": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友仅能评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊", + "value": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友只评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊", "enabled": true }, { @@ -965,7 +965,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.cn", - "value": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n\n", + "value": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n\n", "enabled": true }, { @@ -1022,4 +1022,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 From b4914ccdf910ce5e79d55b84909400b5c8662b17 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 8 Nov 2023 11:00:27 +0800 Subject: [PATCH 13/13] changed copy --- .../src/definitions/common/parameters/userResponses.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index c1f62232..eebf69cf 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -89,7 +89,7 @@ }, "INTERIM_PROMPT": { "en": "Thanks for waiting! We are currently still pending the assessment from some of our network of trusted CheckMate volunteers and will only be able to provide a credible final result once enough votes have come in. \n\nYou may press the button below *to get an interim update of the preliminary result*. However, do note that there may be discrepancies between the preliminary and the final result, and *the preliminary result should be interpreted with caution*. We appreciate your patience and hope to deliver the final result to you soon! 💪🏼", - "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击“获取初步结果”。请注意,初步结果和最终结果可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并会尽快提供最终结果!💪🏼" + "cn": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹投票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击“获取初步结果”。请注意,初步结果和最终结果可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并会尽快提供最终结果!💪🏼" }, "ALREADY_REPLIED": { "en": "CheckMate has already provided a final response to this message.", @@ -100,7 +100,7 @@ "cn": "我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,也感谢您对新加坡网络安全的支持和贡献。" }, "MENU": { - "en": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"Menu\" below to see what CheckMate can do! 👈\n\nDo note that CheckMate *is designed to check dubious messages you send in. It cannot converse freely with you*.\n\nAnytime you need a refresher on what CheckMate can do, type \"menu\" to get here again! 😊", + "en": "{{prefix}}\n\nSelect \"Menu\" below to see what CheckMate can do! 👈\n\nDo note that CheckMate *is designed to check dubious messages you send in. It cannot converse freely with you*.\n\nAnytime you need a refresher on what CheckMate can do, type \"menu\" to get here again! 😊", "cn": "{{prefix}}\n\n请点击“菜单\"查看查友的功能!👈\n\n请注意,查友只评估您发送的短信,它无法与您进行对话。\n\n您只需输入\"菜单\"即可随时返回这里,查看查友的功能!😊" }, "NEW_USER_PREFIX_EN": { @@ -343,4 +343,4 @@ "en": "too difficult to assess", "cn": "很难做评估" } -} \ No newline at end of file +}