From 2a3bcdf2932f240efa8c3d5ef3bf9b9ba3c2bd88 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 21 Oct 2023 12:49:19 +0800 Subject: [PATCH 01/36] nonprod setup --- .firebaserc | 10 +++++++--- functions/.env.checkmate-nonprod | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 functions/.env.checkmate-nonprod diff --git a/.firebaserc b/.firebaserc index 3ba429ef..958a695e 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,5 +1,9 @@ { "projects": { - "default": "checkmate-373101" - } -} + "default": "checkmate-373101", + "nonprod": "checkmate-nonprod", + "prod": "checkmate-373101" + }, + "targets": {}, + "etags": {} +} \ No newline at end of file diff --git a/functions/.env.checkmate-nonprod b/functions/.env.checkmate-nonprod new file mode 100644 index 00000000..5af64148 --- /dev/null +++ b/functions/.env.checkmate-nonprod @@ -0,0 +1,5 @@ +NUM_SHARDS_INSTANCE_COUNT=5 +NUM_SHARDS_VOTE_COUNT=5 +GRAPH_API_VERSION=v15.0 +ENVIRONMENT=UAT +SIMILARITY_THRESHOLD=0.85 \ No newline at end of file From 23f3cda19af9b3b648a9958436e4a7138f26f778 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 21 Oct 2023 14:55:27 +0800 Subject: [PATCH 02/36] changed secret to telegram_checker_bot_token --- functions/src/definitions/api/api.ts | 2 +- functions/src/definitions/api/authentication.ts | 4 ++-- functions/src/definitions/webhookHandlers/telegram.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/src/definitions/api/api.ts b/functions/src/definitions/api/api.ts index d25412c2..6194fa57 100644 --- a/functions/src/definitions/api/api.ts +++ b/functions/src/definitions/api/api.ts @@ -37,7 +37,7 @@ main.use("/api", app) const apiHandler = onRequest( { - secrets: ["TELEGRAM_BOT_TOKEN"], + secrets: ["TELEGRAM_CHECKER_BOT_TOKEN"], }, main ) diff --git a/functions/src/definitions/api/authentication.ts b/functions/src/definitions/api/authentication.ts index 630d5fc6..c303700e 100644 --- a/functions/src/definitions/api/authentication.ts +++ b/functions/src/definitions/api/authentication.ts @@ -14,7 +14,7 @@ const CHECKER1_PHONE_NUMBER: string = String(process.env.CHECKER1_PHONE_NUMBER) app.post("/", async (req, res) => { const initData = req.body // Assuming you send initData in the body of your requests - const botToken = String(process.env.TELEGRAM_BOT_TOKEN) // Replace with your bot token + const botToken = String(process.env.TELEGRAM_CHECKER_BOT_TOKEN) // Replace with your bot token // Extract the data from initData (convert from query string format) const params = new URLSearchParams(initData) @@ -99,7 +99,7 @@ main.use("/telegramAuth", app) const telegramAuthHandler = onRequest( { - secrets: ["TELEGRAM_BOT_TOKEN"], + secrets: ["TELEGRAM_CHECKER_BOT_TOKEN"], }, main ) diff --git a/functions/src/definitions/webhookHandlers/telegram.ts b/functions/src/definitions/webhookHandlers/telegram.ts index c949140a..60291b09 100644 --- a/functions/src/definitions/webhookHandlers/telegram.ts +++ b/functions/src/definitions/webhookHandlers/telegram.ts @@ -5,7 +5,7 @@ import express from "express" import TelegramBot from "node-telegram-bot-api" import { onRequest } from "firebase-functions/v2/https" -const TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" +const TOKEN = String(process.env.TELEGRAM_CHECKER_BOT_TOKEN) const bot = new TelegramBot(TOKEN) const app = express() @@ -23,7 +23,7 @@ app.post("/", async (req, res) => { const telegramHandler = onRequest( { - secrets: ["TELEGRAM_BOT_TOKEN"], + secrets: ["TELEGRAM_CHECKER_BOT_TOKEN"], }, app ) From c1832111d110a42ff7064bde50416c87d8fa9a99 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 21 Oct 2023 16:04:12 +0800 Subject: [PATCH 03/36] updated github actions --- .github/workflows/firebase-deploy.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/firebase-deploy.yml b/.github/workflows/firebase-deploy.yml index 82bc2b54..83752623 100644 --- a/.github/workflows/firebase-deploy.yml +++ b/.github/workflows/firebase-deploy.yml @@ -1,11 +1,14 @@ name: Deploy Cloud Functions + on: workflow_dispatch: push: branches: - main + - develop paths: - - 'functions/**' + - "functions/**" + jobs: build_and_deploy: runs-on: ubuntu-latest @@ -28,9 +31,14 @@ jobs: run: npm ci working-directory: functions - name: Create SA key - run: echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > $HOME/gcloud.json + run: | + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > $HOME/gcloud.json + else + echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NONPROD }}' > $HOME/gcloud.json + fi - name: Install Firebase CLI run: npm install -g firebase-tools - name: Deploy Cloud Functions run: export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json && npm run deploy - working-directory: functions \ No newline at end of file + working-directory: functions From 82daa4bf33651d9fdc715525a7a53456878d902f Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 25 Oct 2023 17:27:38 +0800 Subject: [PATCH 04/36] made webhook endpoint a secret --- functions/package-lock.json | 405 ++++++++++++------ functions/package.json | 2 +- .../definitions/webhookHandlers/whatsapp.ts | 70 +-- 3 files changed, 310 insertions(+), 167 deletions(-) diff --git a/functions/package-lock.json b/functions/package-lock.json index d06b0356..d905a9ff 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -27,7 +27,7 @@ "@babel/core": "^7.21.4", "@babel/preset-env": "^7.21.4", "@babel/preset-typescript": "^7.21.4", - "@types/express": "^4.17.17", + "@types/express": "^4.17.20", "@types/jest": "^29.5.1", "@types/node-telegram-bot-api": "^0.61.8", "@types/supertest": "^2.0.12", @@ -59,17 +59,89 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "dev": true, "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/compat-data": { "version": "7.21.4", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.4.tgz", @@ -125,12 +197,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.4.tgz", - "integrity": "sha512-NieM3pVIYW2SwGzKoqfPrQsf4xGs9M9AIG3ThppsSRmO+m7eQhmI6amajKMUeIO37wFfsvnvcxQFx6x6iqxDnA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.21.4", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -272,9 +344,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" @@ -293,25 +365,25 @@ } }, "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -441,30 +513,30 @@ } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -509,13 +581,13 @@ } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -594,9 +666,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz", - "integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "devOptional": true, "bin": { "parser": "bin/babel-parser.js" @@ -1817,33 +1889,33 @@ } }, "node_modules/@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.4.tgz", - "integrity": "sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.4", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.4", - "@babel/types": "^7.21.4", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1861,13 +1933,13 @@ } }, "node_modules/@babel/types": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.4.tgz", - "integrity": "sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -4227,9 +4299,9 @@ } }, "node_modules/@types/express": { - "version": "4.17.17", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", - "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.20.tgz", + "integrity": "sha512-rOaqlkgEvOW495xErXMsmyX3WKBInbhG5eqojXYi3cGUaLoRDlXa5d52fkfWZT963AZ3v2eZ4MbKE6WpDAGVsw==", "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", @@ -7917,9 +7989,9 @@ } }, "node_modules/image-hash": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/image-hash/-/image-hash-5.3.1.tgz", - "integrity": "sha512-tIOI//XqSnuzb60PBGPoulXNWWAZ2gww2z9P2VYgLpoCl3x8YwlhDVaR/1fgxTZObRshwEcaXYax4zF9MXBCKQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/image-hash/-/image-hash-5.3.2.tgz", + "integrity": "sha512-of8SekDXKFoaK4R93dP/Lzw6+NRGag8Jr9YlIIZ9jJVn9KYLfYVo/ARbKtbRn+tdTz/wDzBObx6yflKpLSYbxA==", "dependencies": { "@cwasm/webp": "^0.1.5", "file-type": "^16.5.3", @@ -12430,12 +12502,71 @@ } }, "@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "dev": true, "requires": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "@babel/compat-data": { @@ -12482,12 +12613,12 @@ } }, "@babel/generator": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.4.tgz", - "integrity": "sha512-NieM3pVIYW2SwGzKoqfPrQsf4xGs9M9AIG3ThppsSRmO+m7eQhmI6amajKMUeIO37wFfsvnvcxQFx6x6iqxDnA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "requires": { - "@babel/types": "^7.21.4", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -12597,9 +12728,9 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true }, "@babel/helper-explode-assignable-expression": { @@ -12612,22 +12743,22 @@ } }, "@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "requires": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" } }, "@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-member-expression-to-functions": { @@ -12724,24 +12855,24 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true }, "@babel/helper-validator-option": { @@ -12774,13 +12905,13 @@ } }, "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "dependencies": { @@ -12843,9 +12974,9 @@ } }, "@babel/parser": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz", - "integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "devOptional": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -13665,30 +13796,30 @@ } }, "@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "requires": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" } }, "@babel/traverse": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.4.tgz", - "integrity": "sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.4", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.4", - "@babel/types": "^7.21.4", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -13702,13 +13833,13 @@ } }, "@babel/types": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.4.tgz", - "integrity": "sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" } }, @@ -15746,9 +15877,9 @@ } }, "@types/express": { - "version": "4.17.17", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", - "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.20.tgz", + "integrity": "sha512-rOaqlkgEvOW495xErXMsmyX3WKBInbhG5eqojXYi3cGUaLoRDlXa5d52fkfWZT963AZ3v2eZ4MbKE6WpDAGVsw==", "requires": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", @@ -18585,9 +18716,9 @@ "dev": true }, "image-hash": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/image-hash/-/image-hash-5.3.1.tgz", - "integrity": "sha512-tIOI//XqSnuzb60PBGPoulXNWWAZ2gww2z9P2VYgLpoCl3x8YwlhDVaR/1fgxTZObRshwEcaXYax4zF9MXBCKQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/image-hash/-/image-hash-5.3.2.tgz", + "integrity": "sha512-of8SekDXKFoaK4R93dP/Lzw6+NRGag8Jr9YlIIZ9jJVn9KYLfYVo/ARbKtbRn+tdTz/wDzBObx6yflKpLSYbxA==", "requires": { "@cwasm/webp": "^0.1.5", "file-type": "^16.5.3", diff --git a/functions/package.json b/functions/package.json index 373dc964..6a951d2a 100644 --- a/functions/package.json +++ b/functions/package.json @@ -39,7 +39,7 @@ "@babel/core": "^7.21.4", "@babel/preset-env": "^7.21.4", "@babel/preset-typescript": "^7.21.4", - "@types/express": "^4.17.17", + "@types/express": "^4.17.20", "@types/jest": "^29.5.1", "@types/node-telegram-bot-api": "^0.61.8", "@types/supertest": "^2.0.12", diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/whatsapp.ts index d88fc2fa..db013dbd 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/whatsapp.ts @@ -6,16 +6,45 @@ import { handleSpecialCommands } from "./specialCommands" import { publishToTopic } from "../common/pubsub" import { onRequest } from "firebase-functions/v2/https" import { checkMessageId } from "../common/utils" +import { Request, Response } from "express" const runtimeEnvironment = defineString("ENVIRONMENT") +const webhookPath = process.env.WEBHOOK_PATH + if (!admin.apps.length) { admin.initializeApp() } const app = express() -// Accepts POST requests at /webhook endpoint -app.post("/whatsapp", async (req, res) => { +const getHandler = async (req: Request, res: Response) => { + /** + * UPDATE YOUR VERIFY TOKEN + *This will be the Verify Token value when you set up webhook + **/ + const verifyToken = process.env.VERIFY_TOKEN + // Parse params from the webhook verification request + const mode = req.query["hub.mode"] + const token = req.query["hub.verify_token"] + const challenge = req.query["hub.challenge"] + + // Check if a token and mode were sent + if (mode && token) { + // Check the mode and token sent are correct + if (mode === "subscribe" && token === verifyToken) { + // Respond with 200 OK and challenge token from the request + functions.logger.log("WEBHOOK_VERIFIED") + res.status(200).send(challenge) + } else { + // Responds with '403 Forbidden' if verify tokens do not match + res.sendStatus(403) + } + } else { + res.sendStatus(400) + } +} + +const postHandler = 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 @@ -108,7 +137,16 @@ app.post("/whatsapp", async (req, res) => { functions.logger.log(JSON.stringify(req.body, null, 2)) res.sendStatus(404) } -}) +} + +// Accepts POST requests at /webhook endpoint +// Note: TODO: Will delete after webhook is pointed to new endpoint and everything is stable +app.post("/whatsapp", postHandler) +app.get("/whatsapp", getHandler) + +// Accepts POST requests at /{webhookPath} endpoint +app.post(`/${webhookPath}`, postHandler) +app.get(`/${webhookPath}`, getHandler) app.post("/telegram", async (req, res) => { const db = admin.firestore() @@ -118,32 +156,6 @@ app.post("/telegram", async (req, res) => { // 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 -app.get("/whatsapp", (req, res) => { - /** - * UPDATE YOUR VERIFY TOKEN - *This will be the Verify Token value when you set up webhook - **/ - const verifyToken = process.env.VERIFY_TOKEN - // Parse params from the webhook verification request - const mode = req.query["hub.mode"] - const token = req.query["hub.verify_token"] - const challenge = req.query["hub.challenge"] - - // Check if a token and mode were sent - if (mode && token) { - // Check the mode and token sent are correct - if (mode === "subscribe" && token === verifyToken) { - // Respond with 200 OK and challenge token from the request - functions.logger.log("WEBHOOK_VERIFIED") - res.status(200).send(challenge) - } else { - // Responds with '403 Forbidden' if verify tokens do not match - res.sendStatus(403) - } - } else { - res.sendStatus(400) - } -}) const webhookHandlerV2 = onRequest( { From d484351e669d45cbf1ba70fadb1aa6ee3388af11 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 25 Oct 2023 17:39:35 +0800 Subject: [PATCH 05/36] Change function ingress settings --- functions/src/definitions/webhookHandlers/whatsapp.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/whatsapp.ts index db013dbd..f11bbfc8 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/whatsapp.ts @@ -159,6 +159,7 @@ app.post("/telegram", async (req, res) => { const webhookHandlerV2 = onRequest( { + ingressSettings: "ALLOW_INTERNAL_AND_GCLB", secrets: [ "WHATSAPP_USER_BOT_PHONE_NUMBER_ID", "WHATSAPP_CHECKERS_BOT_PHONE_NUMBER_ID", From effdf3f3cd03d35f687038e371cc7a7d524c4e20 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 25 Oct 2023 20:06:02 +0800 Subject: [PATCH 06/36] changed project from nonprod to uat --- .firebaserc | 4 ++-- functions/{.env.checkmate-nonprod => .env.checkmate-uat} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename functions/{.env.checkmate-nonprod => .env.checkmate-uat} (100%) diff --git a/.firebaserc b/.firebaserc index 958a695e..80edbbab 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,8 +1,8 @@ { "projects": { "default": "checkmate-373101", - "nonprod": "checkmate-nonprod", - "prod": "checkmate-373101" + "prod": "checkmate-373101", + "uat": "checkmate-uat" }, "targets": {}, "etags": {} diff --git a/functions/.env.checkmate-nonprod b/functions/.env.checkmate-uat similarity index 100% rename from functions/.env.checkmate-nonprod rename to functions/.env.checkmate-uat From edbf97de9b429f25007d67614c3d6f180f69e1e2 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 25 Oct 2023 20:12:44 +0800 Subject: [PATCH 07/36] set nonprod ingress setting appropriately --- functions/src/definitions/webhookHandlers/whatsapp.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/whatsapp.ts index f11bbfc8..c4f7bc25 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/whatsapp.ts @@ -11,6 +11,8 @@ import { Request, Response } from "express" const runtimeEnvironment = defineString("ENVIRONMENT") const webhookPath = process.env.WEBHOOK_PATH +const ingressSetting = + process.env.ENVIRONMENT === "PROD" ? "ALLOW_INTERNAL_AND_GCLB" : "ALLOW_ALL" if (!admin.apps.length) { admin.initializeApp() @@ -159,7 +161,7 @@ app.post("/telegram", async (req, res) => { const webhookHandlerV2 = onRequest( { - ingressSettings: "ALLOW_INTERNAL_AND_GCLB", + ingressSettings: ingressSetting, secrets: [ "WHATSAPP_USER_BOT_PHONE_NUMBER_ID", "WHATSAPP_CHECKERS_BOT_PHONE_NUMBER_ID", From 17c3064f69a2c16be1244a8ccbefada42c825fbb Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 25 Oct 2023 20:14:14 +0800 Subject: [PATCH 08/36] ingress setting change --- functions/src/definitions/webhookHandlers/whatsapp.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/whatsapp.ts index c4f7bc25..c29031f1 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/whatsapp.ts @@ -14,6 +14,8 @@ const webhookPath = process.env.WEBHOOK_PATH const ingressSetting = process.env.ENVIRONMENT === "PROD" ? "ALLOW_INTERNAL_AND_GCLB" : "ALLOW_ALL" +console.log(ingressSetting) + if (!admin.apps.length) { admin.initializeApp() } From dcc43caa574be2aa2c84c16d93fbe0f2285091ec Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 25 Oct 2023 20:14:55 +0800 Subject: [PATCH 09/36] removed log --- functions/src/definitions/webhookHandlers/whatsapp.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/whatsapp.ts index c29031f1..c4f7bc25 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/whatsapp.ts @@ -14,8 +14,6 @@ const webhookPath = process.env.WEBHOOK_PATH const ingressSetting = process.env.ENVIRONMENT === "PROD" ? "ALLOW_INTERNAL_AND_GCLB" : "ALLOW_ALL" -console.log(ingressSetting) - if (!admin.apps.length) { admin.initializeApp() } From 437ecf972ff902111d865db8a135f3d76b1456c8 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Thu, 26 Oct 2023 20:18:37 +0800 Subject: [PATCH 10/36] added variable to .env.local.test --- functions/.env.local.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/.env.local.test b/functions/.env.local.test index 541462fd..9b774d21 100644 --- a/functions/.env.local.test +++ b/functions/.env.local.test @@ -12,4 +12,5 @@ TYPESENSE_PROTOCOL=http EMBEDDER_HOST=http://embedder-server:12344 TELEGRAM_REPORT_CHANNEL_ID=111111111 TEST_IMAGE_URL=TEST -HASHIDS_SALT=SALT \ No newline at end of file +HASHIDS_SALT=SALT +WEBHOOK_PATH=whatsapp \ No newline at end of file From 064c36bc83c55319075d858249b764493b23f74d Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 11:11:51 +0800 Subject: [PATCH 11/36] updated firebase deploy for nonprod setup --- .github/workflows/firebase-deploy.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/firebase-deploy.yml b/.github/workflows/firebase-deploy.yml index 83752623..f8bb55bc 100644 --- a/.github/workflows/firebase-deploy.yml +++ b/.github/workflows/firebase-deploy.yml @@ -25,7 +25,11 @@ jobs: ${{ runner.os }}-node- - name: Create env file run: | - echo "${{ secrets.ENV_FILE }}" > .env + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + echo "${{ secrets.ENV_FILE }}" > .env + else + echo "${{ secrets.ENV_FILE_NONPROD }}" > .env + fi working-directory: functions - name: Build Cloud Functions run: npm ci @@ -39,6 +43,14 @@ jobs: fi - name: Install Firebase CLI run: npm install -g firebase-tools + - name: Set Firebase project + run: | + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + firebase use prod + else + firebase use uat + fi + working-directory: functions - name: Deploy Cloud Functions run: export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json && npm run deploy working-directory: functions From 8bd859bf18bc1899d5417b96f5eced2de42094ca Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 11:13:04 +0800 Subject: [PATCH 12/36] removed hardcoded /whatsapp path --- functions/src/definitions/webhookHandlers/whatsapp.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/functions/src/definitions/webhookHandlers/whatsapp.ts b/functions/src/definitions/webhookHandlers/whatsapp.ts index c4f7bc25..7b7b0455 100644 --- a/functions/src/definitions/webhookHandlers/whatsapp.ts +++ b/functions/src/definitions/webhookHandlers/whatsapp.ts @@ -141,11 +141,6 @@ const postHandler = async (req: Request, res: Response) => { } } -// Accepts POST requests at /webhook endpoint -// Note: TODO: Will delete after webhook is pointed to new endpoint and everything is stable -app.post("/whatsapp", postHandler) -app.get("/whatsapp", getHandler) - // Accepts POST requests at /{webhookPath} endpoint app.post(`/${webhookPath}`, postHandler) app.get(`/${webhookPath}`, getHandler) From 81bc9667a0328a9f47814d3fdd21af5761250fdc Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 11:13:25 +0800 Subject: [PATCH 13/36] edited tests for nonprod environment --- functions/.secret.local.test | 2 +- functions/package.json | 2 +- .../checkmate.postman_collection.json | 498 +++++++++--------- integration-tests/env.json | 12 +- 4 files changed, 262 insertions(+), 252 deletions(-) diff --git a/functions/.secret.local.test b/functions/.secret.local.test index 82cfc551..d2f77eb3 100644 --- a/functions/.secret.local.test +++ b/functions/.secret.local.test @@ -4,7 +4,7 @@ WHATSAPP_TOKEN=WHATSAPP_TOKEN TELEGRAM_CHECKER_BOT_TOKEN=TELEGRAM_CHECKER_BOT_TOKEN TELEGRAM_REPORT_BOT_TOKEN=TELEGRAM_REPORT_BOT_TOKEN VERIFY_TOKEN=VERIFY_TOKEN -BITLY_TOKEN=BITLY_TOKEN +OPENAI_API_KEY=OPEN_API_KEY TYPESENSE_TOKEN=TYPESENSE_TOKEN ML_SERVER_TOKEN=ML_SERVER_TOKEN TELEGRAM_BOT_TOKEN=TELEGRAM_BOT_TOKEN diff --git a/functions/package.json b/functions/package.json index 6a951d2a..55d4746f 100644 --- a/functions/package.json +++ b/functions/package.json @@ -3,7 +3,7 @@ "description": "Cloud Functions for Firebase", "scripts": { "lint": "", - "serve": "firebase emulators:start", + "serve": "firebase emulators:start --project checkmate-uat", "shell": "firebase functions:shell", "start": "npm run shell", "predeploy": "npm run build", diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 6873384b..9ceb7233 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "5218f5ab-c512-43d1-b8a3-0831e12514c1", + "_postman_id": "f9991f6c-049a-4e5c-be8e-a80284402235", "name": "checkmate", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "25230076" @@ -32,12 +32,12 @@ "method": "GET", "header": [], "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/healthcheck", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "healthcheck" ] @@ -97,15 +97,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -147,14 +147,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents:listCollectionIds", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents:listCollectionIds" @@ -215,15 +215,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -334,15 +334,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -467,15 +467,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -599,15 +599,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -716,15 +716,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -835,15 +835,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -973,15 +973,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -1118,14 +1118,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -1189,15 +1189,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -1380,15 +1380,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -1551,15 +1551,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -1998,15 +1998,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -2188,15 +2188,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -2393,15 +2393,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -2578,15 +2578,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -2631,14 +2631,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -2778,15 +2778,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -2930,15 +2930,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -3060,15 +3060,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -3202,15 +3202,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -3330,15 +3330,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -3520,15 +3520,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -3725,15 +3725,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -3906,15 +3906,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -4033,15 +4033,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -4223,15 +4223,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -4428,15 +4428,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -4815,15 +4815,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -4915,14 +4915,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -4984,15 +4984,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -5111,15 +5111,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -5243,15 +5243,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -5689,15 +5689,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -5884,15 +5884,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -6046,14 +6046,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -6113,15 +6113,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -6254,15 +6254,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -6386,14 +6386,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -6439,15 +6439,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -6634,15 +6634,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -6902,15 +6902,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -7097,15 +7097,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -7280,15 +7280,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -7411,15 +7411,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -7857,15 +7857,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -8047,15 +8047,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -8251,15 +8251,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -8433,15 +8433,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -8486,14 +8486,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -8632,15 +8632,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -8756,14 +8756,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -8818,15 +8818,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -8996,15 +8996,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -9128,14 +9128,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -9196,15 +9196,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -9318,14 +9318,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -9371,15 +9371,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -9561,15 +9561,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -9763,15 +9763,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -9941,15 +9941,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -10070,15 +10070,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -10260,15 +10260,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -10464,15 +10464,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -10752,15 +10752,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -10880,15 +10880,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11043,15 +11043,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11161,15 +11161,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11279,15 +11279,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11397,15 +11397,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11515,15 +11515,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11695,15 +11695,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11819,15 +11819,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -11988,15 +11988,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -12130,14 +12130,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -12201,15 +12201,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -12343,14 +12343,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/users/{{USER_1_NUMBER}}", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -12409,15 +12409,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -12513,14 +12513,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -12556,14 +12556,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages/{{infoMessageId}}/instances", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -12612,15 +12612,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -12663,14 +12663,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -12706,14 +12706,14 @@ } ], "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents/messages", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents", @@ -12773,15 +12773,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -12824,15 +12824,15 @@ } }, "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", "host": [ "{{FUNCTIONS_URL}}" ], "path": [ - "checkmate-373101", + "{{PROJECT_ID}}", "asia-southeast1", "webhookHandlerV2", - "whatsapp" + "{{WEBHOOK_PATH}}" ] } }, @@ -12883,14 +12883,14 @@ } }, "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents:runQuery", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents:runQuery" @@ -12943,14 +12943,14 @@ } }, "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "raw": "{{FIRESTORE_URL}}/v1/projects/{{PROJECT_ID}}/databases/(default)/documents:runQuery", "host": [ "{{FIRESTORE_URL}}" ], "path": [ "v1", "projects", - "checkmate-373101", + "{{PROJECT_ID}}", "databases", "(default)", "documents:runQuery" diff --git a/integration-tests/env.json b/integration-tests/env.json index 715dbdf6..013d63d5 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -13,6 +13,16 @@ "value": "wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==", "enabled": true }, + { + "key": "PROJECT_ID", + "value": "checkmate-uat", + "enabled": true + }, + { + "key": "WEBHOOK_PATH", + "value": "whatsapp", + "enabled": true + }, { "key": "FIRESTORE_URL", "value": "http://localhost:18080", @@ -382,4 +392,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 bc4cbc0e408120c938647c2c7a7dbb4d9207c361 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 11:34:26 +0800 Subject: [PATCH 14/36] edited run-tests --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a8b34330..90f72ec3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,7 +17,7 @@ jobs: - name: Start docker compose for testing run: docker-compose -f docker-compose-base.yml up -d - name: Wait for emulator to start - run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:15001/checkmate-373101/asia-southeast1/healthcheck)" != "200" ]]; do sleep 1; done' || false + run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:15001/checkmate-uat/asia-southeast1/healthcheck)" != "200" ]]; do sleep 1; done' || false - name: Install newman and lodash run: npm ci working-directory: integration-tests From f01f28ad65f576b78afe0ff337995f2ca4ab6434 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 14:16:33 +0800 Subject: [PATCH 15/36] added image-caveat --- functions/src/definitions/common/constants.ts | 16 ++++++++++------ .../src/definitions/common/responseUtils.ts | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/functions/src/definitions/common/constants.ts b/functions/src/definitions/common/constants.ts index 6c5ec081..97945986 100644 --- a/functions/src/definitions/common/constants.ts +++ b/functions/src/definitions/common/constants.ts @@ -5,13 +5,13 @@ Please do not spread it further⛔️⛔️ Thank you for keeping Singapore informed!`, - MISLEADING: `{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️ + MISLEADING: `{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}} Please take it with a pinch of salt and think twice before spreading it further🚧🚧. Thank you for keeping Singapore informed!`, - ACCURATE: `{{thanks}}{{matched}}{{methodology}}*accurate*.✅ + ACCURATE: `{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}} Thank you for keeping Singapore informed!`, @@ -23,7 +23,7 @@ You can try sending the message in again, or report the error via our form at ht "Hello! 👋 Thanks for sending this in! Our *CheckMates🕵🏻 will review this* and *provide the results soon*.", //button - SCAM: `{{thanks}}{{matched}}{{methodology}}*a scam*!🚫 + SCAM: `{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}} We recommend you do not engage further⛔️⛔️ @@ -32,7 +32,7 @@ CheckMate will report suspicious messages to ScamShield (https://scamshield.org. To avoid reporting this message, select "Don't report this" below.`, //button - ILLICIT: `{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨 + ILLICIT: `{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}} We recommend you do not engage further⛔️⛔️ @@ -40,13 +40,13 @@ CheckMate will report suspicious messages to ScamShield (https://scamshield.org. To avoid reporting this message, select "Don't report this" below.`, - SPAM: `{{thanks}}{{matched}}{{methodology}}spam!🚧 + SPAM: `{{thanks}}{{matched}}{{methodology}}spam!🚧{{image_caveat}} It's likely harmless, but you should always make sure 🧐 Thank you for keeping Singapore safe!`, - LEGITIMATE: `{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅ + LEGITIMATE: `{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}} Thank you for keeping Singapore safe!`, @@ -62,6 +62,10 @@ Thank you for keeping Singapore safe!`, THANKS_DELAYED: `Thanks for waiting! `, + IMAGE_CAVEAT: ` + +This assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.`, + METHODOLOGY_HUMAN: `Our CheckMates have reviewed this message and think it's `, METHODOLOGY_AUTO: `Based on pattern matching, our auto-classifier is confident that this message is `, diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index ea45bb14..6a542b1e 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -627,6 +627,7 @@ async function respondToInstance( const isMachineCategorised = parentMessageSnap.get("isMachineCategorised") const instanceCount = parentMessageSnap.get("instanceCount") const responseCount = await getCount(parentMessageRef, "responses") + const isImage = data?.type === "image" function getFinalResponseText(responseText: string) { return responseText @@ -646,6 +647,7 @@ async function respondToInstance( ? responses.METHODOLOGY_AUTO : responses.METHODOLOGY_HUMAN ) + .replace("{{image_caveat}}", isImage ? responses.IMAGE_CAVEAT : "") } if (!isAssessed && !forceReply) { From cd65a1a61ba8506c7320c43dd00620927ca4aaa7 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 15:27:34 +0800 Subject: [PATCH 16/36] bugfix: msgRef not created when extractedMsg falsy --- functions/src/definitions/eventHandlers/userHandlers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/definitions/eventHandlers/userHandlers.ts b/functions/src/definitions/eventHandlers/userHandlers.ts index d565ba4e..141e5263 100644 --- a/functions/src/definitions/eventHandlers/userHandlers.ts +++ b/functions/src/definitions/eventHandlers/userHandlers.ts @@ -606,7 +606,7 @@ async function newImageInstanceHandler({ machineCategory ) } - if (extractedMessage) messageRef = db.collection("messages").doc() + messageRef = db.collection("messages").doc() messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: isMachineAssessed, From dc2e563498df3ec361e69a40985bf80f50eb3c22 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 15:28:33 +0800 Subject: [PATCH 17/36] catch errors with sendImageMessage --- .../src/definitions/common/responseUtils.ts | 1 + .../eventHandlers/checkerHandlers.ts | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index 6a542b1e..be9becad 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -630,6 +630,7 @@ async function respondToInstance( const isImage = data?.type === "image" function getFinalResponseText(responseText: string) { + console.log(isImage) return responseText .replace( "{{thanks}}", diff --git a/functions/src/definitions/eventHandlers/checkerHandlers.ts b/functions/src/definitions/eventHandlers/checkerHandlers.ts index bb7c4ba6..f5e0bc4e 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlers.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlers.ts @@ -225,18 +225,32 @@ async function onFactCheckerYes( latestInstanceSnap.get("storageUrl") ) if (temporaryUrl) { - res = await sendImageMessage( - "factChecker", - from, - temporaryUrl, - latestInstanceSnap.get("caption"), - null, - platform - ) - if (!res) { + try { + res = await sendImageMessage( + "factChecker", + from, + temporaryUrl, + latestInstanceSnap.get("caption"), + null, + platform + ) + if (!res) { + return + } + updateObj.sentMessageId = res.data.messages[0].id + } catch { + functions.logger.error( + `Problem sending message ${messageRef.id} to ${from}}` + ) + await sendTextMessage( + "factChecker", + from, + "Sorry, an error occured", + null, + platform + ) return } - updateObj.sentMessageId = res.data.messages[0].id } else { functions.logger.error( `Problem creating URL while sending message ${messageRef.id} to ${from}}` From 1454ab74f883e41749cf00020e90382b8339409f Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 28 Oct 2023 15:29:13 +0800 Subject: [PATCH 18/36] get rid of console.log --- functions/src/definitions/common/responseUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index be9becad..6a542b1e 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -630,7 +630,6 @@ async function respondToInstance( const isImage = data?.type === "image" function getFinalResponseText(responseText: string) { - console.log(isImage) return responseText .replace( "{{thanks}}", From 64a55dc906eb7595f398ef11a07b0e2b0f2d9646 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 29 Oct 2023 10:03:46 +0800 Subject: [PATCH 19/36] moved nonprod surveylikehood to utils --- functions/src/definitions/common/constants.ts | 4 +--- functions/src/definitions/common/utils.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/functions/src/definitions/common/constants.ts b/functions/src/definitions/common/constants.ts index 97945986..7bbb0603 100644 --- a/functions/src/definitions/common/constants.ts +++ b/functions/src/definitions/common/constants.ts @@ -220,8 +220,6 @@ const FACTCHECKER_BOT_RESPONSES = { "Great, you have no further messages to assess. Keep it up!💪", } -const env = process.env.ENVIRONMENT - const thresholds = { endVote: 0.5, endVoteSus: 0.2, @@ -236,7 +234,7 @@ const thresholds = { falseUpperBound: 1.5, misleadingUpperBound: 3.5, sendInterimMinVotes: 1, - surveyLikelihood: env !== "PROD" ? 1 : 0.25, + surveyLikelihood: 0.25, satisfactionSurveyCooldownDays: 30, } diff --git a/functions/src/definitions/common/utils.ts b/functions/src/definitions/common/utils.ts index 8d401365..3cacb9db 100644 --- a/functions/src/definitions/common/utils.ts +++ b/functions/src/definitions/common/utils.ts @@ -9,6 +9,8 @@ if (!admin.apps.length) { admin.initializeApp() } +const env = process.env.ENVIRONMENT + function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)) } @@ -17,7 +19,12 @@ const getThresholds = async function () { const db = admin.firestore() const theresholdsRef = db.doc("systemParameters/thresholds") const theresholdsSnap = await theresholdsRef.get() - return (theresholdsSnap.data() as typeof thresholds | undefined) ?? thresholds + const returnThresholds = + (theresholdsSnap.data() as typeof thresholds | undefined) ?? thresholds + if (env !== "PROD") { + returnThresholds.surveyLikelihood = 1 + } + return returnThresholds } function normalizeSpaces(str: string) { From fed4683646f328231296a3b6ae67053a62f97d28 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 29 Oct 2023 11:30:34 +0800 Subject: [PATCH 20/36] multilingual framework --- functions/src/definitions/common/constants.ts | 241 ------------------ .../common/parameters/checkerResponses.json | 16 ++ .../common/parameters/thresholds.json | 17 ++ .../common/parameters/userResponses.json | 190 ++++++++++++++ .../src/definitions/common/responseUtils.ts | 47 +++- functions/src/definitions/common/utils.ts | 2 +- .../webhookHandlers/specialCommands.ts | 10 +- integration-tests/env.json | 8 +- integration-tests/update-env.ts | 2 + 9 files changed, 268 insertions(+), 265 deletions(-) delete mode 100644 functions/src/definitions/common/constants.ts create mode 100644 functions/src/definitions/common/parameters/checkerResponses.json create mode 100644 functions/src/definitions/common/parameters/thresholds.json create mode 100644 functions/src/definitions/common/parameters/userResponses.json diff --git a/functions/src/definitions/common/constants.ts b/functions/src/definitions/common/constants.ts deleted file mode 100644 index 7bbb0603..00000000 --- a/functions/src/definitions/common/constants.ts +++ /dev/null @@ -1,241 +0,0 @@ -const USER_BOT_RESPONSES = { - UNTRUE: `{{thanks}}{{matched}}{{methodology}}*untrue*.❌ - -Please do not spread it further⛔️⛔️ - -Thank you for keeping Singapore informed!`, - - MISLEADING: `{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}} - -Please take it with a pinch of salt and think twice before spreading it further🚧🚧. - -Thank you for keeping Singapore informed!`, - - ACCURATE: `{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}} - -Thank you for keeping Singapore informed!`, - - ERROR: `Oops, we encountered an error assessing this message. - -You can try sending the message in again, or report the error via our form at https://bit.ly/checkmate-feedback. Sorry about that! 😔`, - - MESSAGE_NOT_YET_ASSESSED: - "Hello! 👋 Thanks for sending this in! Our *CheckMates🕵🏻 will review this* and *provide the results soon*.", - - //button - SCAM: `{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}} - -We recommend you do not engage further⛔️⛔️ - -CheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf. - -To avoid reporting this message, select "Don't report this" below.`, - - //button - ILLICIT: `{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}} - -We recommend you do not engage further⛔️⛔️ - -CheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf. - -To avoid reporting this message, select "Don't report this" below.`, - - SPAM: `{{thanks}}{{matched}}{{methodology}}spam!🚧{{image_caveat}} - -It's likely harmless, but you should always make sure 🧐 - -Thank you for keeping Singapore safe!`, - - LEGITIMATE: `{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}} - -Thank you for keeping Singapore safe!`, - - UNSURE: `{{thanks}} - -Unfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too! 😞 - -If 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. - -Thank you for keeping Singapore safe!`, - - THANKS_IMMEDIATE: `Thanks for sending this in! `, - - THANKS_DELAYED: `Thanks for waiting! `, - - IMAGE_CAVEAT: ` - -This assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.`, - - METHODOLOGY_HUMAN: `Our CheckMates have reviewed this message and think it's `, - - METHODOLOGY_AUTO: `Based on pattern matching, our auto-classifier is confident that this message is `, - - //not used - MATCHED: `In fact, other users have sent this message in {{numberInstances}} times. `, - - UNSUPPORTED_TYPE: - "Sorry, CheckMate currently doesn't support this type of message.", - - SCAMSHIELD_EXPLAINER: - "ScamShield is an anti-scam product developed by the National Crime Prevention Council and Open Government Products. You can learn more at https://scamshield.org.sg.", - - //not used - STATS_TEMPLATE: `{{top}}% of our CheckMates identified this as *{{category1}}**{{info_placeholder}}*. *{{second}}*% felt this was *{{category2}}*.`, - - //button - INTERIM_TEMPLATE: `At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think is that this {{prelim_assessment}}{{info_placeholder}}. - -NOTE: 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}}`, - - INTERIM_TEMPLATE_UNSURE: `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. - -If 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.`, - - INTERIM_FEEDBACK: ` - -Thanks 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.`, - - //button - INTERIM_PROMPT: `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. - -You 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! 💪🏼`, - - INTERIM_USEFUL: `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. - -In the meantime, if you'd like another update after more votes come in, just tap the button below to request one.`, - - INTERIM_NOT_USEFUL: `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. - -If you'd like still another update after more votes come in, just tap the button below to request one.`, - - ALREADY_REPLIED: `CheckMate has already provided a final response to this message.`, - - SCAMSHIELD_ON_DECLINE: `No worries! We will not send your message to ScamShield. Thank you for sharing this message with us, and for keeping Singapore safe!`, - - //menu text list - MENU: `{{prefix}} - -If you know what to do, please go ahead! Else, select "View Menu" below to see what CheckMate can do! 👈 - -Do note that CheckMate *is designed to check dubious messages you send in. It cannot converse freely with you*. - -Anytime you need a refresher on what CheckMate can do, type "menu" to get here again! 😊`, - - //menu text list prefix - NEW_USER_MENU_PREFIX: `Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊.`, - - //menu text list prefix - IRRELEVANT_MENU_PREFIX: `Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕`, - - //menu text list prefix - IRRELEVANT_AUTO_MENU_PREFIX: `Hmm...There doesn't seem to be anything to assess in this message.😕`, - - //menu text list prefix - MENU_PREFIX: `Hi! Thanks for using CheckMate. 🙏🏻`, - - PROCEED_TO_SEND: `Nice! Just send/forward us the message. We'll help you check and/or report it! ✅✅ - -If 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. - -One 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!`, - - HOW_TO: `Check out https://youtube.com/shorts/gFeO_qFOchs?feature=share to see how CheckMate works! - -Done? You're now ready to use CheckMate! Let's do our part in the fight against scams and misinformation! 💪`, - - LEARN_MORE: `To learn more about CheckMate, you can visit our website at https://checkmate.sg`, - - FEEDBACK: `You can submit feedback at https://bit.ly/checkmate-feedback. Rest assured, we'll read it ASAP!`, - - DISPUTE: `Thanks for letting us know! Our CheckMates will review the assessment of this message.`, - - CONTACT: `Here's our contact! Do add us to your contact list so you can find us in future. 😊`, - - REFERRAL: `Have you started checking and reporting suspicious messages using CheckMate yet? Sign up by clicking this link and sending in the pre-loaded message!! {{link}}`, - - REFERRAL_PREPOPULATED_PREFIX: `Welcome to CheckMate! Send in this entire message (including the code) to get started, and credit your friend with your referral. Code:`, - - GENERIC_PREPOPULATED_PREFIX: `Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:`, - - REFERRAL_INVALID: `Sorry, referrals are only credited upon your first interaction with CheckMate.`, - - GENERIC_ERROR: `Sorry, an error occured. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!`, - - SATISFACTION_SURVEY: `Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us. - -On a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?`, - - SATISFACTION_SURVEY_THANKS: `Thanks for your feedback!`, - - HOWD_WE_TELL: `*This is an experimental feature powered by generative AI*. Do let us know if it was useful below! - -{{rationalisation}}`, - RATIONALISATION_USEFUL: `Thanks for your valuable feedback!`, - - RATIONALISATION_NOT_USEFUL: `Sorry to hear that, but thanks anyway for your valuable feedback!`, -} - -const FACTCHECKER_BOT_RESPONSES = { - VOTE_NO: - "No problem! If you wish to come back and assess the message, you may do so by clicking the 'yes' button. See you soon!😊", - - //text list - FACTCHECK_PROMPT: - "Please assess the veracity of the claim(s) in this message on a scale from 0 to 5, where 0 means the claim(s) are entirely false, and 5 means the claim(s) are entirely true.", - - //text list - L1_ASSESSMENT_PROMPT: - "Which of these categories best describes this message?", - - //text list - L2_OTHERS_ASSESSEMENT_PROMPT: - "Which of these subcategories best describes this message?", - - RESPONSE_RECORDED: - "Got it! Your response has been recorded. Thank you for playing your part in the fight against scams and misinformation, one message at a time! 💪", - - HOLD_FOR_NEXT_POLL: - "Got it👍! Please hold for another poll to vote on how true the message is.", - - HOLD_FOR_L2_CATEGORISATION: "Got it👍! Please hold for another selection.", - - ONBOARDING_1: - "Welcome to our community of CheckMates! 👋🏻 We're grateful to have you on board to combat misinformation and scams. 🙇‍♀️🙇🏻 We'd love to get to know you better - could you *reply to this message* and share your name with us? (Reply to this message by swiping right)!", - - ONBOARDING_2: - "Thank you and welcome, {{name}}! We're thrilled to have you on board as we work together to combat misinformation and scams.😊 By using the CheckMate bot, you are accepting our privacy policy which can be found here: https://bit.ly/checkmate-privacy", - - ONBOARDING_3: `To ensure you're equipped with the necessary skills to identify misinformation and scams, let's start with a quick quiz. 📝 Simply follow the link (https://bit.ly/checkmates-quiz) to take the quiz. Once you've completed it, come back to this chat and click on "I've done the quiz!" to notify me. Let's get started! 🤖`, - - ONBOARDING_4: `Awesome! Now that you know how to identify misinformation and scams, you are ready to help us combat them! 🙌🏻 If you haven't already, do join this WhatsApp group (https://bit.ly/checkmates-groupchat) that brings together all the other CheckMates and the core product team for updates and feedback. If you're looking for resources, you can visit our wiki page (https://bit.ly/checkmates-wiki). Thanks again for joining our community of CheckMates. Enjoy! 👋🏻🤖`, - - NOT_A_REPLY: - "Sorry, did you forget to reply to a message? You need to swipe right on the message to reply to it.", - - //button - OUTSTANDING_REMINDER: - "You have *{{num_outstanding}} remaining messages* to assess. Would you like to be sent the next one in line?", - - NO_OUTSTANDING: - "Great, you have no further messages to assess. Keep it up!💪", -} - -const thresholds = { - endVote: 0.5, - endVoteSus: 0.2, - endVoteUnsure: 0.8, - startVote: 1, - isSpam: 0.5, - isLegitimate: 0.5, - isInfo: 0.5, - isIrrelevant: 0.5, - isUnsure: 0.5, - isSus: 0.5, - falseUpperBound: 1.5, - misleadingUpperBound: 3.5, - sendInterimMinVotes: 1, - surveyLikelihood: 0.25, - satisfactionSurveyCooldownDays: 30, -} - -export { USER_BOT_RESPONSES, FACTCHECKER_BOT_RESPONSES, thresholds } diff --git a/functions/src/definitions/common/parameters/checkerResponses.json b/functions/src/definitions/common/parameters/checkerResponses.json new file mode 100644 index 00000000..2300193c --- /dev/null +++ b/functions/src/definitions/common/parameters/checkerResponses.json @@ -0,0 +1,16 @@ +{ + "VOTE_NO": "No problem! If you wish to come back and assess the message, you may do so by clicking the 'yes' button. See you soon!😊", + "FACTCHECK_PROMPT": "Please assess the veracity of the claim(s) in this message on a scale from 0 to 5, where 0 means the claim(s) are entirely false, and 5 means the claim(s) are entirely true.", + "L1_ASSESSMENT_PROMPT": "Which of these categories best describes this message?", + "L2_OTHERS_ASSESSEMENT_PROMPT": "Which of these subcategories best describes this message?", + "RESPONSE_RECORDED": "Got it! Your response has been recorded. Thank you for playing your part in the fight against scams and misinformation, one message at a time! 💪", + "HOLD_FOR_NEXT_POLL": "Got it👍! Please hold for another poll to vote on how true the message is.", + "HOLD_FOR_L2_CATEGORISATION": "Got it👍! Please hold for another selection.", + "ONBOARDING_1": "Welcome to our community of CheckMates! 👋🏻 We're grateful to have you on board to combat misinformation and scams. 🙇‍♀️🙇🏻 We'd love to get to know you better - could you *reply to this message* and share your name with us? (Reply to this message by swiping right)!", + "ONBOARDING_2": "Thank you and welcome, {{name}}! We're thrilled to have you on board as we work together to combat misinformation and scams.😊 By using the CheckMate bot, you are accepting our privacy policy which can be found here: https://bit.ly/checkmate-privacy", + "ONBOARDING_3": "To ensure you're equipped with the necessary skills to identify misinformation and scams, let's start with a quick quiz. 📝 Simply follow the link (https://bit.ly/checkmates-quiz) to take the quiz. Once you've completed it, come back to this chat and click on \"I've done the quiz!\" to notify me. Let's get started! 🤖", + "ONBOARDING_4": "Awesome! Now that you know how to identify misinformation and scams, you are ready to help us combat them! 🙌🏻 If you haven't already, do join this WhatsApp group (https://bit.ly/checkmates-groupchat) that brings together all the other CheckMates and the core product team for updates and feedback. If you're looking for resources, you can visit our wiki page (https://bit.ly/checkmates-wiki). Thanks again for joining our community of CheckMates. Enjoy! 👋🏻🤖", + "NOT_A_REPLY": "Sorry, did you forget to reply to a message? You need to swipe right on the message to reply to it.", + "OUTSTANDING_REMINDER": "You have *{{num_outstanding}} remaining messages* to assess. Would you like to be sent the next one in line?", + "NO_OUTSTANDING": "Great, you have no further messages to assess. Keep it up!💪" +} diff --git a/functions/src/definitions/common/parameters/thresholds.json b/functions/src/definitions/common/parameters/thresholds.json new file mode 100644 index 00000000..b78eab6f --- /dev/null +++ b/functions/src/definitions/common/parameters/thresholds.json @@ -0,0 +1,17 @@ +{ + "endVote": 0.5, + "endVoteSus": 0.2, + "endVoteUnsure": 0.8, + "startVote": 1, + "isSpam": 0.5, + "isLegitimate": 0.5, + "isInfo": 0.5, + "isIrrelevant": 0.5, + "isUnsure": 0.5, + "isSus": 0.5, + "falseUpperBound": 1.5, + "misleadingUpperBound": 3.5, + "sendInterimMinVotes": 1, + "surveyLikelihood": 1, + "satisfactionSurveyCooldownDays": 30 +} diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json new file mode 100644 index 00000000..70abd8d7 --- /dev/null +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -0,0 +1,190 @@ +{ + "UNTRUE": { + "en": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "cn": "占位符" + }, + "MISLEADING": { + "en": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", + "cn": "占位符" + }, + "ACCURATE": { + "en": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅\n\nThank you for keeping Singapore informed!", + "cn": "占位符" + }, + "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": "占位符" + }, + "MESSAGE_NOT_YET_ASSESSED": { + "en": "Hello! 👋 Thanks for sending this in! Our *CheckMates🕵🏻 will review this* and *provide the results soon*.", + "cn": "占位符" + }, + "SCAM": { + "en": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "cn": "占位符" + }, + "ILLICIT": { + "en": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "cn": "占位符" + }, + "SPAM": { + "en": "{{thanks}}{{matched}}{{methodology}}spam!🚧\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", + "cn": "占位符" + }, + "LEGITIMATE": { + "en": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅\n\nThank you for keeping Singapore safe!", + "cn": "占位符" + }, + "UNSURE": { + "en": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", + "cn": "占位符" + }, + "THANKS_IMMEDIATE": { + "en": "Thanks for sending this in! ", + "cn": "占位符" + }, + "THANKS_DELAYED": { + "en": "Thanks for waiting! ", + "cn": "占位符" + }, + "METHODOLOGY_HUMAN": { + "en": "Our CheckMates have reviewed this message and think it's ", + "cn": "占位符" + }, + "METHODOLOGY_AUTO": { + "en": "Based on pattern matching, our auto-classifier is confident that this message is ", + "cn": "占位符" + }, + "MATCHED": { + "en": "In fact, other users have sent this message in {{numberInstances}} times. ", + "cn": "占位符" + }, + "UNSUPPORTED_TYPE": { + "en": "Sorry, CheckMate currently doesn't support this type of message.", + "cn": "占位符" + }, + "SCAMSHIELD_EXPLAINER": { + "en": "ScamShield is an anti-scam product developed by the National Crime Prevention Council and Open Government Products. You can learn more at https://scamshield.org.sg.", + "cn": "占位符" + }, + "STATS_TEMPLATE": { + "en": "{{top}}% of our CheckMates identified this as *{{category1}}**{{info_placeholder}}*. *{{second}}*% felt this was *{{category2}}*.", + "cn": "占位符" + }, + "INTERIM_TEMPLATE": { + "en": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think is that this {{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": "占位符" + }, + "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": "占位符" + }, + "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": "占位符" + }, + "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": "占位符" + }, + "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": "占位符" + }, + "ALREADY_REPLIED": { + "en": "CheckMate has already provided a final response to this message.", + "cn": "占位符" + }, + "SCAMSHIELD_ON_DECLINE": { + "en": "No worries! We will not send your message to ScamShield. Thank you for sharing this message with us, and for keeping Singapore safe!", + "cn": "占位符" + }, + "MENU": { + "en": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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": "占位符" + }, + "NEW_USER_MENU_PREFIX": { + "en": "Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊.", + "cn": "占位符" + }, + "IRRELEVANT_MENU_PREFIX": { + "en": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", + "cn": "占位符" + }, + "IRRELEVANT_AUTO_MENU_PREFIX": { + "en": "Hmm...There doesn't seem to be anything to assess in this message.😕", + "cn": "占位符" + }, + "MENU_PREFIX": { + "en": "Hi! Thanks for using CheckMate. 🙏🏻", + "cn": "占位符" + }, + "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": "占位符" + }, + "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! 💪", + "cn": "占位符" + }, + "LEARN_MORE": { + "en": "To learn more about CheckMate, you can visit our website at https://checkmate.sg", + "cn": "占位符" + }, + "FEEDBACK": { + "en": "You can submit feedback at https://bit.ly/checkmate-feedback. Rest assured, we'll read it ASAP!", + "cn": "占位符" + }, + "DISPUTE": { + "en": "Thanks for letting us know! Our CheckMates will review the assessment of this message.", + "cn": "占位符" + }, + "CONTACT": { + "en": "Here's our contact! Do add us to your contact list so you can find us in future. 😊", + "cn": "占位符" + }, + "REFERRAL": { + "en": "Have you started checking and reporting suspicious messages using CheckMate yet? Sign up by clicking this link and sending in the pre-loaded message!! {{link}}", + "cn": "占位符" + }, + "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": "占位符" + }, + "GENERIC_PREPOPULATED_PREFIX": { + "en": "Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:", + "cn": "占位符" + }, + "REFERRAL_INVALID": { + "en": "Sorry, referrals are only credited upon your first interaction with CheckMate.", + "cn": "占位符" + }, + "GENERIC_ERROR": { + "en": "Sorry, an error occured. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", + "cn": "占位符" + }, + "SATISFACTION_SURVEY": { + "en": "Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us.\n\nOn a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?", + "cn": "占位符" + }, + "SATISFACTION_SURVEY_THANKS": { + "en": "Thanks for your feedback!", + "cn": "占位符" + }, + "HOWD_WE_TELL": { + "en": "*This is an experimental feature powered by generative AI*. Do let us know if it was useful below!\n \n{{rationalisation}}", + "cn": "占位符" + }, + "RATIONALISATION_USEFUL": { + "en": "Thanks for your valuable feedback!", + "cn": "占位符" + }, + "RATIONALISATION_NOT_USEFUL": { + "en": "Sorry to hear that, but thanks anyway for your valuable feedback!", + "cn": "占位符" + } +} diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index 6a542b1e..afe2fbb4 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -1,6 +1,7 @@ import * as functions from "firebase-functions" import * as admin from "firebase-admin" -import { USER_BOT_RESPONSES, FACTCHECKER_BOT_RESPONSES } from "./constants" +import USER_BOT_RESPONSES from "./parameters/userResponses.json" +import CHECKER_BOT_RESPONSES from "./parameters/checkerResponses.json" import { sendWhatsappButtonMessage, sendWhatsappTextListMessage, @@ -13,6 +14,17 @@ import { getCount } from "./counters" const db = admin.firestore() +type BotResponses = { + [key: string]: { + en: string + cn?: string + } +} + +type ResponseObject = { + [key: string]: string +} + function getInfoLiner(truthScore: null | number) { return `, with an average score of ${ typeof truthScore === "number" ? truthScore.toFixed(2) : "NA" @@ -82,25 +94,34 @@ async function respondToRationalisationFeedback( await sendWhatsappTextMessage("user", data.from, response) } -async function getResponsesObj( - botType: "factChecker" -): Promise -async function getResponsesObj( - botType: "user" -): Promise +async function getResponsesObj(botType: "factChecker"): Promise +async function getResponsesObj(botType: "user"): Promise async function getResponsesObj(botType: "user" | "factChecker" = "user") { let path - let fallbackResponses if (botType === "factChecker") { path = "systemParameters/factCheckerBotResponses" - fallbackResponses = FACTCHECKER_BOT_RESPONSES + const checkerResponseSnap = await db.doc(path).get() + return checkerResponseSnap.data() ?? CHECKER_BOT_RESPONSES } else { path = "systemParameters/userBotResponses" - fallbackResponses = USER_BOT_RESPONSES + const userResponseSnap = await db.doc(path).get() + const userResponseObject = userResponseSnap.data() ?? USER_BOT_RESPONSES + const language = "en" //TODO: change this to read from user DB + + const responseProxy = new Proxy(userResponseObject as BotResponses, { + get(target, prop: string) { + if (target[prop] && target[prop][language]) { + return target[prop][language] + } else if (target[prop] && target[prop]["en"]) { + // Fallback to English + return target[prop]["en"] + } + functions.logger.error(`Error getting ${prop} from user bot responses`) + return "error" // Or some default value or error handling + }, + }) + return responseProxy } - const defaultResponsesRef = db.doc(path) - const defaultResponsesSnap = await defaultResponsesRef.get() - return defaultResponsesSnap.data() ?? fallbackResponses } async function sendMenuMessage( diff --git a/functions/src/definitions/common/utils.ts b/functions/src/definitions/common/utils.ts index 3cacb9db..375da0f4 100644 --- a/functions/src/definitions/common/utils.ts +++ b/functions/src/definitions/common/utils.ts @@ -1,4 +1,4 @@ -import { thresholds } from "./constants" +import thresholds from "./parameters/thresholds.json" import * as admin from "firebase-admin" import { findPhoneNumbersInText } from "libphonenumber-js" import { createHash } from "crypto" diff --git a/functions/src/definitions/webhookHandlers/specialCommands.ts b/functions/src/definitions/webhookHandlers/specialCommands.ts index 919a1707..43897e4b 100644 --- a/functions/src/definitions/webhookHandlers/specialCommands.ts +++ b/functions/src/definitions/webhookHandlers/specialCommands.ts @@ -3,11 +3,9 @@ import * as admin from "firebase-admin" import { defineString } from "firebase-functions/params" import { WhatsappMessage } from "../../types" import { sendWhatsappTextMessage } from "../common/sendWhatsappMessage" -import { - USER_BOT_RESPONSES, - FACTCHECKER_BOT_RESPONSES, - thresholds, -} from "../common/constants" +import USER_BOT_RESPONSES from "../common/parameters/userResponses.json" +import CHECKER_BOT_RESPONSES from "../common/parameters/checkerResponses.json" +import thresholds from "../common/parameters/thresholds.json" import { interimPromptHandler } from "../batchJobs/batchJobs" const runtimeEnvironment = defineString("ENVIRONMENT") @@ -64,7 +62,7 @@ const mockDb = async function () { await systemParametersRef.doc("userBotResponses").set(USER_BOT_RESPONSES) await systemParametersRef .doc("factCheckerBotResponses") - .set(FACTCHECKER_BOT_RESPONSES) + .set(CHECKER_BOT_RESPONSES) await systemParametersRef.doc("supportedTypes").set({ whatsapp: ["text", "image"], }) diff --git a/integration-tests/env.json b/integration-tests/env.json index 013d63d5..ed518668 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -155,7 +155,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM", - "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧 \n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", + "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", "enabled": true }, { @@ -165,12 +165,12 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSURE", - "value": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too! 😞\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.\n\nThank you for keeping Singapore safe!", + "value": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE", - "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n \nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", "enabled": true }, { @@ -280,7 +280,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ERROR", - "value": "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! 😔", + "value": "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! 😔", "enabled": true }, { diff --git a/integration-tests/update-env.ts b/integration-tests/update-env.ts index a24158cd..d21e7ca8 100644 --- a/integration-tests/update-env.ts +++ b/integration-tests/update-env.ts @@ -1,3 +1,5 @@ +//TODO: UPDATE THIS + import _ from "lodash" import fs from "fs" import env from "./env.json" From a597d3260e8acf9d53fb0c9601c5245bb9bdaf01 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 29 Oct 2023 19:03:04 +0800 Subject: [PATCH 21/36] fixed env.json file updating --- integration-tests/env.json | 471 ++++++++++++++++++++++++-------- integration-tests/update-env.ts | 28 +- 2 files changed, 370 insertions(+), 129 deletions(-) diff --git a/integration-tests/env.json b/integration-tests/env.json index ed518668..836529b7 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -84,312 +84,547 @@ "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU", - "enabled": true, - "value": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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! 😊" + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1", + "value": "Welcome to our community of CheckMates! 👋🏻 We're grateful to have you on board to combat misinformation and scams. 🙇‍♀️🙇🏻 We'd love to get to know you better - could you *reply to this message* and share your name with us? (Reply to this message by swiping right)!", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2", + "value": "Thank you and welcome, {{name}}! We're thrilled to have you on board as we work together to combat misinformation and scams.😊 By using the CheckMate bot, you are accepting our privacy policy which can be found here: https://bit.ly/checkmate-privacy", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3", + "value": "To ensure you're equipped with the necessary skills to identify misinformation and scams, let's start with a quick quiz. 📝 Simply follow the link (https://bit.ly/checkmates-quiz) to take the quiz. Once you've completed it, come back to this chat and click on \"I've done the quiz!\" to notify me. Let's get started! 🤖", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4", + "value": "Awesome! Now that you know how to identify misinformation and scams, you are ready to help us combat them! 🙌🏻 If you haven't already, do join this WhatsApp group (https://bit.ly/checkmates-groupchat) that brings together all the other CheckMates and the core product team for updates and feedback. If you're looking for resources, you can visit our wiki page (https://bit.ly/checkmates-wiki). Thanks again for joining our community of CheckMates. Enjoy! 👋🏻🤖", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT", + "value": "Please assess the veracity of the claim(s) in this message on a scale from 0 to 5, where 0 means the claim(s) are entirely false, and 5 means the claim(s) are entirely true.", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.OUTSTANDING_REMINDER", + "value": "You have *{{num_outstanding}} remaining messages* to assess. Would you like to be sent the next one in line?", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION", + "value": "Got it👍! Please hold for another selection.", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT", + "value": "Which of these subcategories best describes this message?", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT", + "value": "Which of these categories best describes this message?", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX", - "enabled": true, - "value": "Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊." + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED", + "value": "Got it! Your response has been recorded. Thank you for playing your part in the fight against scams and misinformation, one message at a time! 💪", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_MENU_PREFIX", - "enabled": true, - "value": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕" + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING", + "value": "Great, you have no further messages to assess. Keep it up!💪", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.VOTE_NO", + "value": "No problem! If you wish to come back and assess the message, you may do so by clicking the 'yes' button. See you soon!😊", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL", + "value": "Got it👍! Please hold for another poll to vote on how true the message is.", + "enabled": true + }, + { + "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NOT_A_REPLY", + "value": "Sorry, did you forget to reply to a message? You need to swipe right on the message to reply to it.", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX", - "enabled": true, - "value": "Hmm...There doesn't seem to be anything to assess in this message.😕" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE.en", + "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX", - "enabled": true, - "value": "Hi! Thanks for using CheckMate. 🙏🏻" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE.cn", + "value": "占位符", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND", - "enabled": true, - "value": "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!" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING.en", + "value": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO", - "enabled": true, - "value": "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! 💪" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING.cn", + "value": "占位符", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE", - "enabled": true, - "value": "To learn more about CheckMate, you can visit our website at https://checkmate.sg" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE.en", + "value": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅\n\nThank you for keeping Singapore informed!", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK", - "enabled": true, - "value": "You can submit feedback at https://bit.ly/checkmate-feedback. Rest assured, we'll read it ASAP!" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE.cn", + "value": "占位符", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE", - "enabled": true, - "value": "Thanks for letting us know! Our CheckMates will review the assessment of this message." + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ERROR.en", + "value": "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! 😔", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.CONTACT", - "enabled": true, - "value": "Here's our contact! Do add us to your contact list so you can find us in future. 😊" + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ERROR.cn", + "value": "占位符", + "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED.en", "value": "Hello! 👋 Thanks for sending this in! Our *CheckMates🕵🏻 will review this* and *provide the results soon*.", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM.en", "value": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT.en", "value": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM.en", "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE", - "value": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅\n\nThank you for keeping Singapore safe!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSURE", - "value": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE.en", + "value": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅\n\nThank you for keeping Singapore safe!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE", - "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING", - "value": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSURE.en", + "value": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE", - "value": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅\n\nThank you for keeping Singapore informed!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSURE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en", "value": "Thanks for sending this in! ", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en", "value": "Thanks for waiting! ", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en", "value": "Our CheckMates have reviewed this message and think it's ", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO", - "value": "Based on pattern matching, our auto-classifier is confident that this message is ", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MATCHED", - "value": "In fact, other users have sent this message in {{numberInstances}} times. ", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.en", + "value": "Based on pattern matching, our auto-classifier is confident that this message is ", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1", - "value": "Welcome to our community of CheckMates! 👋🏻 We're grateful to have you on board to combat misinformation and scams. 🙇‍♀️🙇🏻 We'd love to get to know you better - could you *reply to this message* and share your name with us? (Reply to this message by swiping right)!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2", - "value": "Thank you and welcome, {{name}}! We're thrilled to have you on board as we work together to combat misinformation and scams.😊 By using the CheckMate bot, you are accepting our privacy policy which can be found here: https://bit.ly/checkmate-privacy", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MATCHED.en", + "value": "In fact, other users have sent this message in {{numberInstances}} times. ", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3", - "value": "To ensure you're equipped with the necessary skills to identify misinformation and scams, let's start with a quick quiz. 📝 Simply follow the link (https://bit.ly/checkmates-quiz) to take the quiz. Once you've completed it, come back to this chat and click on \"I've done the quiz!\" to notify me. Let's get started! 🤖", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MATCHED.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4", - "value": "Awesome! Now that you know how to identify misinformation and scams, you are ready to help us combat them! 🙌🏻 If you haven't already, do join this WhatsApp group (https://bit.ly/checkmates-groupchat) that brings together all the other CheckMates and the core product team for updates and feedback. If you're looking for resources, you can visit our wiki page (https://bit.ly/checkmates-wiki). Thanks again for joining our community of CheckMates. Enjoy! 👋🏻🤖", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSUPPORTED_TYPE.en", + "value": "Sorry, CheckMate currently doesn't support this type of message.", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT", - "value": "Please assess the veracity of the claim(s) in this message on a scale from 0 to 5, where 0 means the claim(s) are entirely false, and 5 means the claim(s) are entirely true.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSUPPORTED_TYPE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.OUTSTANDING_REMINDER", - "value": "You have *{{num_outstanding}} remaining messages* to assess. Would you like to be sent the next one in line?", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_EXPLAINER.en", + "value": "ScamShield is an anti-scam product developed by the National Crime Prevention Council and Open Government Products. You can learn more at https://scamshield.org.sg.", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION", - "value": "Got it👍! Please hold for another selection.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_EXPLAINER.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT", - "value": "Which of these subcategories best describes this message?", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE.en", + "value": "{{top}}% of our CheckMates identified this as *{{category1}}**{{info_placeholder}}*. *{{second}}*% felt this was *{{category2}}*.", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT", - "value": "Which of these categories best describes this message?", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED", - "value": "Got it! Your response has been recorded. Thank you for playing your part in the fight against scams and misinformation, one message at a time! 💪", + "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 is that this {{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}}", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING", - "value": "Great, you have no further messages to assess. Keep it up!💪", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.VOTE_NO", - "value": "No problem! If you wish to come back and assess the message, you may do so by clicking the 'yes' button. See you soon!😊", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE.en", + "value": "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.", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL", - "value": "Got it👍! Please hold for another poll to vote on how true the message is.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NOT_A_REPLY", - "value": "Sorry, did you forget to reply to a message? You need to swipe right on the message to reply to it.", + "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.ERROR", - "value": "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! 😔", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSUPPORTED_TYPE", - "value": "Sorry, CheckMate currently doesn't support this type of message.", + "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! 💪🏼", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_EXPLAINER", - "value": "ScamShield is an anti-scam product developed by the National Crime Prevention Council and Open Government Products. You can learn more at https://scamshield.org.sg.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE", - "value": "{{top}}% of our CheckMates identified this as *{{category1}}**{{info_placeholder}}*. *{{second}}*% felt this was *{{category2}}*.", + "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_TEMPLATE", - "value": "At this time, {{%voted}}% of our CheckMates have assessed and voted on this message. The majority think is that this {{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}}", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE", - "value": "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.", + "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_PROMPT", - "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! 💪🏼", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED.en", "value": "CheckMate has already provided a final response to this message.", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_ON_DECLINE", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_ON_DECLINE.en", "value": "No worries! We will not send your message to ScamShield. Thank you for sharing this message with us, and for keeping Singapore safe!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK", - "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.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_ON_DECLINE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL", - "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.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.en", + "value": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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! 😊", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL", - "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.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY", - "value": "Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us.\n\nOn a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX.en", + "value": "Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊.", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS", - "value": "Thanks for your feedback!", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_MENU_PREFIX.en", + "value": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_MENU_PREFIX.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.en", + "value": "Hmm...There doesn't seem to be anything to assess in this message.😕", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.en", + "value": "Hi! Thanks for using CheckMate. 🙏🏻", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND.en", + "value": "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!", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO.en", + "value": "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! 💪", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE.en", + "value": "To learn more about CheckMate, you can visit our website at https://checkmate.sg", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK.en", + "value": "You can submit feedback at https://bit.ly/checkmate-feedback. Rest assured, we'll read it ASAP!", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE.en", + "value": "Thanks for letting us know! Our CheckMates will review the assessment of this message.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.CONTACT.en", + "value": "Here's our contact! Do add us to your contact list so you can find us in future. 😊", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.CONTACT.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL.en", "value": "Have you started checking and reporting suspicious messages using CheckMate yet? Sign up by clicking this link and sending in the pre-loaded message!! {{link}}", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID", - "value": "Sorry, referrals are only credited upon your first interaction with CheckMate.", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL.cn", + "value": "占位符", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX", + "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:", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_PREPOPULATED_PREFIX", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX.cn", + "value": "占位符", + "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:", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_ERROR", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_PREPOPULATED_PREFIX.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID.en", + "value": "Sorry, referrals are only credited upon your first interaction with CheckMate.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_ERROR.en", "value": "Sorry, an error occured. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOWD_WE_TELL", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_ERROR.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY.en", + "value": "Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us.\n\nOn a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS.en", + "value": "Thanks for your feedback!", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOWD_WE_TELL.en", "value": "*This is an experimental feature powered by generative AI*. Do let us know if it was useful below!\n \n{{rationalisation}}", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_USEFUL", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOWD_WE_TELL.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_USEFUL.en", "value": "Thanks for your valuable feedback!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_NOT_USEFUL", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_USEFUL.cn", + "value": "占位符", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_NOT_USEFUL.en", "value": "Sorry to hear that, but thanks anyway for your valuable feedback!", "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_NOT_USEFUL.cn", + "value": "占位符", + "enabled": true } ], "_postman_variable_scope": "environment", "_postman_exported_at": "2023-04-30T14:17:56.196Z", "_postman_exported_using": "Postman/10.13.0" -} +} \ No newline at end of file diff --git a/integration-tests/update-env.ts b/integration-tests/update-env.ts index d21e7ca8..2398d54a 100644 --- a/integration-tests/update-env.ts +++ b/integration-tests/update-env.ts @@ -3,15 +3,17 @@ import _ from "lodash" import fs from "fs" import env from "./env.json" -import * as constants from "../functions/src/definitions/common/constants" +import CHECKER_BOT_REPONSES from "../functions/src/definitions/common/parameters/checkerResponses.json" +import USER_BOT_RESPONSES from "../functions/src/definitions/common/parameters/userResponses.json" +import { language } from "googleapis/build/src/apis/language" -const factCheckerKeys = Object.keys(constants.FACTCHECKER_BOT_RESPONSES).map( - (key) => { - return `__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.${key}` - } -) -const userKeys = Object.keys(constants.USER_BOT_RESPONSES).map((key) => { - return `__CONSTANTS__.USER_BOT_RESPONSES.${key}` +const factCheckerKeys = Object.keys(CHECKER_BOT_REPONSES).map((key) => { + return `__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.${key}` +}) +const userKeys = Object.entries(USER_BOT_RESPONSES).flatMap(([key, value]) => { + return Object.keys(value).map( + (language) => `__CONSTANTS__.USER_BOT_RESPONSES.${key}.${language}` + ) }) //combine the two lists @@ -50,9 +52,13 @@ const envWithRemovedValues = env.values.filter((value) => { const envWithReplacedValues = envWithRemovedValues.map((value) => { if (value.key.startsWith("__CONSTANTS__.")) { - const key = value.key.replace("__CONSTANTS__.", "") - const newValue = _.get(constants, key) - value.value = newValue + const stringParts = value.key.split(".") + const key = stringParts.slice(2).join(".") + if (stringParts[1] === "FACTCHECKER_BOT_RESPONSES") { + value.value = _.get(CHECKER_BOT_REPONSES, key) + } else if (stringParts[1] === "USER_BOT_RESPONSES") { + value.value = _.get(USER_BOT_RESPONSES, key) + } return value } else { return value From a478a796a679faf88313f9be7a7dbf9758ef6628 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Mon, 30 Oct 2023 21:47:29 +0800 Subject: [PATCH 22/36] fixed tests --- functions/src/definitions/common/constants.ts | 4 +- .../checkmate.postman_collection.json | 25802 ++++++++-------- integration-tests/env.json | 19 +- 3 files changed, 12518 insertions(+), 13307 deletions(-) diff --git a/functions/src/definitions/common/constants.ts b/functions/src/definitions/common/constants.ts index 97945986..756097cb 100644 --- a/functions/src/definitions/common/constants.ts +++ b/functions/src/definitions/common/constants.ts @@ -1,6 +1,6 @@ const USER_BOT_RESPONSES = { - UNTRUE: `{{thanks}}{{matched}}{{methodology}}*untrue*.❌ - + UNTRUE: `{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}} + Please do not spread it further⛔️⛔️ Thank you for keeping Singapore informed!`, diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 9ceb7233..ca3426f5 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,13299 +1,12505 @@ { - "info": { - "_postman_id": "f9991f6c-049a-4e5c-be8e-a80284402235", - "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 (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that has is created\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralId = jsonData.fields.referralId.stringValue\r", - " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", - " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", - " pm.expect(referralId.length).to.be.above(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\",\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": \"Dispute Assessment\",\r", - " \"description\": \"Dispute CheckMate's assesment of this message\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " // get the id of \"Dispute Assessment\" for validation\r", - " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", - " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", - " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", - "\r", - " // remove the id of \"Dispute Assessment\" for comparison\r", - " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", - " if (row.title === \"Dispute Assessment\") {\r", - " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", - " } else {\r", - " return row;\r", - " }\r", - " });\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Dispute Categorisation\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 10\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_10}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 13\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_13}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 14\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Press button \"No it's not\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_NOT_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_NOT_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update again", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 15\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "005d_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const spamResponse = getFinalResponseText(SPAM)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": spamResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": SATISFACTION_SURVEY\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Tap to respond\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": \"Extremely likely 🤩\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"9\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"8\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"7\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"6\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"5\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"4\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"3\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"2\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"1\",\r", - " \"description\": \"Not at all likely 😥\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Votes 10", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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 thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "006_Info_Machine_Human", - "item": [ - { - "name": "006a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 19\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 21\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_21}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": [ - "{{FUNCTIONS_URL}}" - ], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": [] - } - ] - }, - { - "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\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNTRUE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "006c_3rd_Voter_5", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "007_Unsure_Human", - "item": [ - { - "name": "007a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 23\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_23}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 25\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_25}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": "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_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": "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\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007e_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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", - " //console.log(JSON.stringify(expected,null,2))\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNSURE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007f_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 29\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_29}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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 thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "008_Menu_Message", - "item": [ - { - "name": "Send WhatApp message (\"Menu\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 30\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_30}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 2000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Check/Report\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 31\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_31}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\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\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 2000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Contact\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 35\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_35}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_37\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": BODY_TEXT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"How'd we tell?\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"Don't report this\"\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\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_38\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "011_Check_Steps_logging", - "item": [ - { - "name": "[DB CALL] Check steps", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", - " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", - " const expected = [\r", - " \"text_machine_irrelevant_length\",\r", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"satisfactionSurvey_10\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_info\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_contact\",\r", - " \"menu_referral\",\r", - " \"text_machine_scam\",\r", - " \"text_machine_spam\",\r", - " ]\r", - " pm.expect(actions).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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}} {{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 (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": [ - "{{RESULT_SERVER_URL}}" - ], - "path": [ - "testresultdata" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that referral count is incremented to 1\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralCount = jsonData.fields.referralCount.integerValue\r", - " pm.expect(parseInt(referralCount)).to.eql(1);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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}} {{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\");\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": "f9991f6c-049a-4e5c-be8e-a80284402235", + "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 (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that has is created\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralId = jsonData.fields.referralId.stringValue\r", + " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", + " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", + " pm.expect(referralId.length).to.be.above(0);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\",\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_dispute_messages/*/instances/*\",\r", + " \"title\": \"Dispute Assessment\",\r", + " \"description\": \"Dispute CheckMate's assesment of this message\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " // get the id of \"Dispute Assessment\" for validation\r", + " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", + " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", + " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", + "\r", + " // remove the id of \"Dispute Assessment\" for comparison\r", + " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", + " if (row.title === \"Dispute Assessment\") {\r", + " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", + " } else {\r", + " return row;\r", + " }\r", + " });\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Dispute Categorisation\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 10\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_10}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [""], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 13\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_13}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 14\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Press button \"No it's not\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_NOT_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_NOT_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update again", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 15\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + }, + { + "name": "005c_2nd Voter Legitimate", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + }, + { + "name": "005d_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT\")\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\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [""], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": SATISFACTION_SURVEY\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Tap to respond\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"10\",\r", + " \"description\": \"Extremely likely 🤩\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"9\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"8\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"7\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"6\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"5\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"4\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"3\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"2\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"1\",\r", + " \"description\": \"Not at all likely 😥\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [""], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Votes 10", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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 thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "006_Info_Machine_Human", + "item": [ + { + "name": "006a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 19\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 21\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_21}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", + "host": ["{{FUNCTIONS_URL}}"], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": [] + } + ] + }, + { + "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\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT\")\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\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [""], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + }, + { + "name": "006c_3rd_Voter_5", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "007_Unsure_Human", + "item": [ + { + "name": "007a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 23\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_23}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [""], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 25\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_25}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": "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_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": "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\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + }, + { + "name": "007e_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const isImage = false\r", + " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT\")\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\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [""], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + }, + { + "name": "007f_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 29\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_29}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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 thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "008_Menu_Message", + "item": [ + { + "name": "Send WhatApp message (\"Menu\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 30\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_30}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 2000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Check/Report\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 31\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_31}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\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\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 2000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Contact\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 35\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_35}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_37\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\").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\": \"How'd we tell?\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"Don't report this\"\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\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").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", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"feedbackInterim_no\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"satisfactionSurvey_10\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_info\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_contact\",\r", + " \"menu_referral\",\r", + " \"text_machine_scam\",\r", + " \"text_machine_spam\",\r", + " ]\r", + " pm.expect(actions).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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}} {{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 (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": ["setTimeout(() => {}, 3000);"], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": ["{{RESULT_SERVER_URL}}"], + "path": ["testresultdata"] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that referral count is incremented to 1\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralCount = jsonData.fields.referralCount.integerValue\r", + " pm.expect(parseInt(referralCount)).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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}} {{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\");\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": "" + } + ] +} diff --git a/integration-tests/env.json b/integration-tests/env.json index 013d63d5..a5435dc2 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -145,22 +145,22 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM", - "value": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "value": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT", - "value": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "value": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM", - "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧 \n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", + "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧{{image_caveat}}\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE", - "value": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅\n\nThank you for keeping Singapore safe!", + "value": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}}\n\nThank you for keeping Singapore safe!", "enabled": true }, { @@ -175,12 +175,12 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING", - "value": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}}\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE", - "value": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}}\n\nThank you for keeping Singapore informed!", "enabled": true }, { @@ -387,9 +387,14 @@ "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_NOT_USEFUL", "value": "Sorry to hear that, but thanks anyway for your valuable feedback!", "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT", + "value": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", + "enabled": true } ], "_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 d179b77468d923429a9363e0dd9d2d1f6dc5823d Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Mon, 30 Oct 2023 21:50:23 +0800 Subject: [PATCH 23/36] update env.json --- integration-tests/env.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/env.json b/integration-tests/env.json index a5435dc2..2427110b 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -170,7 +170,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE", - "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n \nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}}\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", "enabled": true }, { From 98b973f18ba491b7a36d82ba8774acf9f5edf856 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Mon, 30 Oct 2023 21:59:52 +0800 Subject: [PATCH 24/36] added image caveats --- .../common/parameters/userResponses.json | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 70abd8d7..5948aabc 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -1,14 +1,14 @@ { "UNTRUE": { - "en": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "en": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}}\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", "cn": "占位符" }, "MISLEADING": { - "en": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", + "en": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}}\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", "cn": "占位符" }, "ACCURATE": { - "en": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅\n\nThank you for keeping Singapore informed!", + "en": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}}\n\nThank you for keeping Singapore informed!", "cn": "占位符" }, "ERROR": { @@ -20,19 +20,19 @@ "cn": "占位符" }, "SCAM": { - "en": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "en": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "cn": "占位符" }, "ILLICIT": { - "en": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "en": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "cn": "占位符" }, "SPAM": { - "en": "{{thanks}}{{matched}}{{methodology}}spam!🚧\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", + "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": "占位符" }, "LEGITIMATE": { - "en": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅\n\nThank you for keeping Singapore safe!", + "en": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}}\n\nThank you for keeping Singapore safe!", "cn": "占位符" }, "UNSURE": { @@ -59,6 +59,10 @@ "en": "In fact, other users have sent this message in {{numberInstances}} times. ", "cn": "占位符" }, + "IMAGE_CAVEAT": { + "en": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", + "cn": "占位符" + }, "UNSUPPORTED_TYPE": { "en": "Sorry, CheckMate currently doesn't support this type of message.", "cn": "占位符" From 2abdac1f2fc1bfd9e40ae87130e62e2af4e6e8f2 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Wed, 1 Nov 2023 18:39:32 +0800 Subject: [PATCH 25/36] added CN responses --- .../common/parameters/userResponses.json | 258 +- .../src/definitions/common/responseUtils.ts | 144 +- .../checkmate.postman_collection.json | 25916 ++++++++-------- integration-tests/env.json | 520 +- 4 files changed, 14133 insertions(+), 12705 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 5948aabc..2a902d00 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -1,194 +1,334 @@ { "UNTRUE": { "en": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}}\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", - "cn": "占位符" + "cn": "{thanks}}{{matched}}{{methodology}}*不属实*。❌{{image_caveat}}\n\n请不要再转发了⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n" }, "MISLEADING": { "en": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}}\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", - "cn": "占位符" + "cn": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但整体来看,它*具有误导性或展现不平衡的观点*。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!" }, "ACCURATE": { "en": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}}\n\nThank you for keeping Singapore informed!", - "cn": "占位符" + "cn": "{{thanks}}{{matched}}{{methodology}}*是准确的*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" }, "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": "占位符" + "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*.", - "cn": "占位符" + "cn": "你好!👋 感谢您的提交!我们的查哥查妹🕵🏻将尽快审查这条短信并回复。" }, "SCAM": { "en": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", - "cn": "占位符" + "cn": "{{thanks}}{{matched}}{{methodology}}*是一种诈骗*!🚫{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告此诈骗。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。" }, "ILLICIT": { "en": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", - "cn": "占位符" + "cn": "{{thanks}}{{matched}}{{methodology}}**很可疑*!🚨{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告这条可疑的短信。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。" }, "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": "占位符" + "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!", - "cn": "占位符" + "cn": "{{thanks}}{{matched}}{{methodology}}*来自可靠的来源*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" }, "UNSURE": { "en": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", - "cn": "占位符" + "cn": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信*无法做出评估*🤷🏻‍♂️🤷🏻‍♀️。对不起,毕竟我们也只是普通人!😞\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。\n\n感谢您对新加坡网络安全的支持和贡献!" }, "THANKS_IMMEDIATE": { - "en": "Thanks for sending this in! ", - "cn": "占位符" + "en": "Thanks for sending this in!", + "cn": "感谢您提交这条短信!" }, "THANKS_DELAYED": { - "en": "Thanks for waiting! ", - "cn": "占位符" + "en": "Thanks for waiting!", + "cn": "感谢您的耐心等待!" + }, + "IMAGE_CAVEAT": { + "en": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", + "cn": "这个评估是根据标题中的任何声明。如果短信里没有文字标题,此评估是根据图片里的内容。" }, "METHODOLOGY_HUMAN": { - "en": "Our CheckMates have reviewed this message and think it's ", - "cn": "占位符" + "en": "Our CheckMates have reviewed this message and think it's", + "cn": "我们的查哥查妹审查了这条短信后,认为它" }, "METHODOLOGY_AUTO": { "en": "Based on pattern matching, our auto-classifier is confident that this message is ", - "cn": "占位符" + "cn": "根据我们采用的人工智能技术,我们确信这条短信" }, "MATCHED": { "en": "In fact, other users have sent this message in {{numberInstances}} times. ", - "cn": "占位符" - }, - "IMAGE_CAVEAT": { - "en": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", - "cn": "占位符" + "cn": "其实查友已经收到了{{numberInstances}}条同样的短信。" }, "UNSUPPORTED_TYPE": { "en": "Sorry, CheckMate currently doesn't support this type of message.", - "cn": "占位符" + "cn": "对不起,查友目前不支持这种类型的短信。" }, - "SCAMSHIELD_EXPLAINER": { - "en": "ScamShield is an anti-scam product developed by the National Crime Prevention Council and Open Government Products. You can learn more at https://scamshield.org.sg.", - "cn": "占位符" + "STATS_TEMPLATE_1": { + "en": "{{top}}% of our CheckMates felt this was *{{category}}*{{info_placeholder}}.", + "cn": "我们的查哥查妹中有{{top}}%的人认为这条短信*{{category}}*{{info_placeholder}}。" }, - "STATS_TEMPLATE": { - "en": "{{top}}% of our CheckMates identified this as *{{category1}}**{{info_placeholder}}*. *{{second}}*% felt this was *{{category2}}*.", - "cn": "占位符" + "STATS_TEMPLATE_2": { + "en": " {{second}}% felt this was *{{category}}*{{info_placeholder}}.", + "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 is that this {{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": "占位符" + "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}}" + }, + "INFO_PLACEHOLDER": { + "en": ", with an average score of {{score}} on a scale of 0-5 (5 = completely true)", + "cn": "在0-5的评分标准上,平均分数为{{score}}(5 = 完全正确)" }, "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": "占位符" + "cn": "\n目前,我们的查哥查妹中{{%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": "感谢您对查友的信任!👋🏼 如果这个临时更新对您有帮助,我们会很感激如果您能点击下方的“有帮助”。否则,点击“没帮助”以继续等待最终结果。无论如何,随着更多投票的到来,您都可以继续请求更多更新。" }, "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": "占位符" + "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": "占位符" + "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": "占位符" + "cn": "很遗憾听到这个消息,但还是要感谢您的宝贵反馈!我们的查哥查妹们投票更多或者自您发送短信后已过24小时时,我们会尽快向您提供最终结果。\n\n如果您希望在更多投票进来后再次更新,请点击下方的按钮进行请求。" }, "ALREADY_REPLIED": { "en": "CheckMate has already provided a final response to this message.", - "cn": "占位符" + "cn": "查友已经对这条短信给出了最终的回应。" }, "SCAMSHIELD_ON_DECLINE": { "en": "No worries! We will not send your message to ScamShield. Thank you for sharing this message with us, and for keeping Singapore safe!", - "cn": "占位符" + "cn": "没关系!我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,感谢您对新加坡网络安全的支持和贡献!\n!" }, "MENU": { "en": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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": "占位符" + "cn": "{{prefix}}\n\n如果你知道该怎么做,请继续!否则,请选择下方的\"查看菜单\",看看查友能做什么!👈\n\n请注意,查友*只会帮你审查发送给查友的可疑短信,它不能与你自由对话*。\n\n无论何时你需要再次了解查友的功能,只需输入\"菜单\"即可返回这里!😊" }, "NEW_USER_MENU_PREFIX": { "en": "Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊.", - "cn": "占位符" + "cn": "您好,欢迎来到查友!我们注意到这是您第一次使用我们的服务。我们很高兴您加入我们,一起对抗诈骗和误导短信😊。" }, "IRRELEVANT_MENU_PREFIX": { "en": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", - "cn": "占位符" + "cn": "感谢您的耐心等待!🙏🏻 我们的查哥查妹在这条短信中没有找到任何可以评估的内容。😕" }, "IRRELEVANT_AUTO_MENU_PREFIX": { "en": "Hmm...There doesn't seem to be anything to assess in this message.😕", - "cn": "占位符" + "cn": "嗯...这条短信似乎没有什么可以评估的内容。😕" }, "MENU_PREFIX": { "en": "Hi! Thanks for using CheckMate. 🙏🏻", - "cn": "占位符" + "cn": "你好!感谢你使用查友。🙏🏻" }, "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": "占位符" + "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! 💪", - "cn": "占位符" + "cn": "请访问 https://youtube.com/shorts/gFeO_qFOchs?feature=share 查看查友的工作原理!\n\n完成了吗?您现在已经准备好使用查友了!让我们一起为打击诈骗和误导短信做出贡献!💪" }, "LEARN_MORE": { "en": "To learn more about CheckMate, you can visit our website at https://checkmate.sg", - "cn": "占位符" + "cn": "要了解更多关于查友的短信,您可以访问我们的网站 https://checkmate.sg" }, "FEEDBACK": { "en": "You can submit feedback at https://bit.ly/checkmate-feedback. Rest assured, we'll read it ASAP!", - "cn": "占位符" + "cn": "您可以在 https://bit.ly/checkmate-feedback 提交反馈。请放心,我们会尽快阅读并处理!" }, "DISPUTE": { "en": "Thanks for letting us know! Our CheckMates will review the assessment of this message.", - "cn": "占位符" + "cn": "感谢您的反馈!我们的查哥查妹将会重新评估这条短信。" }, "CONTACT": { "en": "Here's our contact! Do add us to your contact list so you can find us in future. 😊", - "cn": "占位符" + "cn": "这是我们的联系方式!请将我们添加到您的联系人列表中,以便您以后能找到我们。😊" }, "REFERRAL": { "en": "Have you started checking and reporting suspicious messages using CheckMate yet? Sign up by clicking this link and sending in the pre-loaded message!! {{link}}", - "cn": "占位符" + "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": "占位符" + "cn": "欢迎使用查友!发送整条短信(包括代码)以开始使用,并将您的推荐人记入账户。代码:" }, "GENERIC_PREPOPULATED_PREFIX": { "en": "Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:", - "cn": "占位符" + "cn": "欢迎使用查友!请将此整条短信(包括代码)发送给我们以开始使用。代码:" }, "REFERRAL_INVALID": { "en": "Sorry, referrals are only credited upon your first interaction with CheckMate.", - "cn": "占位符" + "cn": "对不起,只有在您首次与查友互动时,推荐才会被记入账户。" }, "GENERIC_ERROR": { "en": "Sorry, an error occured. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", - "cn": "占位符" + "cn": "对不起,出现了一个错误。😔 我们会尽快解决这个问题!同时,您可以尝试使用查友的其他功能。再次为此道歉!" }, "SATISFACTION_SURVEY": { "en": "Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us.\n\nOn a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?", - "cn": "占位符" + "cn": "非常感谢您使用查友🙏。您的反馈对我们非常重要,也会帮我们改进。\n\n请问在1-10的评分中,您有多大可能性向您的朋友、同事或家人推荐查友?" }, "SATISFACTION_SURVEY_THANKS": { "en": "Thanks for your feedback!", - "cn": "占位符" + "cn": "感谢您的反馈!" }, "HOWD_WE_TELL": { "en": "*This is an experimental feature powered by generative AI*. Do let us know if it was useful below!\n \n{{rationalisation}}", - "cn": "占位符" + "cn": "*这是一项由生成式人工智能驱动的实验性功能*。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}" }, "RATIONALISATION_USEFUL": { "en": "Thanks for your valuable feedback!", - "cn": "占位符" + "cn": "感谢您的反馈!" }, "RATIONALISATION_NOT_USEFUL": { "en": "Sorry to hear that, but thanks anyway for your valuable feedback!", - "cn": "占位符" + "cn": "很遗憾得知此功能对您来说不是很有用。 我已将此消息传递给我们的产品团队,以便将来进一步增强此功能。感谢您的反馈!" + }, + "MENU_BUTTON": { + "en": "Menu", + "cn": "菜单" + }, + "MENU_TITLE_CHECK": { + "en": "Check/Report", + "cn": "查询/举报" + }, + "MENU_DESCRIPTION_CHECK": { + "en": "Send in messages, images, or screenshots for checking!", + "cn": "提交消息、图片或截图进行检查!" + }, + "MENU_TITLE_REFERRAL": { + "en": "Get Referral Link", + "cn": "获取推荐链接" + }, + "MENU_DESCRIPTION_REFERRAL": { + "en": "Get referral link to forward to others", + "cn": "获取推荐链接以转发给亲戚好友加入查友" + }, + "MENU_TITLE_HELP": { + "en": "Get Help", + "cn": "使用说明" + }, + "MENU_DESCRIPTION_HELP": { + "en": "Find out how to use CheckMate to check or report dubious messages", + "cn": "了解如何使用查友来查询或举报可疑短信" + }, + "MENU_TITLE_ABOUT": { + "en": "About CheckMate", + "cn": "关于查友" + }, + "MENU_DESCRIPTION_ABOUT": { + "en": "Learn more about CheckMate and the team behind it", + "cn": "了解更多关于查友及其幕后团队的短信" + }, + "MENU_TITLE_FEEDBACK": { + "en": "Send Feedback", + "cn": "给予反馈" + }, + "MENU_DESCRIPTION_FEEDBACK": { + "en": "Send us feedback on anything to do with CheckMate", + "cn": "给予有关查友的任何反馈" + }, + "MENU_TITLE_CONTACT": { + "en": "Get Contact", + "cn": "获取联系方式" + }, + "MENU_DESCRIPTION_CONTACT": { + "en": "Get CheckMate's contact to add to your contact list", + "cn": "获取查友的联系方式并添加查友到您的通讯列表" + }, + "MENU_TITLE_DISPUTE": { + "en": "Dispute Assessment", + "cn": "争议判断" + }, + "MENU_DESCRIPTION_DISPUTE": { + "en": "Dispute CheckMate's assesment of this message", + "cn": "对查友对此消息的评估提出异议" + }, + "MENU_DESCRIPTION_NPS_LIKELY": { + "en": "Extremely likely 🤩", + "cn": "一定会🤩" + }, + "MENU_DESCRIPTION_NPS_UNLIKELY": { + "en": "Not at all likely 😥", + "cn": "休想😥" + }, + "NPS_MENU_BUTTON": { + "en": "Respond", + "cn": "回应" + }, + "BUTTON_USEFUL": { + "en": "Yes, it's useful", + "cn": "有帮助" + }, + "BUTTON_NOT_USEFUL": { + "en": "No, it's not", + "cn": "没帮助" + }, + "BUTTON_ANOTHER_UPDATE": { + "en": "Get another update", + "cn": "再提供审查状态更新" + }, + "BUTTON_GET_INTERIM": { + "en": "Get interim update", + "cn": "提供审查状态更新" + }, + "BUTTON_RESULTS": { + "en": "See voting results", + "cn": "查看投票结果" + }, + "BUTTON_DECLINE_REPORT": { + "en": "Don't report this", + "cn": "不要举报" + }, + "BUTTON_RATIONALISATION": { + "en": "How'd we tell?", + "cn": "我们是如何判断的?" + }, + "PLACEHOLDER_SCAM": { + "en": "a scam🚫", + "cn": "是一种诈骗🚫" + }, + "PLACEHOLDER_SUSPICIOUS": { + "en": "illicit🚨", + "cn": "具有非法性🚨" + }, + "PLACEHOLDER_UNTRUE": { + "en": "untrue❌", + "cn": "不真实❌" + }, + "PLACEHOLDER_MISLEADING": { + "en": "misleading⚠️", + "cn": "具有误导性⚠️" + }, + "PLACEHOLDER_ACCURATE": { + "en": "accurate✅", + "cn": "是准确的✅" + }, + "PLACEHOLDER_SPAM": { + "en": "spam🚧", + "cn": "是垃圾信息🚧" + }, + "PLACEHOLDER_LEGITIMATE": { + "en": "legitimate✅", + "cn": "来自可靠的来源✅" + }, + "PLACEHOLDER_IRRELEVANT": { + "en": "message doesn't contain a meaningful claim to assess.😕", + "cn": "没有包含有意义的声明进行评估😕" + }, + "PLACEHOLDER_UNSURE": { + "en": "too difficult to assess", + "cn": "很难做评估" } } diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index afe2fbb4..8a7d0a5d 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -25,10 +25,11 @@ type ResponseObject = { [key: string]: string } -function getInfoLiner(truthScore: null | number) { - return `, with an average score of ${ +function getInfoLiner(truthScore: null | number, infoPlaceholder: string) { + return infoPlaceholder.replace( + "{{score}}", typeof truthScore === "number" ? truthScore.toFixed(2) : "NA" - } on a scale of 0-5 (5 = completely true)` + ) } async function respondToInterimFeedback( @@ -48,7 +49,7 @@ async function respondToInterimFeedback( type: "reply", reply: { id: `sendInterim_${instancePath}`, - title: "Get another update", + title: responses.BUTTON_ANOTHER_UPDATE, }, }, ] @@ -110,6 +111,10 @@ async function getResponsesObj(botType: "user" | "factChecker" = "user") { const responseProxy = new Proxy(userResponseObject as BotResponses, { get(target, prop: string) { + if (prop === "then") { + //somehow code tries to access then property + return undefined + } if (target[prop] && target[prop][language]) { return target[prop][language] } else if (target[prop] && target[prop]["en"]) { @@ -149,34 +154,33 @@ async function sendMenuMessage( const rows = [ { id: `${type}_check`, - title: "Check/Report", - description: "Send in messages, images, or screenshots for checking!", + title: responses.MENU_TITLE_CHECK, + description: responses.MENU_DESCRIPTION_CHECK, }, { id: `${type}_referral`, - title: "Get Referral Link", - description: "Get referral link to forward to others", + title: responses.MENU_TITLE_REFERRAL, + description: responses.MENU_DESCRIPTION_REFERRAL, }, { id: `${type}_help`, - title: "Get Help", - description: - "Find out how to use CheckMate to check or report dubious messages", + title: responses.MENU_TITLE_HELP, + description: responses.MENU_DESCRIPTION_HELP, }, { id: `${type}_about`, - title: "About CheckMate", - description: "Learn more about CheckMate and the team behind it", + title: responses.MENU_TITLE_ABOUT, + description: responses.MENU_DESCRIPTION_ABOUT, }, { id: `${type}_feedback`, - title: "Send Feedback", - description: "Send us feedback on anything to do with CheckMate", + title: responses.MENU_TITLE_FEEDBACK, + description: responses.MENU_DESCRIPTION_FEEDBACK, }, { id: `${type}_contact`, - title: "Get Contact", - description: "Get CheckMate's contact to add to your contact list", + title: responses.MENU_TITLE_CONTACT, + description: responses.MENU_DESCRIPTION_CONTACT, }, //TODO: Implement these next time @@ -199,8 +203,8 @@ async function sendMenuMessage( if (disputedInstancePath) { rows.splice(5, 0, { id: `${type}_dispute_${disputedInstancePath}`, - title: "Dispute Assessment", - description: "Dispute CheckMate's assesment of this message", + title: responses.MENU_TITLE_DISPUTE, + description: responses.MENU_DESCRIPTION_DISPUTE, }) } const sections = [ @@ -212,7 +216,7 @@ async function sendMenuMessage( "user", to, text, - "View Menu", + responses.MENU_BUTTON, sections, replyMessageId ) @@ -247,8 +251,8 @@ async function sendSatisfactionSurvey(instanceSnap: DocumentSnapshot) { title: `${number}`, } }) - rows[0].description = "Extremely likely 🤩" - rows[9].description = "Not at all likely 😥" + rows[0].description = responses.MENU_DESCRIPTION_NPS_LIKELY + rows[9].description = responses.MENU_DESCRIPTION_NPS_UNLIKELY const sections = [ { rows: rows, @@ -258,7 +262,7 @@ async function sendSatisfactionSurvey(instanceSnap: DocumentSnapshot) { "user", data.from, responses.SATISFACTION_SURVEY, - "Tap to respond", + responses.NPS_MENU_BUTTON, sections ) const batch = db.batch() @@ -302,7 +306,7 @@ async function sendVotingStats(instancePath: string) { await sendTextMessage( "user", from, - "Sorry, an error occured!", + responses.GENERIC_ERROR, instanceSnap.get("id") ) return @@ -310,45 +314,62 @@ async function sendVotingStats(instancePath: string) { if (truthScore !== null) { if (truthScore < (thresholds.falseUpperBound || 1.5)) { - truthCategory = "untrue" + truthCategory = responses.PLACEHOLDER_UNTRUE } else if (truthScore < (thresholds.misleadingUpperBound || 3.5)) { - truthCategory = "misleading" + truthCategory = responses.PLACEHOLDER_MISLEADING } else { - truthCategory = "accurate" + truthCategory = responses.PLACEHOLDER_MISLEADING } } else truthCategory = "NA" const categories = [ { name: "trivial", count: irrelevantCount, isInfo: false }, { - name: scamCount >= illicitCount ? "scam" : "illicit", + name: + scamCount >= illicitCount + ? responses.PLACEHOLDER_SCAM + : responses.PLACEHOLDER_ILLICIT, count: susCount, isInfo: false, }, - { name: "spam", count: spamCount, isInfo: false }, + { name: responses.PLACEHOLDER_SPAM, count: spamCount, isInfo: false }, { name: truthCategory, count: infoCount, isInfo: true }, - { name: "legitimate", count: legitimateCount, isInfo: false }, + { + name: responses.PLACEHOLDER_LEGITIMATE, + count: legitimateCount, + isInfo: false, + }, { name: "unsure", count: unsureCount, isInfo: false }, ] categories.sort((a, b) => b.count - a.count) // sort in descending order - const highestCategory = - categories[0].name === "scam" ? "a scam" : categories[0].name - const secondCategory = - categories[1].name === "scam" ? "a scam" : categories[1].name + const highestCategory = categories[0].name + const secondCategory = categories[1].name const highestPercentage = (categories[0].count / responseCount) * 100 const secondPercentage = (categories[1].count / responseCount) * 100 const isHighestInfo = categories[0].isInfo const isSecondInfo = categories[1].isInfo - const infoLiner = getInfoLiner(truthScore) - let response = `${highestPercentage.toFixed(2)}% of our CheckMates ${ - isHighestInfo ? "collectively " : "" - }thought this was *${highestCategory}*${isHighestInfo ? infoLiner : ""}.` + const infoLiner = getInfoLiner(truthScore, responses.INFO_PLACEHOLDER) + let response = responses.STATS_TEMPLATE_1.replace( + "{{top}}", + `${highestPercentage.toFixed(2)}` + ) + .replace("{{category}}", highestCategory) + .replace("{{info_placeholder}}", isHighestInfo ? infoLiner : "") + // let response = `${highestPercentage.toFixed(2)}% of our CheckMates ${ + // isHighestInfo ? "collectively " : "" + // }thought this was *${highestCategory}*${isHighestInfo ? infoLiner : ""}.` if (secondPercentage > 0) { - response += ` ${secondPercentage.toFixed(2)}% ${ - isSecondInfo ? "collectively " : "" - } thought this was *${secondCategory}*${isSecondInfo ? infoLiner : ""}.` + response += responses.STATS_TEMPLATE_2.replace( + "{{second}}", + `${secondPercentage.toFixed(2)}` + ) + .replace("{{category}}", secondCategory) + .replace("{{info_placeholder}}", isSecondInfo ? infoLiner : "") + // response += ` ${secondPercentage.toFixed(2)}% ${ + // isSecondInfo ? "collectively " : "" + // } thought this was *${secondCategory}*${isSecondInfo ? infoLiner : ""}.` } await sendTextMessage("user", from, response, instanceSnap.get("id")) @@ -411,14 +432,14 @@ async function sendRationalisation(instancePath: string) { type: "reply", reply: { id: `feedbackRationalisation_${instancePath}_yes`, - title: "Yes, it's useful", + title: responses.BUTTON_USEFUL, }, }, { type: "reply", reply: { id: `feedbackRationalisation_${instancePath}_no`, - title: "No, it's not", + title: responses.BUTTON_NOT_USEFUL, }, }, ] @@ -478,38 +499,37 @@ async function sendInterimUpdate(instancePath: string) { const percentageVoted = ((voteCount / numFactCheckers) * 100).toFixed(2) let prelimAssessment let infoPlaceholder = "" - const infoLiner = getInfoLiner(truthScore) + const infoLiner = getInfoLiner(truthScore, responses.INFO_PLACEHOLDER) switch (primaryCategory) { case "scam": - prelimAssessment = "is a scam🚫" + prelimAssessment = responses.PLACEHOLDER_SCAM break case "illicit": - prelimAssessment = "is suspicious🚨" + prelimAssessment = responses.PLACEHOLDER_SUSPICIOUS break case "untrue": - prelimAssessment = "is untrue❌" + prelimAssessment = responses.PLACEHOLDER_UNTRUE infoPlaceholder = infoLiner break case "misleading": - prelimAssessment = "is misleading⚠️" + prelimAssessment = responses.PLACEHOLDER_MISLEADING infoPlaceholder = infoLiner break case "accurate": - prelimAssessment = "is accurate✅" + prelimAssessment = responses.PLACEHOLDER_ACCURATE infoPlaceholder = infoLiner break case "spam": - prelimAssessment = "is spam🚧" + prelimAssessment = responses.PLACEHOLDER_SPAM break case "legitimate": - prelimAssessment = "is legitimate✅" + prelimAssessment = responses.PLACEHOLDER_LEGITIMATE break case "irrelevant": - prelimAssessment = - "message doesn't contain a meaningful claim to assess.😕" + prelimAssessment = responses.PLACEHOLDER_IRRELEVANT break case "unsure": - prelimAssessment = "unsure" + prelimAssessment = responses.PLACEHOLDER_UNSURE break default: functions.logger.log("primaryCategory did not match available cases") @@ -555,14 +575,14 @@ async function sendInterimUpdate(instancePath: string) { type: "reply", reply: { id: `feedbackInterim_${instancePath}_yes`, - title: "Yes, it's useful", + title: responses.BUTTON_USEFUL, }, }, { type: "reply", reply: { id: `feedbackInterim_${instancePath}_no`, - title: "No, it's not", + title: responses.BUTTON_NOT_USEFUL, }, }, ] @@ -572,7 +592,7 @@ async function sendInterimUpdate(instancePath: string) { type: "reply", reply: { id: `sendInterim_${instancePath}`, - title: "Get another update", + title: responses.BUTTON_ANOTHER_UPDATE, }, }, ] @@ -604,7 +624,7 @@ async function sendInterimPrompt(instanceSnap: DocumentSnapshot) { type: "reply", reply: { id: `sendInterim_${instanceSnap.ref.path}`, - title: "Get interim update", + title: responses.BUTTON_GET_INTERIM, }, }, ] @@ -659,7 +679,7 @@ async function respondToInstance( .replace( "{{matched}}", instanceCount >= 5 - ? `In fact, others have already sent this message in ${instanceCount} times. ` + ? responses.MATCHED.replace("{{numberInstances}}", `${instanceCount}`) : "" ) .replace( @@ -698,7 +718,7 @@ async function respondToInstance( type: "reply", reply: { id: `votingResults_${instanceSnap.ref.path}`, - title: "See voting results", + title: responses.BUTTON_RESULTS, }, } @@ -706,7 +726,7 @@ async function respondToInstance( type: "reply", reply: { id: `scamshieldDecline_${instanceSnap.ref.path}`, - title: "Don't report this", + title: responses.BUTTON_DECLINE_REPORT, }, } @@ -714,7 +734,7 @@ async function respondToInstance( type: "reply", reply: { id: `rationalisation_${instanceSnap.ref.path}`, - title: "How'd we tell?", + title: responses.BUTTON_RATIONALISATION, }, } diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index ca3426f5..423a4174 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,12505 +1,13413 @@ { - "info": { - "_postman_id": "f9991f6c-049a-4e5c-be8e-a80284402235", - "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 (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that has is created\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralId = jsonData.fields.referralId.stringValue\r", - " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", - " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", - " pm.expect(referralId.length).to.be.above(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\",\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": \"Dispute Assessment\",\r", - " \"description\": \"Dispute CheckMate's assesment of this message\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " // get the id of \"Dispute Assessment\" for validation\r", - " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", - " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", - " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", - "\r", - " // remove the id of \"Dispute Assessment\" for comparison\r", - " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", - " if (row.title === \"Dispute Assessment\") {\r", - " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", - " } else {\r", - " return row;\r", - " }\r", - " });\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Dispute Categorisation\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 10\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_10}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 13\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_13}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 14\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"No it's not\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_NOT_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_NOT_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update again", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 15\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005d_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT\")\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\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": SATISFACTION_SURVEY\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Tap to respond\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": \"Extremely likely 🤩\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"9\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"8\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"7\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"6\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"5\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"4\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"3\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"2\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"1\",\r", - " \"description\": \"Not at all likely 😥\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Votes 10", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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 thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "006_Info_Machine_Human", - "item": [ - { - "name": "006a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 19\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "\r", - "// Allow time for firestore onUpdate event to complete\r" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 21\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_21}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "{{PROJECT_ID}}", - "asia-southeast1", - "webhookHandlerV2", - "{{WEBHOOK_PATH}}" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": [] - } - ] - }, - { - "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\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT\")\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\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006c_3rd_Voter_5", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "007_Unsure_Human", - "item": [ - { - "name": "007a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 23\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_23}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 25\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_25}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": "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_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": "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\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 3000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007e_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const isImage = false\r", - " const IMAGE_CAVEAT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT\")\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\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007f_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 29\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_29}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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 thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": wamid\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "008_Menu_Message", - "item": [ - { - "name": "Send WhatApp message (\"Menu\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 30\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_30}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Check/Report\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 31\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_31}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\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\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Contact\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 35\r", - "\r", - "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", - "\r", - "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", - "let n = messageCounter.toString().length;\r", - "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", - "let newId = basePart + messageCounter + \"==\";\r", - "\r", - "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_35}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/{{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\");\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\");\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\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const wamid = pm.variables.get(\"whatsapp_id_37\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\").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\": \"How'd we tell?\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"Don't report this\"\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\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").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", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"satisfactionSurvey_10\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_info\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_contact\",\r", - " \"menu_referral\",\r", - " \"text_machine_scam\",\r", - " \"text_machine_spam\",\r", - " ]\r", - " pm.expect(actions).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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}} {{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 (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 3000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that referral count is incremented to 1\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralCount = jsonData.fields.referralCount.integerValue\r", - " pm.expect(parseInt(referralCount)).to.eql(1);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/{{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}} {{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\");\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": "" - } - ] -} + "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 (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.NEW_USER_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_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_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_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_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_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.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 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 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", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 14\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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(\"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 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_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", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"No it's not\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{PROJECT_ID}}/asia-southeast1/webhookHandlerV2/{{WEBHOOK_PATH}}", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "{{PROJECT_ID}}", + "asia-southeast1", + "webhookHandlerV2", + "{{WEBHOOK_PATH}}" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_NOT_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL.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", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update again", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 15\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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 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 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", + " console.log(JSON.stringify(expected,null,2))\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "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_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.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(\"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 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", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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": [] + } + ] + }, + { + "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": "[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": [] + } + ] + }, + { + "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_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.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 expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": 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": "[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": [] + } + ] + }, + { + "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", + " //console.log(JSON.stringify(expected,null,2))\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/{{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_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_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 (\"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", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"feedbackInterim_no\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"satisfactionSurvey_10\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_info\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_contact\",\r", + " \"menu_referral\",\r", + " \"text_machine_scam\",\r", + " \"text_machine_spam\",\r", + " ]\r", + " pm.expect(actions).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/{{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 (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.NEW_USER_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_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_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 diff --git a/integration-tests/env.json b/integration-tests/env.json index 7603874c..99c1ca46 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -155,32 +155,32 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE.en", - "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}}\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE.cn", - "value": "占位符", + "value": "{thanks}}{{matched}}{{methodology}}*不属实*。❌{{image_caveat}}\n\n请不要再转发了⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING.en", - "value": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}}\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING.cn", - "value": "占位符", + "value": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但整体来看,它*具有误导性或展现不平衡的观点*。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE.en", - "value": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅\n\nThank you for keeping Singapore informed!", + "value": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}}\n\nThank you for keeping Singapore informed!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE.cn", - "value": "占位符", + "value": "{{thanks}}{{matched}}{{methodology}}*是准确的*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -190,7 +190,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ERROR.cn", - "value": "占位符", + "value": "抱歉,我们评估短信时出现了问题。\n\n您可以再次发送短信,或使用我们的反馈表格报告问题:https://bit.ly/checkmate-feedback。非常抱歉!😔", "enabled": true }, { @@ -200,47 +200,47 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED.cn", - "value": "占位符", + "value": "你好!👋 感谢您的提交!我们的查哥查妹🕵🏻将尽快审查这条短信并回复。", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM.en", - "value": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "value": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM.cn", - "value": "占位符", + "value": "{{thanks}}{{matched}}{{methodology}}*是一种诈骗*!🚫{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告此诈骗。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT.en", - "value": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", + "value": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT.cn", - "value": "占位符", + "value": "{{thanks}}{{matched}}{{methodology}}**很可疑*!🚨{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告这条可疑的短信。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM.en", - "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", + "value": "{{thanks}}{{matched}}{{methodology}}spam!🚧{{image_caveat}}\n\nIt's likely harmless, but you should always make sure 🧐\n\nThank you for keeping Singapore safe!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SPAM.cn", - "value": "占位符", + "value": "{{thanks}}{{matched}}{{methodology}}是垃圾信息!🚧{{image_caveat}}\n\n虽然可能无害,但请始终保持警惕 🧐\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE.en", - "value": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅\n\nThank you for keeping Singapore safe!", + "value": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}}\n\nThank you for keeping Singapore safe!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE.cn", - "value": "占位符", + "value": "{{thanks}}{{matched}}{{methodology}}*来自可靠的来源*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -250,37 +250,37 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSURE.cn", - "value": "占位符", + "value": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信*无法做出评估*🤷🏻‍♂️🤷🏻‍♀️。对不起,毕竟我们也只是普通人!😞\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.en", - "value": "Thanks for sending this in! ", + "value": "Thanks for sending this in!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE.cn", - "value": "占位符", + "value": "感谢您提交这条短信!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.en", - "value": "Thanks for waiting! ", + "value": "Thanks for waiting!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED.cn", - "value": "占位符", + "value": "感谢您的耐心等待!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.en", - "value": "Our CheckMates have reviewed this message and think it's ", + "value": "Our CheckMates have reviewed this message and think it's", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.cn", - "value": "占位符", + "value": "我们的查哥查妹审查了这条短信后,认为它", "enabled": true }, { @@ -290,7 +290,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.cn", - "value": "占位符", + "value": "根据我们采用的人工智能技术,我们确信这条短信", "enabled": true }, { @@ -300,7 +300,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MATCHED.cn", - "value": "占位符", + "value": "其实查友已经收到了{{numberInstances}}条同样的短信。", "enabled": true }, { @@ -310,37 +310,17 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSUPPORTED_TYPE.cn", - "value": "占位符", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_EXPLAINER.en", - "value": "ScamShield is an anti-scam product developed by the National Crime Prevention Council and Open Government Products. You can learn more at https://scamshield.org.sg.", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_EXPLAINER.cn", - "value": "占位符", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE.en", - "value": "{{top}}% of our CheckMates identified this as *{{category1}}**{{info_placeholder}}*. *{{second}}*% felt this was *{{category2}}*.", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE.cn", - "value": "占位符", + "value": "对不起,查友目前不支持这种类型的短信。", "enabled": true }, { "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 is that this {{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.{{get_feedback}}", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE.cn", - "value": "占位符", + "value": "目前,我们的查哥查妹中有{{%voted}}%的人已经评估并对这条短信进行了投票。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是*初步结果*。我们的目标是在更多的查哥查妹投票,或者自您发送短信后24小时内,为您提供更可信的最终结果。{{get_feedback}}", "enabled": true }, { @@ -350,7 +330,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE.cn", - "value": "占位符", + "value": "\n目前,我们的查哥查妹中{{%voted}}%的人已经投票评估了这条短信。不幸的是,他们要么没有一致意见,要么缺乏资料来评估这条短信。\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。", "enabled": true }, { @@ -360,7 +340,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.cn", - "value": "占位符", + "value": "感谢您对查友的信任!👋🏼 如果这个临时更新对您有帮助,我们会很感激如果您能点击下方的“有帮助”。否则,点击“没帮助”以继续等待最终结果。无论如何,随着更多投票的到来,您都可以继续请求更多更新。", "enabled": true }, { @@ -370,7 +350,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT.cn", - "value": "占位符", + "value": "感谢您的耐心等待!我们目前仍在等待我们的查友志愿者网络的评估,只有在收到足够的投票后,我们才能提供可信的最终结果。\n\n您可以点击下面的按钮*获取初步结果的临时更新*。但是,请注意,初步结果和最终结果之间可能存在差异,*应谨慎解读初步结果*。我们感谢您的耐心,并希望尽快向您提供最终结果!💪🏼", "enabled": true }, { @@ -380,7 +360,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.cn", - "value": "占位符", + "value": "感谢您的反馈!我们会尽快提供最终结果,一旦我们的查哥查投票更多或者已经过去24小时自您发送短信。\n\n如果您希望在更多投票后再次更新,请点击下方按钮请求。", "enabled": true }, { @@ -390,7 +370,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL.cn", - "value": "占位符", + "value": "很遗憾听到这个消息,但还是要感谢您的宝贵反馈!我们的查哥查妹们投票更多或者自您发送短信后已过24小时时,我们会尽快向您提供最终结果。\n\n如果您希望在更多投票进来后再次更新,请点击下方的按钮进行请求。", "enabled": true }, { @@ -400,7 +380,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED.cn", - "value": "占位符", + "value": "查友已经对这条短信给出了最终的回应。", "enabled": true }, { @@ -410,17 +390,17 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_ON_DECLINE.cn", - "value": "占位符", + "value": "没关系!我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,感谢您对新加坡网络安全的支持和贡献!\n!", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.en", - "value": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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! 😊", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.en", + "value": "Menu", "enabled": true }, { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.cn", - "value": "占位符", + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_BUTTON.cn", + "value": "菜单", "enabled": true }, { @@ -430,7 +410,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX.cn", - "value": "占位符", + "value": "您好,欢迎来到查友!我们注意到这是您第一次使用我们的服务。我们很高兴您加入我们,一起对抗诈骗和误导短信😊。", "enabled": true }, { @@ -440,7 +420,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_MENU_PREFIX.cn", - "value": "占位符", + "value": "感谢您的耐心等待!🙏🏻 我们的查哥查妹在这条短信中没有找到任何可以评估的内容。😕", "enabled": true }, { @@ -450,7 +430,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.cn", - "value": "占位符", + "value": "嗯...这条短信似乎没有什么可以评估的内容。😕", "enabled": true }, { @@ -460,7 +440,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.cn", - "value": "占位符", + "value": "你好!感谢你使用查友。🙏🏻", "enabled": true }, { @@ -470,7 +450,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND.cn", - "value": "占位符", + "value": "好的!只需将短信发送给我们,我们会帮您检查和报告!✅✅\n\n如果愿意,也可以发截图📷或其他图片🖼️!这有助于我们获得发信人号码或完整的对话内容,帮助查哥查妹评估。\n\n最后一点:使用查友即表示同意我们的隐私政策,可在 https://checkmate.sg/privacy-policy 查看。简单来说,我们只收集您发送给我们的短信和您的号码以便回复您!", "enabled": true }, { @@ -480,7 +460,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO.cn", - "value": "占位符", + "value": "请访问 https://youtube.com/shorts/gFeO_qFOchs?feature=share 查看查友的工作原理!\n\n完成了吗?您现在已经准备好使用查友了!让我们一起为打击诈骗和误导短信做出贡献!💪", "enabled": true }, { @@ -490,7 +470,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE.cn", - "value": "占位符", + "value": "要了解更多关于查友的短信,您可以访问我们的网站 https://checkmate.sg", "enabled": true }, { @@ -500,7 +480,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK.cn", - "value": "占位符", + "value": "您可以在 https://bit.ly/checkmate-feedback 提交反馈。请放心,我们会尽快阅读并处理!", "enabled": true }, { @@ -510,7 +490,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE.cn", - "value": "占位符", + "value": "感谢您的反馈!我们的查哥查妹将会重新评估这条短信。", "enabled": true }, { @@ -520,7 +500,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.CONTACT.cn", - "value": "占位符", + "value": "这是我们的联系方式!请将我们添加到您的联系人列表中,以便您以后能找到我们。😊", "enabled": true }, { @@ -530,7 +510,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL.cn", - "value": "占位符", + "value": "您是否已经开始使用查友来检查和报告可疑的短信了?点击此链接并发送预加载的短信进行注册!{{link}}", "enabled": true }, { @@ -540,7 +520,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX.cn", - "value": "占位符", + "value": "欢迎使用查友!发送整条短信(包括代码)以开始使用,并将您的推荐人记入账户。代码:", "enabled": true }, { @@ -550,7 +530,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_PREPOPULATED_PREFIX.cn", - "value": "占位符", + "value": "欢迎使用查友!请将此整条短信(包括代码)发送给我们以开始使用。代码:", "enabled": true }, { @@ -560,7 +540,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID.cn", - "value": "占位符", + "value": "对不起,只有在您首次与查友互动时,推荐才会被记入账户。", "enabled": true }, { @@ -570,7 +550,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_ERROR.cn", - "value": "占位符", + "value": "对不起,出现了一个错误。😔 我们会尽快解决这个问题!同时,您可以尝试使用查友的其他功能。再次为此道歉!", "enabled": true }, { @@ -580,7 +560,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY.cn", - "value": "占位符", + "value": "非常感谢您使用查友🙏。您的反馈对我们非常重要,也会帮我们改进。\n\n请问在1-10的评分中,您有多大可能性向您的朋友、同事或家人推荐查友?", "enabled": true }, { @@ -590,7 +570,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS.cn", - "value": "占位符", + "value": "感谢您的反馈!", "enabled": true }, { @@ -600,7 +580,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOWD_WE_TELL.cn", - "value": "占位符", + "value": "*这是一项由生成式人工智能驱动的实验性功能*。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}", "enabled": true }, { @@ -610,7 +590,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_USEFUL.cn", - "value": "占位符", + "value": "感谢您的反馈!", "enabled": true }, { @@ -620,11 +600,391 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_NOT_USEFUL.cn", - "value": "占位符", + "value": "很遗憾得知此功能对您来说不是很有用。 我已将此消息传递给我们的产品团队,以便将来进一步增强此功能。感谢您的反馈!", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en", + "value": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.cn", + "value": "这个评估是根据标题中的任何声明。如果短信里没有文字标题,此评估是根据图片里的内容。", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.en", + "value": "{{top}}% of our CheckMates felt this was *{{category}}*{{info_placeholder}}.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.cn", + "value": "我们的查哥查妹中有{{top}}%的人认为这条短信*{{category}}*{{info_placeholder}}。", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INFO_PLACEHOLDER.en", + "value": ", with an average score of {{score}} on a scale of 0-5 (5 = completely true)", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.INFO_PLACEHOLDER.cn", + "value": "在0-5的评分标准上,平均分数为{{score}}(5 = 完全正确)", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.en", + "value": "Check/Report", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CHECK.cn", + "value": "查询/举报", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.en", + "value": "Send in messages, images, or screenshots for checking!", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.cn", + "value": "提交消息、图片或截图进行检查!", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.en", + "value": "Get Referral Link", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_REFERRAL.cn", + "value": "获取推荐链接", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.en", + "value": "Get referral link to forward to others", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.cn", + "value": "获取推荐链接以转发给亲戚好友加入查友", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.en", + "value": "Get Help", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_HELP.cn", + "value": "使用说明", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.en", + "value": "Find out how to use CheckMate to check or report dubious messages", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_HELP.cn", + "value": "了解如何使用查友来查询或举报可疑短信", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.en", + "value": "About CheckMate", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_ABOUT.cn", + "value": "关于查友", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.en", + "value": "Learn more about CheckMate and the team behind it", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.cn", + "value": "了解更多关于查友及其幕后团队的短信", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.en", + "value": "Send Feedback", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.cn", + "value": "给予反馈", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.en", + "value": "Send us feedback on anything to do with CheckMate", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.cn", + "value": "给予有关查友的任何反馈", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.en", + "value": "Get Contact", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_CONTACT.cn", + "value": "获取联系方式", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.en", + "value": "Get CheckMate's contact to add to your contact list", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CONTACT.cn", + "value": "获取查友的联系方式并添加查友到您的通讯列表", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.en", + "value": "Dispute Assessment", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.cn", + "value": "争议判断", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.en", + "value": "Dispute CheckMate's assesment of this message", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.cn", + "value": "对查友对此消息的评估提出异议", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_LIKELY.en", + "value": "Extremely likely 🤩", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_LIKELY.cn", + "value": "一定会🤩", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.en", + "value": "Not at all likely 😥", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.cn", + "value": "休想😥", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NPS_MENU_BUTTON.en", + "value": "Respond", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NPS_MENU_BUTTON.cn", + "value": "回应", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.en", + "value": "Yes, it's useful", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_USEFUL.cn", + "value": "有帮助", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.en", + "value": "No, it's not", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_NOT_USEFUL.cn", + "value": "没帮助", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.en", + "value": "Get another update", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.cn", + "value": "再提供审查状态更新", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.en", + "value": "Get interim update", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.cn", + "value": "提供审查状态更新", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.en", + "value": "See voting results", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RESULTS.cn", + "value": "查看投票结果", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.en", + "value": "Don't report this", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.cn", + "value": "不要举报", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.en", + "value": "How'd we tell?", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_RATIONALISATION.cn", + "value": "我们是如何判断的?", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SCAM.en", + "value": "a scam🚫", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SCAM.cn", + "value": "是一种诈骗🚫", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SUSPICIOUS.en", + "value": "illicit🚨", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SUSPICIOUS.cn", + "value": "具有非法性🚨", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_UNTRUE.en", + "value": "untrue❌", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_UNTRUE.cn", + "value": "不真实❌", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_MISLEADING.en", + "value": "misleading⚠️", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_MISLEADING.cn", + "value": "具有误导性⚠️", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_ACCURATE.en", + "value": "accurate✅", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_ACCURATE.cn", + "value": "是准确的✅", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SPAM.en", + "value": "spam🚧", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SPAM.cn", + "value": "是垃圾信息🚧", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_LEGITIMATE.en", + "value": "legitimate✅", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_LEGITIMATE.cn", + "value": "来自可靠的来源✅", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_IRRELEVANT.en", + "value": "message doesn't contain a meaningful claim to assess.😕", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_IRRELEVANT.cn", + "value": "没有包含有意义的声明进行评估😕", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_UNSURE.en", + "value": "too difficult to assess", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_UNSURE.cn", + "value": "很难做评估", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.en", + "value": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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! 😊", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.cn", + "value": "{{prefix}}\n\n如果你知道该怎么做,请继续!否则,请选择下方的\"查看菜单\",看看查友能做什么!👈\n\n请注意,查友*只会帮你审查发送给查友的可疑短信,它不能与你自由对话*。\n\n无论何时你需要再次了解查友的功能,只需输入\"菜单\"即可返回这里!😊", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_2.en", + "value": " {{second}}% felt this was *{{category}}*{{info_placeholder}}.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_2.cn", + "value": "另外{{second}}%的人认为这条短信*{{category}}*{{info_placeholder}}。", "enabled": true } ], "_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 22f36fd2eeedc32515b035daba54c1f7d8c2d5ac Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Thu, 2 Nov 2023 21:23:58 +0800 Subject: [PATCH 26/36] multilingual stuff --- documentation/dataSchema.md | 1 + .../common/parameters/userResponses.json | 34 +- .../src/definitions/common/responseUtils.ts | 189 ++-- .../definitions/eventHandlers/userHandlers.ts | 21 +- .../checkmate.postman_collection.json | 842 +++++++++++++++--- integration-tests/env.json | 84 +- 6 files changed, 968 insertions(+), 203 deletions(-) diff --git a/documentation/dataSchema.md b/documentation/dataSchema.md index fb631412..b631112c 100644 --- a/documentation/dataSchema.md +++ b/documentation/dataSchema.md @@ -114,6 +114,7 @@ erDiagram string referralId "referral code" number referralCount map utm "map containing utm parameters, source, medium, content, campaign, term" + string language "en or cn, users preferred language" } message ||--|{ instance: has diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 2a902d00..c4345465 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -112,12 +112,20 @@ "cn": "没关系!我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,感谢您对新加坡网络安全的支持和贡献!\n!" }, "MENU": { - "en": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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无论何时你需要再次了解查友的功能,只需输入\"菜单\"即可返回这里!😊" + "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无论何时你需要再次了解查友的功能,只需输入\"菜单\"即可返回这里!😊" }, - "NEW_USER_MENU_PREFIX": { - "en": "Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊.", - "cn": "您好,欢迎来到查友!我们注意到这是您第一次使用我们的服务。我们很高兴您加入我们,一起对抗诈骗和误导短信😊。" + "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": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n" + }, + "LANGUAGE_SELECTION": { + "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", + "cn": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。" }, "IRRELEVANT_MENU_PREFIX": { "en": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", @@ -255,6 +263,14 @@ "en": "Dispute CheckMate's assesment of this message", "cn": "对查友对此消息的评估提出异议" }, + "MENU_TITLE_LANGUAGE": { + "en": "Language / 语言", + "cn": "Language / 语言" + }, + "MENU_DESCRIPTION_LANGUAGE": { + "en": "Select Language / 选择语言", + "cn": "Select Language / 选择语言" + }, "MENU_DESCRIPTION_NPS_LIKELY": { "en": "Extremely likely 🤩", "cn": "一定会🤩" @@ -267,6 +283,14 @@ "en": "Respond", "cn": "回应" }, + "BUTTON_ENGLISH": { + "en": "English", + "cn": "English" + }, + "BUTTON_CHINESE": { + "en": "华语", + "cn": "华语" + }, "BUTTON_USEFUL": { "en": "Yes, it's useful", "cn": "有帮助" diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index 8a7d0a5d..5adb1310 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -16,8 +16,7 @@ const db = admin.firestore() type BotResponses = { [key: string]: { - en: string - cn?: string + [key: string]: string } } @@ -25,6 +24,51 @@ type ResponseObject = { [key: string]: string } +async function getResponsesObj(botType: "factChecker"): Promise +async function getResponsesObj(botType: "user"): Promise +async function getResponsesObj( + botType: "user", + user: string +): Promise +async function getResponsesObj( + botType: "user" | "factChecker" = "user", + user: string | null = null +) { + let path + if (botType === "factChecker") { + path = "systemParameters/factCheckerBotResponses" + const checkerResponseSnap = await db.doc(path).get() + return checkerResponseSnap.data() ?? CHECKER_BOT_RESPONSES + } else { + if (typeof user !== "string") { + functions.logger.error("user not provided to getResponsesObj") + return "error" + } + path = "systemParameters/userBotResponses" + const userResponseSnap = await db.doc(path).get() + const userResponseObject = userResponseSnap.data() ?? USER_BOT_RESPONSES + const userSnap = await db.collection("users").doc(user).get() + const language = userSnap.get("language") ?? "en" + const responseProxy = new Proxy(userResponseObject as BotResponses, { + get(target, prop: string) { + if (prop === "then") { + //somehow code tries to access then property + return undefined + } + if (target[prop] && target[prop][language]) { + return target[prop][language] + } else if (target[prop] && target[prop]["en"]) { + // Fallback to English + return target[prop]["en"] + } + functions.logger.error(`Error getting ${prop} from user bot responses`) + return "error" // Or some default value or error handling + }, + }) + return responseProxy + } +} + function getInfoLiner(truthScore: null | number, infoPlaceholder: string) { return infoPlaceholder.replace( "{{score}}", @@ -38,8 +82,9 @@ async function respondToInterimFeedback( ) { const instanceRef = db.doc(instancePath) const instanceSnap = await instanceRef.get() - const responses = await getResponsesObj("user") 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 @@ -65,7 +110,7 @@ async function respondToInterimFeedback( break } - await sendWhatsappButtonMessage("user", data.from, response, buttons, data.id) + await sendWhatsappButtonMessage("user", from, response, buttons, data.id) } async function respondToRationalisationFeedback( @@ -74,8 +119,9 @@ async function respondToRationalisationFeedback( ) { const instanceRef = db.doc(instancePath) const instanceSnap = await instanceRef.get() - const responses = await getResponsesObj("user") const data = instanceSnap.data() + const from = data?.from ?? null + const responses = await getResponsesObj("user", from) if (!data) { functions.logger.log("Missing data in respondToRationalisationFeedback") return @@ -92,41 +138,7 @@ async function respondToRationalisationFeedback( break } - await sendWhatsappTextMessage("user", data.from, response) -} - -async function getResponsesObj(botType: "factChecker"): Promise -async function getResponsesObj(botType: "user"): Promise -async function getResponsesObj(botType: "user" | "factChecker" = "user") { - let path - if (botType === "factChecker") { - path = "systemParameters/factCheckerBotResponses" - const checkerResponseSnap = await db.doc(path).get() - return checkerResponseSnap.data() ?? CHECKER_BOT_RESPONSES - } else { - path = "systemParameters/userBotResponses" - const userResponseSnap = await db.doc(path).get() - const userResponseObject = userResponseSnap.data() ?? USER_BOT_RESPONSES - const language = "en" //TODO: change this to read from user DB - - const responseProxy = new Proxy(userResponseObject as BotResponses, { - get(target, prop: string) { - if (prop === "then") { - //somehow code tries to access then property - return undefined - } - if (target[prop] && target[prop][language]) { - return target[prop][language] - } else if (target[prop] && target[prop]["en"]) { - // Fallback to English - return target[prop]["en"] - } - functions.logger.error(`Error getting ${prop} from user bot responses`) - return "error" // Or some default value or error handling - }, - }) - return responseProxy - } + await sendWhatsappTextMessage("user", from, response) } async function sendMenuMessage( @@ -136,7 +148,7 @@ async function sendMenuMessage( replyMessageId: string | null = null, disputedInstancePath: string | null = null ) { - const responses = await getResponsesObj("user") + const responses = await getResponsesObj("user", to) if (!(prefixName in responses)) { functions.logger.error(`prefixName ${prefixName} not found in responses`) return @@ -177,6 +189,11 @@ async function sendMenuMessage( title: responses.MENU_TITLE_FEEDBACK, description: responses.MENU_DESCRIPTION_FEEDBACK, }, + { + id: `${type}_language`, + title: responses.MENU_TITLE_LANGUAGE, + description: responses.MENU_DESCRIPTION_LANGUAGE, + }, { id: `${type}_contact`, title: responses.MENU_TITLE_CONTACT, @@ -229,9 +246,10 @@ async function sendSatisfactionSurvey(instanceSnap: DocumentSnapshot) { if (!data) { return } - const responses = await getResponsesObj("user") + const from = data?.from ?? null + const responses = await getResponsesObj("user", from) const isSatisfactionSurveySent = instanceSnap.get("isSatisfactionSurveySent") - const userRef = db.collection("users").doc(data.from) + const userRef = db.collection("users").doc(from) const thresholds = await getThresholds() const cooldown = thresholds.satisfactionSurveyCooldownDays ?? 30 const userSnap = await userRef.get() @@ -260,7 +278,7 @@ async function sendSatisfactionSurvey(instanceSnap: DocumentSnapshot) { ] await sendWhatsappTextListMessage( "user", - data.from, + from, responses.SATISFACTION_SURVEY, responses.NPS_MENU_BUTTON, sections @@ -295,8 +313,8 @@ async function sendVotingStats(instancePath: string) { const voteTotal = await getCount(messageRef, "totalVoteScore") const truthScore = infoCount > 0 ? voteTotal / infoCount : null const thresholds = await getThresholds() - const responses = await getResponsesObj("user") const from = instanceSnap.get("from") + const responses = await getResponsesObj("user", from) let truthCategory if (responseCount <= 0) { @@ -406,7 +424,8 @@ async function sendRationalisation(instancePath: string) { const instanceRef = db.doc(instancePath) const instanceSnap = await instanceRef.get() const data = instanceSnap.data() - const responses = await getResponsesObj("user") + const from = data?.from ?? null + const responses = await getResponsesObj("user", from) try { const messageRef = instanceRef.parent.parent if (!data) { @@ -450,31 +469,34 @@ async function sendRationalisation(instancePath: string) { await instanceRef.update({ isRationalisationSent: true, }) - await sendWhatsappButtonMessage( - "user", - data.from, - replyText, - buttons, - data.id - ) + await sendWhatsappButtonMessage("user", from, replyText, buttons, data.id) } catch (e) { functions.logger.error(`Error sending rationalisation: ${e}`) if (data?.from) { - await sendTextMessage("user", data.from, responses.GENERIC_ERROR) + await sendTextMessage("user", from, responses.GENERIC_ERROR) } } } +async function updateLanguageAndSendMenu(from: string, language: string) { + const userRef = db.collection("users").doc(from) + await userRef.update({ + language: language, + }) + await sendMenuMessage(from, "MENU_PREFIX") +} + async function sendInterimUpdate(instancePath: string) { //get statistics const FEEDBACK_FEATURE_FLAG = true - const responses = await getResponsesObj("user") const instanceRef = db.doc(instancePath) const instanceSnap = await instanceRef.get() const data = instanceSnap.data() if (!data) { return } + const from = data?.from ?? null + const responses = await getResponsesObj("user", from) if (instanceSnap.get("isReplied")) { await sendTextMessage( "user", @@ -597,13 +619,7 @@ async function sendInterimUpdate(instancePath: string) { }, ] } - await sendWhatsappButtonMessage( - "user", - data.from, - finalResponse, - buttons, - data.id - ) + await sendWhatsappButtonMessage("user", from, finalResponse, buttons, data.id) if (!instanceSnap.get("isInterimReplySent")) { updateObj.isInterimReplySent = true } @@ -618,7 +634,8 @@ async function sendInterimPrompt(instanceSnap: DocumentSnapshot) { if (!data) { return } - const responses = await getResponsesObj("user") + const from = data?.from ?? null + const responses = await getResponsesObj("user", from) const buttons = [ { type: "reply", @@ -630,7 +647,7 @@ async function sendInterimPrompt(instanceSnap: DocumentSnapshot) { ] await sendWhatsappButtonMessage( "user", - data.from, + from, responses.INTERIM_PROMPT, buttons, data.id @@ -654,7 +671,8 @@ async function respondToInstance( functions.logger.log("Missing 'from' field in instance data") return Promise.resolve() } - const responses = await getResponsesObj("user") + const from = data.from + const responses = await getResponsesObj("user", from) const thresholds = await getThresholds() const isAssessed = parentMessageSnap.get("isAssessed") const isIrrelevant = parentMessageSnap.get("isIrrelevant") @@ -694,7 +712,7 @@ async function respondToInstance( if (!isAssessed && !forceReply) { await sendTextMessage( "user", - data.from, + from, responses.MESSAGE_NOT_YET_ASSESSED, data.id ) @@ -778,7 +796,7 @@ async function respondToInstance( switch (category) { case "irrelevant_auto": await sendMenuMessage( - data.from, + from, "IRRELEVANT_AUTO_MENU_PREFIX", "whatsapp", data.id, @@ -787,7 +805,7 @@ async function respondToInstance( break case "irrelevant": await sendMenuMessage( - data.from, + from, "IRRELEVANT_MENU_PREFIX", "whatsapp", data.id, @@ -796,7 +814,7 @@ async function respondToInstance( break case "error": responseText = getFinalResponseText(responses.ERROR) - await sendTextMessage("user", data.from, responseText, data.id) + await sendTextMessage("user", from, responseText, data.id) break default: if (!(category.toUpperCase() in responses)) { @@ -825,13 +843,13 @@ async function respondToInstance( if (buttons.length > 0) { await sendWhatsappButtonMessage( "user", - data.from, + from, responseText, buttons, data.id ) } else { - await sendTextMessage("user", data.from, responseText, data.id) + await sendTextMessage("user", from, responseText, data.id) } } updateObj.replyCategory = category @@ -849,7 +867,7 @@ async function respondToInstance( async function sendReferralMessage(user: string) { let referralResponse const code = (await db.collection("users").doc(user).get()).get("referralId") - const responses = await getResponsesObj("user") + const responses = await getResponsesObj("user", user) if (code) { referralResponse = responses.REFERRAL.replace( "{{link}}", @@ -862,6 +880,31 @@ async function sendReferralMessage(user: string) { await sendTextMessage("user", user, referralResponse, null, "whatsapp", true) } +async function sendLanguageSelection(user: string, newUser: boolean) { + const responses = await getResponsesObj("user", user) + const response = responses.LANGUAGE_SELECTION.replace( + "{{new_user_en}}", + newUser ? responses.NEW_USER_PREFIX_EN : "" + ).replace("{{new_user_cn}}", newUser ? responses.NEW_USER_PREFIX_CN : "") + const buttons = [ + { + type: "reply", + reply: { + id: `languageSelection_en`, + title: responses.BUTTON_ENGLISH, + }, + }, + { + type: "reply", + reply: { + id: `languageSelection_cn`, + title: responses.BUTTON_CHINESE, + }, + }, + ] + await sendWhatsappButtonMessage("user", user, response, buttons) +} + export { getResponsesObj, respondToInstance, @@ -873,4 +916,6 @@ export { respondToInterimFeedback, sendRationalisation, respondToRationalisationFeedback, + updateLanguageAndSendMenu, + sendLanguageSelection, } diff --git a/functions/src/definitions/eventHandlers/userHandlers.ts b/functions/src/definitions/eventHandlers/userHandlers.ts index 141e5263..5eb9f73f 100644 --- a/functions/src/definitions/eventHandlers/userHandlers.ts +++ b/functions/src/definitions/eventHandlers/userHandlers.ts @@ -23,6 +23,8 @@ import { respondToInterimFeedback, sendRationalisation, respondToRationalisationFeedback, + updateLanguageAndSendMenu, + sendLanguageSelection, } from "../common/responseUtils" import { downloadWhatsappMedia, @@ -37,6 +39,7 @@ import { classifyText } from "../common/classifier" import { FieldValue } from "@google-cloud/firestore" import Hashids from "hashids" import { Message } from "../../types" +import { user } from "firebase-functions/v1/auth" const runtimeEnvironment = defineString("ENVIRONMENT") const similarityThreshold = defineString("SIMILARITY_THRESHOLD") @@ -62,7 +65,7 @@ const userHandlerWhatsapp = async function (message: Message) { let from = message.from // extract the phone number from the webhook payload let type = message.type - const responses = await getResponsesObj("user") + const responses = await getResponsesObj("user", from) //check whether new user const userRef = db.collection("users").doc(from) @@ -713,13 +716,13 @@ async function newImageInstanceHandler({ } async function newUserHandler(from: string) { - await sendMenuMessage(from, "NEW_USER_MENU_PREFIX", "whatsapp", null, null) + await sendLanguageSelection(from, true) } async function onButtonReply(messageObj: Message, platform = "whatsapp") { const buttonId = messageObj.interactive.button_reply.id const from = messageObj.from - const responses = await getResponsesObj("user") + const responses = await getResponsesObj("user", from) const [type, ...rest] = buttonId.split("_") let instancePath, selection, @@ -763,6 +766,10 @@ async function onButtonReply(messageObj: Message, platform = "whatsapp") { ;[instancePath, selection] = rest await respondToRationalisationFeedback(instancePath, selection) break + case "languageSelection": + ;[selection] = rest + await updateLanguageAndSendMenu(from, selection) + break } const step = type + (selection ? `_${selection}` : "") return Promise.resolve(step) @@ -771,7 +778,7 @@ async function onButtonReply(messageObj: Message, platform = "whatsapp") { async function onTextListReceipt(messageObj: Message, platform = "whatsapp") { const listId = messageObj.interactive.list_reply.id const from = messageObj.from - const responses = await getResponsesObj("user") + const responses = await getResponsesObj("user", from) const [type, selection, ...rest] = listId.split("_") let response, instancePath const step = `${type}_${selection}` @@ -794,6 +801,11 @@ async function onTextListReceipt(messageObj: Message, platform = "whatsapp") { response = responses.FEEDBACK break + case "language": + await sendLanguageSelection(from, false) + hasReplied = true + break + case "contact": const nameObj = { formatted_name: "CheckMate", suffix: "CheckMate" } response = responses.CONTACT @@ -904,6 +916,7 @@ async function createNewUser( initialJourney: {}, referralId: referralId, referralCount: 0, + language: "en", }) } diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 423a4174..d8d70522 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -988,7 +988,142 @@ "response": [] }, { - "name": "Get last message (NEW_USER_MENU)", + "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", @@ -996,7 +1131,7 @@ "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.NEW_USER_MENU_PREFIX.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", @@ -1009,6 +1144,8 @@ " 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", @@ -1060,6 +1197,11 @@ " \"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", @@ -1241,6 +1383,8 @@ " 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", @@ -1298,6 +1442,11 @@ " \"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", @@ -10991,6 +11140,8 @@ " 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", @@ -11042,6 +11193,11 @@ " \"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", @@ -11559,7 +11715,7 @@ "response": [] }, { - "name": "Make Menu Selection (\"Get Contact\")", + "name": "Make Menu Selection (\"Select Language\")", "event": [ { "listen": "test", @@ -11577,7 +11733,7 @@ "script": { "exec": [ "// 1. Retrieve the current messageCounter and increment it.\r", - "let messageCounter = 35\r", + "let messageCounter = 34\r", "\r", "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", "\r", @@ -11598,7 +11754,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\": \"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}", + "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" @@ -11621,14 +11777,19 @@ "response": [] }, { - "name": "Get last message (contact type)", + "name": "Get last message (SELECT LANGUAGE)", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + "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", @@ -11637,29 +11798,37 @@ " \"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", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": BODY_TEXT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", " {\r", - " \"url\": \"https://checkmate.sg\"\r", - " }\r", - " ],\r", - " \"phones\": [\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_en\",\r", + " \"title\": BUTTON_ENGLISH\r", + " }\r", + " },\r", " {\r", - " \"phone\": \"+1 555-093-3685\"\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"languageSelection_cn\",\r", + " \"title\": BUTTON_CHINESE\r", + " }\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", "});" ], @@ -11670,54 +11839,7 @@ "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", - "});" + "setTimeout(() => {}, 3000);" ], "type": "text/javascript" } @@ -11739,7 +11861,7 @@ "response": [] }, { - "name": "Make Menu Selection (\"Referral\")", + "name": "Press English Button", "event": [ { "listen": "test", @@ -11756,17 +11878,6 @@ "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" @@ -11778,7 +11889,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\": \"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}", + "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" @@ -11801,38 +11912,404 @@ "response": [] }, { - "name": "Get last message (REFERRAL)", + "name": "Get last message (USER_MENU)", "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" - } - }, - { + " 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": [ @@ -12180,6 +12657,7 @@ " 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", @@ -12205,6 +12683,8 @@ " \"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", @@ -12312,6 +12792,141 @@ }, "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": [ @@ -12321,7 +12936,7 @@ "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.NEW_USER_MENU_PREFIX.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", @@ -12334,6 +12949,8 @@ " 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", @@ -12385,6 +13002,11 @@ " \"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", diff --git a/integration-tests/env.json b/integration-tests/env.json index 99c1ca46..02a08e76 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -403,16 +403,6 @@ "value": "菜单", "enabled": true }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX.en", - "value": "Hello and welcome to CheckMate! We noticed it's your first time here. We're glad you've joined us to battle scams and misinformation😊.", - "enabled": true - }, - { - "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX.cn", - "value": "您好,欢迎来到查友!我们注意到这是您第一次使用我们的服务。我们很高兴您加入我们,一起对抗诈骗和误导短信😊。", - "enabled": true - }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_MENU_PREFIX.en", "value": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", @@ -965,12 +955,12 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU.en", - "value": "{{prefix}}\n\nIf you know what to do, please go ahead! Else, select \"View 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! 😊", + "value": "{{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! 😊", "enabled": true }, { "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 }, { @@ -982,6 +972,76 @@ "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_2.cn", "value": "另外{{second}}%的人认为这条短信*{{category}}*{{info_placeholder}}。", "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.en", + "value": "Hello and welcome to CheckMate! We're glad you've joined us to battle scams and misinformation😊.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_EN.cn", + "value": "Hello and welcome to CheckMate! We're glad you've joined us to battle scams and misinformation😊.", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.en", + "value": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.cn", + "value": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en", + "value": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.cn", + "value": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.en", + "value": "Language / 语言", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_LANGUAGE.cn", + "value": "Language / 语言", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.en", + "value": "Select Language / 选择语言", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_LANGUAGE.cn", + "value": "Select Language / 选择语言", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.en", + "value": "English", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ENGLISH.cn", + "value": "English", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.en", + "value": "华语", + "enabled": true + }, + { + "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_CHINESE.cn", + "value": "华语", + "enabled": true } ], "_postman_variable_scope": "environment", From 92b532bc8c7611bde6119e809b89c00a1268b2c2 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Thu, 2 Nov 2023 21:32:16 +0800 Subject: [PATCH 27/36] fixed issue with update-env.ts --- integration-tests/update-env.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/update-env.ts b/integration-tests/update-env.ts index 2398d54a..383ad2f8 100644 --- a/integration-tests/update-env.ts +++ b/integration-tests/update-env.ts @@ -5,7 +5,6 @@ import fs from "fs" import env from "./env.json" import CHECKER_BOT_REPONSES from "../functions/src/definitions/common/parameters/checkerResponses.json" import USER_BOT_RESPONSES from "../functions/src/definitions/common/parameters/userResponses.json" -import { language } from "googleapis/build/src/apis/language" const factCheckerKeys = Object.keys(CHECKER_BOT_REPONSES).map((key) => { return `__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.${key}` From fa03c3cce5d77b42b676bf07b84b687199849925 Mon Sep 17 00:00:00 2001 From: bingwen Date: Fri, 3 Nov 2023 09:03:59 +0800 Subject: [PATCH 28/36] added caidan as menu keyword --- functions/src/definitions/eventHandlers/userHandlers.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/src/definitions/eventHandlers/userHandlers.ts b/functions/src/definitions/eventHandlers/userHandlers.ts index 5eb9f73f..37ebfb32 100644 --- a/functions/src/definitions/eventHandlers/userHandlers.ts +++ b/functions/src/definitions/eventHandlers/userHandlers.ts @@ -171,8 +171,7 @@ const userHandlerWhatsapp = async function (message: Message) { } break } - - if (message.text.body.toLowerCase() === "menu") { + if (checkMenu(message.text.body)) { step = "text_menu" await sendMenuMessage(from, "MENU_PREFIX", "whatsapp", null, null) break @@ -901,6 +900,11 @@ async function addInstanceToDb( } } +function checkMenu(text: string) { + const menuKeywords = ["menu", "菜单"] + return menuKeywords.includes(text.toLowerCase()) +} + async function createNewUser( userRef: admin.firestore.DocumentReference, messageTimestamp: Timestamp From 856ba865dd6b2ab13d1ade2d1adb32195d3d9d26 Mon Sep 17 00:00:00 2001 From: bingwen Date: Fri, 3 Nov 2023 09:44:02 +0800 Subject: [PATCH 29/36] added fanti caidan --- functions/src/definitions/eventHandlers/userHandlers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/definitions/eventHandlers/userHandlers.ts b/functions/src/definitions/eventHandlers/userHandlers.ts index 37ebfb32..a8b7da9b 100644 --- a/functions/src/definitions/eventHandlers/userHandlers.ts +++ b/functions/src/definitions/eventHandlers/userHandlers.ts @@ -901,7 +901,7 @@ async function addInstanceToDb( } function checkMenu(text: string) { - const menuKeywords = ["menu", "菜单"] + const menuKeywords = ["menu", "菜单", "菜單"] return menuKeywords.includes(text.toLowerCase()) } From b66af6b0552aedc96878ac0beb0db2c62da15e4f Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 10:37:12 +0800 Subject: [PATCH 30/36] changes to chinese copy --- functions/package-lock.json | 14 +-- functions/package.json | 2 +- .../common/parameters/userResponses.json | 114 +++++++++--------- 3 files changed, 65 insertions(+), 65 deletions(-) diff --git a/functions/package-lock.json b/functions/package-lock.json index d905a9ff..c48d3860 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -13,7 +13,7 @@ "express": "^4.18.2", "firebase": "^9.15.0", "firebase-admin": "^11.4.1", - "firebase-functions": "^4.4.1", + "firebase-functions": "^4.5.0", "googleapis": "^112.0.0", "hashids": "^2.3.0", "image-hash": "^5.3.1", @@ -6919,9 +6919,9 @@ } }, "node_modules/firebase-functions": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-4.4.1.tgz", - "integrity": "sha512-3no53Lg12ToNlPSgLZtAFLQAz6si7ilHvzO8NC3/2EybyUwegpj5YhHwNiCw839lmAWp3znjATJDTvADFiZMrg==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-4.5.0.tgz", + "integrity": "sha512-y6HsasHtGLfXCp3Pfrz+JA19lO9hSzYiNxFDIDMffrfcsG7UbXzv0zfi2ASadMVRoDCaox5ppZBa1QJxZbctPQ==", "dependencies": { "@types/cors": "^2.8.5", "@types/express": "4.17.3", @@ -17993,9 +17993,9 @@ } }, "firebase-functions": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-4.4.1.tgz", - "integrity": "sha512-3no53Lg12ToNlPSgLZtAFLQAz6si7ilHvzO8NC3/2EybyUwegpj5YhHwNiCw839lmAWp3znjATJDTvADFiZMrg==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-4.5.0.tgz", + "integrity": "sha512-y6HsasHtGLfXCp3Pfrz+JA19lO9hSzYiNxFDIDMffrfcsG7UbXzv0zfi2ASadMVRoDCaox5ppZBa1QJxZbctPQ==", "requires": { "@types/cors": "^2.8.5", "@types/express": "4.17.3", diff --git a/functions/package.json b/functions/package.json index 55d4746f..7fa348e2 100644 --- a/functions/package.json +++ b/functions/package.json @@ -25,7 +25,7 @@ "express": "^4.18.2", "firebase": "^9.15.0", "firebase-admin": "^11.4.1", - "firebase-functions": "^4.4.1", + "firebase-functions": "^4.5.0", "googleapis": "^112.0.0", "hashids": "^2.3.0", "image-hash": "^5.3.1", diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index c4345465..24622bb5 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -1,11 +1,11 @@ { "UNTRUE": { "en": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}}\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", - "cn": "{thanks}}{{matched}}{{methodology}}*不属实*。❌{{image_caveat}}\n\n请不要再转发了⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n" + "cn": "{thanks}}{{matched}}{{methodology}}*不属实*。❌{{image_caveat}}\n\n请不要转发⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n" }, "MISLEADING": { "en": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}}\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", - "cn": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但整体来看,它*具有误导性或展现不平衡的观点*。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但它*存在误导性或缺乏公正性*。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!" }, "ACCURATE": { "en": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}}\n\nThank you for keeping Singapore informed!", @@ -13,31 +13,31 @@ }, "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*.", - "cn": "你好!👋 感谢您的提交!我们的查哥查妹🕵🏻将尽快审查这条短信并回复。" + "cn": "你好!👋 感谢您使用查友!我们的查哥查妹🕵🏻会尽快评估这条短信并回复。" }, "SCAM": { "en": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", - "cn": "{{thanks}}{{matched}}{{methodology}}*是一种诈骗*!🚫{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告此诈骗。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。" + "cn": "{{thanks}}{{matched}}{{methodology}}*是诈骗信息*! 🚫{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。" }, "ILLICIT": { "en": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", - "cn": "{{thanks}}{{matched}}{{methodology}}**很可疑*!🚨{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告这条可疑的短信。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。" + "cn": "{{thanks}}{{matched}}{{methodology}}**很可疑*!🚨{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。" }, "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!", - "cn": "{{thanks}}{{matched}}{{methodology}}*来自可靠的来源*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}*的来源是可靠的*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" }, "UNSURE": { "en": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", - "cn": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信*无法做出评估*🤷🏻‍♂️🤷🏻‍♀️。对不起,毕竟我们也只是普通人!😞\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信*无法得出结论*🤷🏻‍♂️🤷🏻‍♀️。对不起,我们尽力了!😞\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。\n\n感谢您对新加坡网络安全的支持和贡献!" }, "THANKS_IMMEDIATE": { "en": "Thanks for sending this in!", @@ -48,28 +48,28 @@ "cn": "感谢您的耐心等待!" }, "IMAGE_CAVEAT": { - "en": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", - "cn": "这个评估是根据标题中的任何声明。如果短信里没有文字标题,此评估是根据图片里的内容。" + "en": "This assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", + "cn": "我们的评估基于图片标题中的内容。如果您提交的短信里没有文字标题,我们对图片本身的内容进行了评估。" }, "METHODOLOGY_HUMAN": { "en": "Our CheckMates have reviewed this message and think it's", - "cn": "我们的查哥查妹审查了这条短信后,认为它" + "cn": "经过查哥查妹的评估,我们认为这条短信" }, "METHODOLOGY_AUTO": { "en": "Based on pattern matching, our auto-classifier is confident that this message is ", - "cn": "根据我们采用的人工智能技术,我们确信这条短信" + "cn": "根据我们的AI技术,我们认为这条短信" }, "MATCHED": { "en": "In fact, other users have sent this message in {{numberInstances}} times. ", - "cn": "其实查友已经收到了{{numberInstances}}条同样的短信。" + "cn": "其实查友已收到{{numberInstances}}条同样的短信。" }, "UNSUPPORTED_TYPE": { "en": "Sorry, CheckMate currently doesn't support this type of message.", - "cn": "对不起,查友目前不支持这种类型的短信。" + "cn": "对不起,查友目前不支持这类短信。" }, "STATS_TEMPLATE_1": { "en": "{{top}}% of our CheckMates felt this was *{{category}}*{{info_placeholder}}.", - "cn": "我们的查哥查妹中有{{top}}%的人认为这条短信*{{category}}*{{info_placeholder}}。" + "cn": "{{top}}%的查哥查妹认为这条短信*{{category}}*{{info_placeholder}}。" }, "STATS_TEMPLATE_2": { "en": " {{second}}% felt this was *{{category}}*{{info_placeholder}}.", @@ -77,43 +77,43 @@ }, "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}}" + "cn": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是*初步结果*。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。{{get_feedback}}" }, "INFO_PLACEHOLDER": { "en": ", with an average score of {{score}} on a scale of 0-5 (5 = completely true)", - "cn": "在0-5的评分标准上,平均分数为{{score}}(5 = 完全正确)" + "cn": "在0 - 5的评分内,平均投票分数为{{score}}(5 = 完全正确)" }, "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": "\n目前,我们的查哥查妹中{{%voted}}%的人已经投票评估了这条短信。不幸的是,他们要么没有一致意见,要么缺乏资料来评估这条短信。\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。" + "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": "感谢您对查友的信任!👋🏼 如果这个初步结果对您有帮助,请点击“有帮助”。否则,请点击“没帮助”以继续等待最终结果。您可以在最终结果发布之前随时要求最新的初步结果。" }, "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在最终结果发布之前,您可以点击*获取初步结果*。请注意,初步结果和最终结果之间可能存在差异,*应谨慎解读初步结果*。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼" }, "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如果您希望在更多投票后再次更新,请点击下方按钮请求。" + "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": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,尽快为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。" }, "ALREADY_REPLIED": { "en": "CheckMate has already provided a final response to this message.", - "cn": "查友已经对这条短信给出了最终的回应。" + "cn": "查友已经对这条短信做出最终回应。" }, "SCAMSHIELD_ON_DECLINE": { "en": "No worries! We will not send your message to ScamShield. Thank you for sharing this message with us, and for keeping Singapore safe!", - "cn": "没关系!我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,感谢您对新加坡网络安全的支持和贡献!\n!" + "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! 😊", - "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😊.", @@ -121,7 +121,7 @@ }, "NEW_USER_PREFIX_CN": { "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", - "cn": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n" + "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。" }, "LANGUAGE_SELECTION": { "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", @@ -129,31 +129,31 @@ }, "IRRELEVANT_MENU_PREFIX": { "en": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", - "cn": "感谢您的耐心等待!🙏🏻 我们的查哥查妹在这条短信中没有找到任何可以评估的内容。😕" + "cn": "感谢您的耐心等待!🙏🏻 我们的查哥查妹没有在这条短信中找到可以评估的内容。😕" }, "IRRELEVANT_AUTO_MENU_PREFIX": { "en": "Hmm...There doesn't seem to be anything to assess in this message.😕", - "cn": "嗯...这条短信似乎没有什么可以评估的内容。😕" + "cn": "嗯...这条短信似乎没有可以评估的内容。😕" }, "MENU_PREFIX": { "en": "Hi! Thanks for using CheckMate. 🙏🏻", - "cn": "你好!感谢你使用查友。🙏🏻" + "cn": "您好!感谢您使用查友。🙏🏻" }, "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! 💪", - "cn": "请访问 https://youtube.com/shorts/gFeO_qFOchs?feature=share 查看查友的工作原理!\n\n完成了吗?您现在已经准备好使用查友了!让我们一起为打击诈骗和误导短信做出贡献!💪" + "cn": "了解查友是如何运行的:https://youtube.com/shorts/gFeO_qFOchs?feature=share\n\n准备好了吗?您可以开始使用查友了!让我们一起为反击诈骗和虚假信息做出贡献!💪" }, "LEARN_MORE": { "en": "To learn more about CheckMate, you can visit our website at https://checkmate.sg", - "cn": "要了解更多关于查友的短信,您可以访问我们的网站 https://checkmate.sg" + "cn": "若想了解有关查友的更多信息,您可以访问我们的网站 https://checkmate.sg" }, "FEEDBACK": { "en": "You can submit feedback at https://bit.ly/checkmate-feedback. Rest assured, we'll read it ASAP!", - "cn": "您可以在 https://bit.ly/checkmate-feedback 提交反馈。请放心,我们会尽快阅读并处理!" + "cn": "您可以在 https://bit.ly/checkmate-feedback 提供反馈。我们会尽快查看!" }, "DISPUTE": { "en": "Thanks for letting us know! Our CheckMates will review the assessment of this message.", @@ -165,27 +165,27 @@ }, "REFERRAL": { "en": "Have you started checking and reporting suspicious messages using CheckMate yet? Sign up by clicking this link and sending in the pre-loaded message!! {{link}}", - "cn": "您是否已经开始使用查友来检查和报告可疑的短信了?点击此链接并发送预加载的短信进行注册!{{link}}" + "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": "欢迎使用查友!发送整条短信(包括代码)以开始使用,并将您的推荐人记入账户。代码:" + "cn": "欢迎使用查友!请发送这条短信(包括推荐人代码)以开始使用。代码:" }, "GENERIC_PREPOPULATED_PREFIX": { "en": "Welcome to Checkmate! Send in this entire message (including the code) to get started. Code:", - "cn": "欢迎使用查友!请将此整条短信(包括代码)发送给我们以开始使用。代码:" + "cn": "欢迎使用查友!请发送这条短信(包括代码)以开始使用。代码:" }, "REFERRAL_INVALID": { "en": "Sorry, referrals are only credited upon your first interaction with CheckMate.", - "cn": "对不起,只有在您首次与查友互动时,推荐才会被记入账户。" + "cn": "对不起,推荐人代码仅在您首次与查友互动时才有效。" }, "GENERIC_ERROR": { - "en": "Sorry, an error occured. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", - "cn": "对不起,出现了一个错误。😔 我们会尽快解决这个问题!同时,您可以尝试使用查友的其他功能。再次为此道歉!" + "en": "Sorry, an error occurred. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", + "cn": "抱歉,查友出现了错误。😔 我们会尽快解决这个问题!您可以尝试使用查友的其他功能。我们再次为此道歉!" }, "SATISFACTION_SURVEY": { "en": "Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us.\n\nOn a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?", - "cn": "非常感谢您使用查友🙏。您的反馈对我们非常重要,也会帮我们改进。\n\n请问在1-10的评分中,您有多大可能性向您的朋友、同事或家人推荐查友?" + "cn": "非常感谢您使用查友🙏。您的反馈对我们非常重要,也会帮我们改进。\n\n请问在1-10之间,您愿意向朋友、同事或家人推荐查友吗?" }, "SATISFACTION_SURVEY_THANKS": { "en": "Thanks for your feedback!", @@ -193,7 +193,7 @@ }, "HOWD_WE_TELL": { "en": "*This is an experimental feature powered by generative AI*. Do let us know if it was useful below!\n \n{{rationalisation}}", - "cn": "*这是一项由生成式人工智能驱动的实验性功能*。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}" + "cn": "*这是一项由AI技术提供的实验性功能。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}" }, "RATIONALISATION_USEFUL": { "en": "Thanks for your valuable feedback!", @@ -201,7 +201,7 @@ }, "RATIONALISATION_NOT_USEFUL": { "en": "Sorry to hear that, but thanks anyway for your valuable feedback!", - "cn": "很遗憾得知此功能对您来说不是很有用。 我已将此消息传递给我们的产品团队,以便将来进一步增强此功能。感谢您的反馈!" + "cn": "很遗憾此功能对您来说不是很有用。 查友已将您的反馈传递给我们的产品团队,以便进一步增强此功能。感谢您的反馈!" }, "MENU_BUTTON": { "en": "Menu", @@ -213,7 +213,7 @@ }, "MENU_DESCRIPTION_CHECK": { "en": "Send in messages, images, or screenshots for checking!", - "cn": "提交消息、图片或截图进行检查!" + "cn": "提交文字内容、图片或截图进行评估" }, "MENU_TITLE_REFERRAL": { "en": "Get Referral Link", @@ -221,7 +221,7 @@ }, "MENU_DESCRIPTION_REFERRAL": { "en": "Get referral link to forward to others", - "cn": "获取推荐链接以转发给亲戚好友加入查友" + "cn": "获取加入查友的推荐链接以转发给好友" }, "MENU_TITLE_HELP": { "en": "Get Help", @@ -237,11 +237,11 @@ }, "MENU_DESCRIPTION_ABOUT": { "en": "Learn more about CheckMate and the team behind it", - "cn": "了解更多关于查友及其幕后团队的短信" + "cn": "了解更多关于查友及幕后团队的短信" }, "MENU_TITLE_FEEDBACK": { "en": "Send Feedback", - "cn": "给予反馈" + "cn": "反馈" }, "MENU_DESCRIPTION_FEEDBACK": { "en": "Send us feedback on anything to do with CheckMate", @@ -257,11 +257,11 @@ }, "MENU_TITLE_DISPUTE": { "en": "Dispute Assessment", - "cn": "争议判断" + "cn": "提出异议" }, "MENU_DESCRIPTION_DISPUTE": { "en": "Dispute CheckMate's assesment of this message", - "cn": "对查友对此消息的评估提出异议" + "cn": "对查友的评估提出异议" }, "MENU_TITLE_LANGUAGE": { "en": "Language / 语言", @@ -277,7 +277,7 @@ }, "MENU_DESCRIPTION_NPS_UNLIKELY": { "en": "Not at all likely 😥", - "cn": "休想😥" + "cn": "不会😥" }, "NPS_MENU_BUTTON": { "en": "Respond", @@ -301,11 +301,11 @@ }, "BUTTON_ANOTHER_UPDATE": { "en": "Get another update", - "cn": "再提供审查状态更新" + "cn": "获取初步结果更新" }, "BUTTON_GET_INTERIM": { "en": "Get interim update", - "cn": "提供审查状态更新" + "cn": "获取初步结果" }, "BUTTON_RESULTS": { "en": "See voting results", @@ -313,7 +313,7 @@ }, "BUTTON_DECLINE_REPORT": { "en": "Don't report this", - "cn": "不要举报" + "cn": "不举报" }, "BUTTON_RATIONALISATION": { "en": "How'd we tell?", @@ -321,11 +321,11 @@ }, "PLACEHOLDER_SCAM": { "en": "a scam🚫", - "cn": "是一种诈骗🚫" + "cn": "是诈骗信息🚫" }, "PLACEHOLDER_SUSPICIOUS": { "en": "illicit🚨", - "cn": "具有非法性🚨" + "cn": "包含非法内容🚨" }, "PLACEHOLDER_UNTRUE": { "en": "untrue❌", @@ -349,10 +349,10 @@ }, "PLACEHOLDER_IRRELEVANT": { "en": "message doesn't contain a meaningful claim to assess.😕", - "cn": "没有包含有意义的声明进行评估😕" + "cn": "没有可以评估的内容😕" }, "PLACEHOLDER_UNSURE": { "en": "too difficult to assess", "cn": "很难做评估" } -} +} \ No newline at end of file From 46a3f30142c157eb96ba887d7003825140c692fa Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 11:55:37 +0800 Subject: [PATCH 31/36] updated firebase-deploy --- .github/workflows/firebase-deploy.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/firebase-deploy.yml b/.github/workflows/firebase-deploy.yml index f8bb55bc..373d2937 100644 --- a/.github/workflows/firebase-deploy.yml +++ b/.github/workflows/firebase-deploy.yml @@ -43,14 +43,12 @@ jobs: fi - name: Install Firebase CLI run: npm install -g firebase-tools - - name: Set Firebase project + - name: Deploy Cloud Functions run: | + export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json if [ "${{ github.ref }}" == "refs/heads/main" ]; then - firebase use prod + firebase deploy --only functions --project checkmate-373101 else - firebase use uat + firebase deploy --only functions --project checkmate-uat fi working-directory: functions - - name: Deploy Cloud Functions - run: export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json && npm run deploy - working-directory: functions From 36fd5b751108bda768030a75e06a31212b94fcdb Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 12:45:11 +0800 Subject: [PATCH 32/36] fixed firebase-deploy.yml --- .github/workflows/firebase-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/firebase-deploy.yml b/.github/workflows/firebase-deploy.yml index 373d2937..3b0f76c0 100644 --- a/.github/workflows/firebase-deploy.yml +++ b/.github/workflows/firebase-deploy.yml @@ -47,8 +47,8 @@ jobs: run: | export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json if [ "${{ github.ref }}" == "refs/heads/main" ]; then - firebase deploy --only functions --project checkmate-373101 + npm run deploy -- --project checkmate-373101 else - firebase deploy --only functions --project checkmate-uat + npm run deploy -- --project checkmate-uat fi working-directory: functions From c6c579119984054e2f97b62d70c970a125486d82 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 13:15:01 +0800 Subject: [PATCH 33/36] got rid of unnecessary lines --- functions/src/definitions/eventHandlers/onInstanceCreate.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/src/definitions/eventHandlers/onInstanceCreate.ts b/functions/src/definitions/eventHandlers/onInstanceCreate.ts index 59d80a25..0832a8f9 100644 --- a/functions/src/definitions/eventHandlers/onInstanceCreate.ts +++ b/functions/src/definitions/eventHandlers/onInstanceCreate.ts @@ -9,12 +9,8 @@ import { CollectionTypes, } from "../common/typesense/collectionOperations" import { FieldValue } from "@google-cloud/firestore" -import { defineInt } from "firebase-functions/params" import { Timestamp } from "firebase-admin/firestore" -// Define some parameters -const numInstanceShards = defineInt("NUM_SHARDS_INSTANCE_COUNT") - interface MessageUpdate { [x: string]: any } From 123b872f0fb44618e7e77c4b142e5bb1596dc425 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 13:15:11 +0800 Subject: [PATCH 34/36] removed asterisks and other cn copy changes --- .../common/parameters/userResponses.json | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 24622bb5..6850da4c 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -1,15 +1,15 @@ { "UNTRUE": { "en": "{{thanks}}{{matched}}{{methodology}}*untrue*.❌{{image_caveat}}\n\nPlease do not spread it further⛔️⛔️\n\nThank you for keeping Singapore informed!", - "cn": "{thanks}}{{matched}}{{methodology}}*不属实*。❌{{image_caveat}}\n\n请不要转发⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n" + "cn": "{thanks}}{{matched}}{{methodology}}不属实。❌{{image_caveat}}\n\n请不要转发⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n" }, "MISLEADING": { "en": "{{thanks}}{{matched}}{{methodology}}*presented in a misleading or unbalanced way*, even though some elements within could be true!⚠️{{image_caveat}}\n\nPlease take it with a pinch of salt and think twice before spreading it further🚧🚧.\n\nThank you for keeping Singapore informed!", - "cn": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但它*存在误导性或缺乏公正性*。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但它存在误导性或缺乏公正性。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!" }, "ACCURATE": { "en": "{{thanks}}{{matched}}{{methodology}}*accurate*.✅{{image_caveat}}\n\nThank you for keeping Singapore informed!", - "cn": "{{thanks}}{{matched}}{{methodology}}*是准确的*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}是准确的。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" }, "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! 😔", @@ -21,11 +21,11 @@ }, "SCAM": { "en": "{{thanks}}{{matched}}{{methodology}}*a scam*!🚫{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", - "cn": "{{thanks}}{{matched}}{{methodology}}*是诈骗信息*! 🚫{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。" + "cn": "{{thanks}}{{matched}}{{methodology}}是诈骗信息! 🚫{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。" }, "ILLICIT": { "en": "{{thanks}}{{matched}}{{methodology}}*suspicious*!🚨{{image_caveat}}\n\nWe recommend you do not engage further⛔️⛔️\n\nCheckMate will report suspicious messages to ScamShield (https://scamshield.org.sg) on your behalf.\n\nTo avoid reporting this message, select \"Don't report this\" below.", - "cn": "{{thanks}}{{matched}}{{methodology}}**很可疑*!🚨{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。" + "cn": "{{thanks}}{{matched}}{{methodology}}很可疑!🚨{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。" }, "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!", @@ -33,11 +33,11 @@ }, "LEGITIMATE": { "en": "{{thanks}}{{matched}}{{methodology}}*from a legitimate source*.✅{{image_caveat}}\n\nThank you for keeping Singapore safe!", - "cn": "{{thanks}}{{matched}}{{methodology}}*的来源是可靠的*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}{{matched}}{{methodology}}的来源是可靠的。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!" }, "UNSURE": { "en": "{{thanks}}\n\nUnfortunately, our CheckMates are *unsure about this message*🤷🏻‍♂️🤷🏻‍♀️. Sorry, we're human too!😞\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.\n\nThank you for keeping Singapore safe!", - "cn": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信*无法得出结论*🤷🏻‍♂️🤷🏻‍♀️。对不起,我们尽力了!😞\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。\n\n感谢您对新加坡网络安全的支持和贡献!" + "cn": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信无法得出结论🤷🏻‍♂️🤷🏻‍♀️。对不起,我们尽力了!😞\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。\n\n感谢您对新加坡网络安全的支持和贡献!" }, "THANKS_IMMEDIATE": { "en": "Thanks for sending this in!", @@ -69,15 +69,15 @@ }, "STATS_TEMPLATE_1": { "en": "{{top}}% of our CheckMates felt this was *{{category}}*{{info_placeholder}}.", - "cn": "{{top}}%的查哥查妹认为这条短信*{{category}}*{{info_placeholder}}。" + "cn": "{{top}}%的查哥查妹认为这条短信{{category}}{{info_placeholder}}。" }, "STATS_TEMPLATE_2": { "en": " {{second}}% felt this was *{{category}}*{{info_placeholder}}.", - "cn": "另外{{second}}%的人认为这条短信*{{category}}*{{info_placeholder}}。" + "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}}" + "cn": "目前,{{%voted}}%的查哥查妹已经对这条短信进行投票评估。大多数人认为这条短信{{prelim_assessment}}{{info_placeholder}}。\n\n注意:这只是初步结果。我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。{{get_feedback}}" }, "INFO_PLACEHOLDER": { "en": ", with an average score of {{score}} on a scale of 0-5 (5 = completely true)", @@ -93,7 +93,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在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼" }, "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.", @@ -113,7 +113,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😊.", @@ -124,8 +124,8 @@ "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。" }, "LANGUAGE_SELECTION": { - "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", - "cn": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。" + "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。", + "cn": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。" }, "IRRELEVANT_MENU_PREFIX": { "en": "Thanks for waiting!🙏🏻 Our CheckMates didn't find anything to assess in this message.😕", @@ -185,7 +185,7 @@ }, "SATISFACTION_SURVEY": { "en": "Thanks so much for using CheckMate🙏. We're improving the product from time to time, and your feedback is valuable to us.\n\nOn a scale from 1-10, how likely are you to recommend us to a friend, colleague or family member?", - "cn": "非常感谢您使用查友🙏。您的反馈对我们非常重要,也会帮我们改进。\n\n请问在1-10之间,您愿意向朋友、同事或家人推荐查友吗?" + "cn": "非常感谢您使用查友🙏。您的反馈对于不断改进查友非常重要。\n\n请问在1-10之间,您愿意向朋友、同事或家人推荐查友吗?" }, "SATISFACTION_SURVEY_THANKS": { "en": "Thanks for your feedback!", @@ -193,7 +193,7 @@ }, "HOWD_WE_TELL": { "en": "*This is an experimental feature powered by generative AI*. Do let us know if it was useful below!\n \n{{rationalisation}}", - "cn": "*这是一项由AI技术提供的实验性功能。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}" + "cn": "这是一项由AI技术提供的实验性功能。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}" }, "RATIONALISATION_USEFUL": { "en": "Thanks for your valuable feedback!", @@ -237,7 +237,7 @@ }, "MENU_DESCRIPTION_ABOUT": { "en": "Learn more about CheckMate and the team behind it", - "cn": "了解更多关于查友及幕后团队的短信" + "cn": "了解查友及幕后团队" }, "MENU_TITLE_FEEDBACK": { "en": "Send Feedback", @@ -245,7 +245,7 @@ }, "MENU_DESCRIPTION_FEEDBACK": { "en": "Send us feedback on anything to do with CheckMate", - "cn": "给予有关查友的任何反馈" + "cn": "给予有关查友的反馈" }, "MENU_TITLE_CONTACT": { "en": "Get Contact", @@ -355,4 +355,4 @@ "en": "too difficult to assess", "cn": "很难做评估" } -} \ No newline at end of file +} From c0fd8c692df1e9b969bb6cb0cba40355430719b5 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 4 Nov 2023 14:07:45 +0800 Subject: [PATCH 35/36] dont show rationalisation button if chinese. --- .../src/definitions/common/responseUtils.ts | 6 +- integration-tests/env.json | 122 +++++++++--------- 2 files changed, 66 insertions(+), 62 deletions(-) diff --git a/functions/src/definitions/common/responseUtils.ts b/functions/src/definitions/common/responseUtils.ts index 5adb1310..3aa18535 100644 --- a/functions/src/definitions/common/responseUtils.ts +++ b/functions/src/definitions/common/responseUtils.ts @@ -832,7 +832,11 @@ async function respondToInstance( const rationalisation = parentMessageSnap.get("rationalisation") if ((category === "scam" || category === "illicit") && rationalisation) { - buttons.push(viewRationalisationButton) + const language = + (await db.collection("users").doc(from).get()).get("language") ?? "en" + if (language === "en") { + buttons.push(viewRationalisationButton) + } } if (category === "scam" || category === "illicit") { diff --git a/integration-tests/env.json b/integration-tests/env.json index 02a08e76..091aa869 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -160,7 +160,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE.cn", - "value": "{thanks}}{{matched}}{{methodology}}*不属实*。❌{{image_caveat}}\n\n请不要再转发了⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n", + "value": "{thanks}}{{matched}}{{methodology}}不属实。❌{{image_caveat}}\n\n请不要转发⛔️⛔️\n\n感谢您对新加坡网络安全的支持和贡献!\n", "enabled": true }, { @@ -170,7 +170,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MISLEADING.cn", - "value": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但整体来看,它*具有误导性或展现不平衡的观点*。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!", + "value": "{{thanks}}{{matched}}{{methodology}}虽然包含一些真实的信息,但它存在误导性或缺乏公正性。⚠️{{image_caveat}}\n\n在分享之前,请三思🚧🚧。\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -180,7 +180,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ACCURATE.cn", - "value": "{{thanks}}{{matched}}{{methodology}}*是准确的*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!", + "value": "{{thanks}}{{matched}}{{methodology}}是准确的。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -190,7 +190,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 }, { @@ -200,7 +200,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED.cn", - "value": "你好!👋 感谢您的提交!我们的查哥查妹🕵🏻将尽快审查这条短信并回复。", + "value": "你好!👋 感谢您使用查友!我们的查哥查妹🕵🏻会尽快评估这条短信并回复。", "enabled": true }, { @@ -210,7 +210,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAM.cn", - "value": "{{thanks}}{{matched}}{{methodology}}*是一种诈骗*!🚫{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告此诈骗。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。", + "value": "{{thanks}}{{matched}}{{methodology}}是诈骗信息! 🚫{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。", "enabled": true }, { @@ -220,7 +220,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ILLICIT.cn", - "value": "{{thanks}}{{matched}}{{methodology}}**很可疑*!🚨{{image_caveat}}\n\n我们建议您不要再进行任何交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 报告这条可疑的短信。\n\n如果您不想报告此短信,请选择\"不报告此短信\"。", + "value": "{{thanks}}{{matched}}{{methodology}}很可疑!🚨{{image_caveat}}\n\n建议您停止交流⛔️⛔️\n\n查友会代表您向ScamShield (https://scamshield.org.sg) 举报这条可疑的短信。\n\n如果您不想举报此短信,请选择\"不举报\"。", "enabled": true }, { @@ -230,7 +230,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 }, { @@ -240,7 +240,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEGITIMATE.cn", - "value": "{{thanks}}{{matched}}{{methodology}}*来自可靠的来源*。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!", + "value": "{{thanks}}{{matched}}{{methodology}}的来源是可靠的。✅{{image_caveat}}\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -250,7 +250,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSURE.cn", - "value": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信*无法做出评估*🤷🏻‍♂️🤷🏻‍♀️。对不起,毕竟我们也只是普通人!😞\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。\n\n感谢您对新加坡网络安全的支持和贡献!", + "value": "{{thanks}}\n\n抱歉,我们的查哥查妹对这条短信无法得出结论🤷🏻‍♂️🤷🏻‍♀️。对不起,我们尽力了!😞\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。\n\n感谢您对新加坡网络安全的支持和贡献!", "enabled": true }, { @@ -280,7 +280,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN.cn", - "value": "我们的查哥查妹审查了这条短信后,认为它", + "value": "经过查哥查妹的评估,我们认为这条短信", "enabled": true }, { @@ -290,7 +290,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO.cn", - "value": "根据我们采用的人工智能技术,我们确信这条短信", + "value": "根据我们的AI技术,我们认为这条短信", "enabled": true }, { @@ -300,7 +300,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MATCHED.cn", - "value": "其实查友已经收到了{{numberInstances}}条同样的短信。", + "value": "其实查友已收到{{numberInstances}}条同样的短信。", "enabled": true }, { @@ -310,7 +310,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.UNSUPPORTED_TYPE.cn", - "value": "对不起,查友目前不支持这种类型的短信。", + "value": "对不起,查友目前不支持这类短信。", "enabled": true }, { @@ -320,7 +320,7 @@ }, { "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小时内,为您提供最终的结果。{{get_feedback}}", "enabled": true }, { @@ -330,7 +330,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE.cn", - "value": "\n目前,我们的查哥查妹中{{%voted}}%的人已经投票评估了这条短信。不幸的是,他们要么没有一致意见,要么缺乏资料来评估这条短信。\n\n如果可能的话,请提供更多详细资料,例如发信人电话号码或截图。", + "value": "目前,{%voted}}%的查哥查妹已经对这条短信进行投票评估。不幸的是,他们无法达成一致,或缺乏足够的信息进行评估。\n\n如果您能提供更多信息,例如发信人电话号码或截图,将有助于我们更好地评估。", "enabled": true }, { @@ -340,7 +340,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK.cn", - "value": "感谢您对查友的信任!👋🏼 如果这个临时更新对您有帮助,我们会很感激如果您能点击下方的“有帮助”。否则,点击“没帮助”以继续等待最终结果。无论如何,随着更多投票的到来,您都可以继续请求更多更新。", + "value": "感谢您对查友的信任!👋🏼 如果这个初步结果对您有帮助,请点击“有帮助”。否则,请点击“没帮助”以继续等待最终结果。您可以在最终结果发布之前随时要求最新的初步结果。", "enabled": true }, { @@ -350,7 +350,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT.cn", - "value": "感谢您的耐心等待!我们目前仍在等待我们的查友志愿者网络的评估,只有在收到足够的投票后,我们才能提供可信的最终结果。\n\n您可以点击下面的按钮*获取初步结果的临时更新*。但是,请注意,初步结果和最终结果之间可能存在差异,*应谨慎解读初步结果*。我们感谢您的耐心,并希望尽快向您提供最终结果!💪🏼", + "value": "感谢您的耐心等待!查哥查妹正在对您提交的短信进行投票评估。我们将在足够多的查哥查妹票后,为您提供最终结果。\n\n在最终结果发布之前,您可以点击获取初步结果。请注意,初步结果和最终结果之间可能存在差异,应谨慎解读初步结果。我们感谢您的耐心,并希望尽快为您提供最终结果!💪🏼", "enabled": true }, { @@ -360,7 +360,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL.cn", - "value": "感谢您的反馈!我们会尽快提供最终结果,一旦我们的查哥查投票更多或者已经过去24小时自您发送短信。\n\n如果您希望在更多投票后再次更新,请点击下方按钮请求。", + "value": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。", "enabled": true }, { @@ -370,7 +370,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL.cn", - "value": "很遗憾听到这个消息,但还是要感谢您的宝贵反馈!我们的查哥查妹们投票更多或者自您发送短信后已过24小时时,我们会尽快向您提供最终结果。\n\n如果您希望在更多投票进来后再次更新,请点击下方的按钮进行请求。", + "value": "感谢您的反馈!我们将在更多的查哥查妹投票后,或在您提交短信的24小时内,尽快为您提供最终的结果。\n\n请点击下方按钮再次获取最新的初步结果。", "enabled": true }, { @@ -380,7 +380,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED.cn", - "value": "查友已经对这条短信给出了最终的回应。", + "value": "查友已经对这条短信做出最终回应。", "enabled": true }, { @@ -390,7 +390,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SCAMSHIELD_ON_DECLINE.cn", - "value": "没关系!我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,感谢您对新加坡网络安全的支持和贡献!\n!", + "value": "我们不会将您的短信发送给ScamShield。感谢您与我们分享这条短信,也感谢您对新加坡网络安全的支持和贡献。", "enabled": true }, { @@ -410,7 +410,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_MENU_PREFIX.cn", - "value": "感谢您的耐心等待!🙏🏻 我们的查哥查妹在这条短信中没有找到任何可以评估的内容。😕", + "value": "感谢您的耐心等待!🙏🏻 我们的查哥查妹没有在这条短信中找到可以评估的内容。😕", "enabled": true }, { @@ -420,7 +420,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX.cn", - "value": "嗯...这条短信似乎没有什么可以评估的内容。😕", + "value": "嗯...这条短信似乎没有可以评估的内容。😕", "enabled": true }, { @@ -430,7 +430,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX.cn", - "value": "你好!感谢你使用查友。🙏🏻", + "value": "您好!感谢您使用查友。🙏🏻", "enabled": true }, { @@ -440,7 +440,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 }, { @@ -450,7 +450,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO.cn", - "value": "请访问 https://youtube.com/shorts/gFeO_qFOchs?feature=share 查看查友的工作原理!\n\n完成了吗?您现在已经准备好使用查友了!让我们一起为打击诈骗和误导短信做出贡献!💪", + "value": "了解查友是如何运行的:https://youtube.com/shorts/gFeO_qFOchs?feature=share\n\n准备好了吗?您可以开始使用查友了!让我们一起为反击诈骗和虚假信息做出贡献!💪", "enabled": true }, { @@ -460,7 +460,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE.cn", - "value": "要了解更多关于查友的短信,您可以访问我们的网站 https://checkmate.sg", + "value": "若想了解有关查友的更多信息,您可以访问我们的网站 https://checkmate.sg", "enabled": true }, { @@ -470,7 +470,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK.cn", - "value": "您可以在 https://bit.ly/checkmate-feedback 提交反馈。请放心,我们会尽快阅读并处理!", + "value": "您可以在 https://bit.ly/checkmate-feedback 提供反馈。我们会尽快查看!", "enabled": true }, { @@ -500,7 +500,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL.cn", - "value": "您是否已经开始使用查友来检查和报告可疑的短信了?点击此链接并发送预加载的短信进行注册!{{link}}", + "value": "您是否已经开始使用查友?点击此链接进行注册!{{link}}", "enabled": true }, { @@ -510,7 +510,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX.cn", - "value": "欢迎使用查友!发送整条短信(包括代码)以开始使用,并将您的推荐人记入账户。代码:", + "value": "欢迎使用查友!请发送这条短信(包括推荐人代码)以开始使用。代码:", "enabled": true }, { @@ -520,7 +520,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_PREPOPULATED_PREFIX.cn", - "value": "欢迎使用查友!请将此整条短信(包括代码)发送给我们以开始使用。代码:", + "value": "欢迎使用查友!请发送这条短信(包括代码)以开始使用。代码:", "enabled": true }, { @@ -530,17 +530,17 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID.cn", - "value": "对不起,只有在您首次与查友互动时,推荐才会被记入账户。", + "value": "对不起,推荐人代码仅在您首次与查友互动时才有效。", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_ERROR.en", - "value": "Sorry, an error occured. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", + "value": "Sorry, an error occurred. 😔 We'll be looking into this! Meanwhile, you can try out other functions of the bot. Apologies!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.GENERIC_ERROR.cn", - "value": "对不起,出现了一个错误。😔 我们会尽快解决这个问题!同时,您可以尝试使用查友的其他功能。再次为此道歉!", + "value": "抱歉,查友出现了错误。😔 我们会尽快解决这个问题!您可以尝试使用查友的其他功能。我们再次为此道歉!", "enabled": true }, { @@ -550,7 +550,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY.cn", - "value": "非常感谢您使用查友🙏。您的反馈对我们非常重要,也会帮我们改进。\n\n请问在1-10的评分中,您有多大可能性向您的朋友、同事或家人推荐查友?", + "value": "非常感谢您使用查友🙏。您的反馈对于不断改进查友非常重要。\n\n请问在1-10之间,您愿意向朋友、同事或家人推荐查友吗?", "enabled": true }, { @@ -570,7 +570,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.HOWD_WE_TELL.cn", - "value": "*这是一项由生成式人工智能驱动的实验性功能*。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}", + "value": "这是一项由AI技术提供的实验性功能。请在下方告诉我们它是否对您有所帮助!\n\n{{rationalisation}}", "enabled": true }, { @@ -590,17 +590,17 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.RATIONALISATION_NOT_USEFUL.cn", - "value": "很遗憾得知此功能对您来说不是很有用。 我已将此消息传递给我们的产品团队,以便将来进一步增强此功能。感谢您的反馈!", + "value": "很遗憾此功能对您来说不是很有用。 查友已将您的反馈传递给我们的产品团队,以便进一步增强此功能。感谢您的反馈!", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.en", - "value": "\n\nThis assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", + "value": "This assessment refers to any claims made within the captions. If there are no claims/captions, it refers to the image itself.", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.IMAGE_CAVEAT.cn", - "value": "这个评估是根据标题中的任何声明。如果短信里没有文字标题,此评估是根据图片里的内容。", + "value": "我们的评估基于图片标题中的内容。如果您提交的短信里没有文字标题,我们对图片本身的内容进行了评估。", "enabled": true }, { @@ -610,7 +610,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_1.cn", - "value": "我们的查哥查妹中有{{top}}%的人认为这条短信*{{category}}*{{info_placeholder}}。", + "value": "{{top}}%的查哥查妹认为这条短信{{category}}{{info_placeholder}}。", "enabled": true }, { @@ -620,7 +620,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.INFO_PLACEHOLDER.cn", - "value": "在0-5的评分标准上,平均分数为{{score}}(5 = 完全正确)", + "value": "在0 - 5的评分内,平均投票分数为{{score}}(5 = 完全正确)", "enabled": true }, { @@ -640,7 +640,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_CHECK.cn", - "value": "提交消息、图片或截图进行检查!", + "value": "提交文字内容、图片或截图进行评估", "enabled": true }, { @@ -660,7 +660,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_REFERRAL.cn", - "value": "获取推荐链接以转发给亲戚好友加入查友", + "value": "获取加入查友的推荐链接以转发给好友", "enabled": true }, { @@ -700,7 +700,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_ABOUT.cn", - "value": "了解更多关于查友及其幕后团队的短信", + "value": "了解查友及幕后团队", "enabled": true }, { @@ -710,7 +710,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_FEEDBACK.cn", - "value": "给予反馈", + "value": "反馈", "enabled": true }, { @@ -720,7 +720,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_FEEDBACK.cn", - "value": "给予有关查友的任何反馈", + "value": "给予有关查友的反馈", "enabled": true }, { @@ -750,7 +750,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_TITLE_DISPUTE.cn", - "value": "争议判断", + "value": "提出异议", "enabled": true }, { @@ -760,7 +760,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_DISPUTE.cn", - "value": "对查友对此消息的评估提出异议", + "value": "对查友的评估提出异议", "enabled": true }, { @@ -780,7 +780,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.MENU_DESCRIPTION_NPS_UNLIKELY.cn", - "value": "休想😥", + "value": "不会😥", "enabled": true }, { @@ -820,7 +820,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_ANOTHER_UPDATE.cn", - "value": "再提供审查状态更新", + "value": "获取初步结果更新", "enabled": true }, { @@ -830,7 +830,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_GET_INTERIM.cn", - "value": "提供审查状态更新", + "value": "获取初步结果", "enabled": true }, { @@ -850,7 +850,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.BUTTON_DECLINE_REPORT.cn", - "value": "不要举报", + "value": "不举报", "enabled": true }, { @@ -870,7 +870,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SCAM.cn", - "value": "是一种诈骗🚫", + "value": "是诈骗信息🚫", "enabled": true }, { @@ -880,7 +880,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_SUSPICIOUS.cn", - "value": "具有非法性🚨", + "value": "包含非法内容🚨", "enabled": true }, { @@ -940,7 +940,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.PLACEHOLDER_IRRELEVANT.cn", - "value": "没有包含有意义的声明进行评估😕", + "value": "没有可以评估的内容😕", "enabled": true }, { @@ -960,7 +960,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 }, { @@ -970,7 +970,7 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.STATS_TEMPLATE_2.cn", - "value": "另外{{second}}%的人认为这条短信*{{category}}*{{info_placeholder}}。", + "value": "另外{{second}}%的人认为这条短信{{category}}{{info_placeholder}}。", "enabled": true }, { @@ -990,17 +990,17 @@ }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_PREFIX_CN.cn", - "value": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", + "value": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.en", - "value": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", + "value": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。", "enabled": true }, { "key": "__CONSTANTS__.USER_BOT_RESPONSES.LANGUAGE_SELECTION.cn", - "value": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}\n请选择语言。", + "value": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。", "enabled": true }, { From c8985622dd6dd7bd817a9b8f94cd3b92e2a0b03c Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sun, 5 Nov 2023 12:26:01 +0800 Subject: [PATCH 36/36] added \n to cn prefix --- functions/src/definitions/common/parameters/userResponses.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/definitions/common/parameters/userResponses.json b/functions/src/definitions/common/parameters/userResponses.json index 6850da4c..5134f414 100644 --- a/functions/src/definitions/common/parameters/userResponses.json +++ b/functions/src/definitions/common/parameters/userResponses.json @@ -121,7 +121,7 @@ }, "NEW_USER_PREFIX_CN": { "en": "您好,欢迎来到查友!我们很高兴您加入我们,一起对抗诈骗和误导信息😊。\n", - "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。" + "cn": "您好,欢迎使用查友!很高兴您加入我们,一起参与反击诈骗和虚假信息😊。\n" }, "LANGUAGE_SELECTION": { "en": "{{new_user_en}}\n\nPlease select your preferred language.\n\n{{new_user_cn}}请选择语言。",