diff --git a/documentation/businessFlow.md b/documentation/businessFlow.md index 29478d59..3353d714 100644 --- a/documentation/businessFlow.md +++ b/documentation/businessFlow.md @@ -1,3 +1,4 @@ +```mermaid sequenceDiagram autonumber participant Outside Chat @@ -33,4 +34,5 @@ sequenceDiagram System->> User Bot: Trigger reply with corresponding response User Bot->> Citizen: "The message has been assessed to be..." end - end \ No newline at end of file + end +``` diff --git a/documentation/conversationFlow.yml b/documentation/conversationFlow.md similarity index 98% rename from documentation/conversationFlow.yml rename to documentation/conversationFlow.md index 90767796..ae5c0bcf 100644 --- a/documentation/conversationFlow.yml +++ b/documentation/conversationFlow.md @@ -1,3 +1,4 @@ +```mermaid sequenceDiagram actor citizen @@ -8,7 +9,7 @@ actor checker citizen ->> user bot: {fake news} alt there is a match alt vote not completed - user bot ->> citizen: Hello! 👋 Thank you for sending this in! Our *CheckMates🕵🏻 will be reviewing this message* and *providing you with the results soon*. + user bot ->> citizen: Hello! 👋 Thank you for sending this in! Our *CheckMates🕵🏻 will be reviewing this message* and *providing you with the results soon*. else is a scam user bot ->> citizen: ⛔⛔ Thank you for waiting! Our CheckMates have reviewed the message and think this is likely to be a *scam*!🚫\n\nWe recommend you do not engage further⛔️\n\nThank you for keeping Singapore safe! else is suspicious @@ -44,4 +45,5 @@ else no match checker bot ->> checker: No problem! If you wish to come back and assess the message, you may do so by clicking the "yes" button. See you soon!😊 end -end \ No newline at end of file +end +``` diff --git a/documentation/dataSchema.md b/documentation/dataSchema.md index 62390e17..103b23cb 100644 --- a/documentation/dataSchema.md +++ b/documentation/dataSchema.md @@ -1,13 +1,16 @@ +```mermaid erDiagram message { string id PK "Assigned by Firestore" string machineCategory boolean isMachineCategorised - string text "Text. For text, shows the latest iteration" + string originalText "text as sent by user" + string text "pii-stripped text. For text, shows the latest iteration" string caption "Latest caption for image, if applicable" timestamp firstTimestamp "Timestamp of first instance" timestamp lastTimestamp "Timestamp of latest instance" + timestamp lastRefreshedTimestamp "Timestamp where details were last updated" boolean isPollStarted boolean isAssessed "Should message be considered assessed and ready for reply" timestamp assessedTimestamp @@ -21,7 +24,7 @@ erDiagram boolean isInfo boolean isIrrelevant "Should message be considered assessed and ready for reply" number truthScore - string primaryCategory either "scam", "illicit", "irrelevant", "spam", "legitimate", "misleading", "untrue", "accurate", "unsure", or "error" + string primaryCategory "either scam, illicit, irrelevant, spam, legitimate, misleading, untrue, accurate, unsure, or error" string customReply "Not used for now" number instanceCount collection instances @@ -115,3 +118,4 @@ erDiagram user ||--|{ instance: sends message ||--o{ voteRequest: triggers factChecker ||--o{ voteRequest: responds_to +``` diff --git a/documentation/detailedFlow.md b/documentation/detailedFlow.md index f4327939..7704b6e7 100644 --- a/documentation/detailedFlow.md +++ b/documentation/detailedFlow.md @@ -1,3 +1,4 @@ +```mermaid sequenceDiagram actor Citizen participant User Bot @@ -59,10 +60,10 @@ sequenceDiagram webhookHandler->>Firestore: Update vote request Firestore->> onVoteRequestUpdate: Trigger onVoteRequestUpdate->> Checker Bot: call API with interactive poll - Checker Bot->>Checker: "On a scale of 0-5, how true...?" + Checker Bot->>Checker: "On a scale of 0-5, how true...?" Checker->>Checker Bot: "" Checker Bot->>webhookHandler: Trigger - webhookHandler->>Firestore: Update vote request + webhookHandler->>Firestore: Update vote request end Firestore->> onVoteRequestUpdate: Trigger onVoteRequestUpdate->>onVoteRequestUpdate: Determine isScam, isIrrelevant, isAssessed @@ -79,4 +80,5 @@ sequenceDiagram end end end - end \ No newline at end of file + end +``` diff --git a/functions/.env.local.test b/functions/.env.local.test index c78dbc2f..10bcc26a 100644 --- a/functions/.env.local.test +++ b/functions/.env.local.test @@ -2,7 +2,7 @@ NUM_SHARDS_INSTANCE_COUNT=5 NUM_SHARDS_VOTE_COUNT=5 GRAPH_API_VERSION=v15.0 TEST_SERVER_URL=http://resultserver:12345 -ENVIRONMENT=DEV +ENVIRONMENT=SIT SPREADSHEET_ID=SPREADSHEET_ID WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID=WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID=WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID diff --git a/functions/package-lock.json b/functions/package-lock.json index 4f8f719b..6e7eeb12 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -18,6 +18,7 @@ "hashids": "^2.3.0", "image-hash": "^5.3.1", "libphonenumber-js": "^1.10.21", + "openai": "^4.10.0", "typesense": "^1.5.3" }, "devDependencies": { @@ -4246,6 +4247,15 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, + "node_modules/@types/node-fetch": { + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.5.tgz", + "integrity": "sha512-OZsUlr2nxvkqUFLSaY2ZbA+P1q22q+KrlxWOn/38RX+u5kTkYL2mTujEpzUhGkS+K/QCYp9oagfXG39XOzyySg==", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, "node_modules/@types/prettier": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", @@ -4606,6 +4616,17 @@ "node": ">= 6.0.0" } }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -4915,6 +4936,11 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "devOptional": true }, + "node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -5162,6 +5188,14 @@ "node": ">=10" } }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "engines": { + "node": "*" + } + }, "node_modules/ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -5348,6 +5382,14 @@ "node": ">= 8" } }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "engines": { + "node": "*" + } + }, "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -5449,6 +5491,15 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/digest-fetch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", + "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==", + "dependencies": { + "base-64": "^0.1.0", + "md5": "^2.3.0" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -6434,6 +6485,23 @@ "node": ">= 6" } }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, "node_modules/formidable": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", @@ -7043,6 +7111,14 @@ "node": ">=10.17.0" } }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -7172,6 +7248,11 @@ "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, "node_modules/is-core-module": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.0.tgz", @@ -8421,6 +8502,16 @@ "node": ">= 12" } }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", @@ -8574,6 +8665,24 @@ "node": ">= 0.6" } }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -8700,6 +8809,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/openai": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.10.0.tgz", + "integrity": "sha512-II4b5/7qzwYkqA9MSjgqdofCc798EW+dtF2h6qNaVLet+qO7FShAJTWnoyzb50J4ZH1rPxRFAsmDLIhY3PT6DQ==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7" + }, + "bin": { + "openai": "bin/cli" + } + }, "node_modules/optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -10357,6 +10484,14 @@ "makeerror": "1.0.12" } }, + "node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "engines": { + "node": ">= 14" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -13895,6 +14030,15 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, + "@types/node-fetch": { + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.5.tgz", + "integrity": "sha512-OZsUlr2nxvkqUFLSaY2ZbA+P1q22q+KrlxWOn/38RX+u5kTkYL2mTujEpzUhGkS+K/QCYp9oagfXG39XOzyySg==", + "requires": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, "@types/prettier": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", @@ -14147,6 +14291,14 @@ "debug": "4" } }, + "agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "requires": { + "humanize-ms": "^1.2.1" + } + }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -14387,6 +14539,11 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "devOptional": true }, + "base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -14558,6 +14715,11 @@ "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==" + }, "ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -14703,6 +14865,11 @@ "which": "^2.0.1" } }, + "crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==" + }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -14774,6 +14941,15 @@ "integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==", "dev": true }, + "digest-fetch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", + "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==", + "requires": { + "base-64": "^0.1.0", + "md5": "^2.3.0" + } + }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -15557,6 +15733,20 @@ "mime-types": "^2.1.12" } }, + "form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, + "formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "requires": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + } + }, "formidable": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", @@ -16011,6 +16201,14 @@ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true }, + "humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "requires": { + "ms": "^2.0.0" + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -16099,6 +16297,11 @@ "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, "is-core-module": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.0.tgz", @@ -17087,6 +17290,16 @@ "integrity": "sha512-yr8hSKa3Fv4D3jdZmtMMPghgVt6TWbk86WQaWhDloQjRSQhMMYCAro7jP7VDJrjjdV8pxVxMssXS8B8Y5DZ5aw==", "optional": true }, + "md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "requires": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", @@ -17198,6 +17411,11 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" + }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -17283,6 +17501,21 @@ "mimic-fn": "^2.1.0" } }, + "openai": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.10.0.tgz", + "integrity": "sha512-II4b5/7qzwYkqA9MSjgqdofCc798EW+dtF2h6qNaVLet+qO7FShAJTWnoyzb50J4ZH1rPxRFAsmDLIhY3PT6DQ==", + "requires": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7" + } + }, "optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -18491,6 +18724,11 @@ "makeerror": "1.0.12" } }, + "web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==" + }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/functions/package.json b/functions/package.json index b2e774ae..9af14e02 100644 --- a/functions/package.json +++ b/functions/package.json @@ -30,6 +30,7 @@ "hashids": "^2.3.0", "image-hash": "^5.3.1", "libphonenumber-js": "^1.10.21", + "openai": "^4.10.0", "typesense": "^1.5.3" }, "devDependencies": { diff --git a/functions/src/definitions/checkerHandlers.ts b/functions/src/definitions/checkerHandlers.ts index 82138576..837c7182 100644 --- a/functions/src/definitions/checkerHandlers.ts +++ b/functions/src/definitions/checkerHandlers.ts @@ -22,10 +22,11 @@ if (!admin.apps.length) { admin.initializeApp() } +const db = admin.firestore() + const checkerHandlerWhatsapp = async function (message: Message) { const from = message.from // extract the phone number from the webhook payload const type = message.type - const db = admin.firestore() let responses switch (type) { @@ -99,7 +100,6 @@ const checkerHandlerWhatsapp = async function (message: Message) { async function onSignUp(from: string, platform = "whatsapp") { const responses = await getResponsesObj("factChecker") - const db = admin.firestore() let res = await sendTextMessage( "factChecker", from, @@ -135,7 +135,6 @@ async function onMsgReplyReceipt( platform = "whatsapp" ) { const responses = await getResponsesObj("factChecker") - const db = admin.firestore() const factCheckerSnap = await db.collection("factCheckers").doc(from).get() if (factCheckerSnap.get("getNameMessageId") === messageId) { await factCheckerSnap.ref.update({ @@ -164,7 +163,6 @@ async function onFactCheckerYes( from: string, platform = "whatsapp" ) { - const db = admin.firestore() if (!voteRequestPath.includes("/")) { throw new Error("The voteRequestPath does not contain a forward slash (/).") } @@ -213,7 +211,7 @@ async function onFactCheckerYes( res = await sendTextMessage( "factChecker", from, - latestInstanceSnap.get("text"), + messageSnap.get("text"), null, platform ) @@ -430,7 +428,6 @@ async function onTextListReceipt( } async function onContinue(factCheckerId: string) { - const db = admin.firestore() await db.collection("factCheckers").doc(factCheckerId).update({ isActive: true, }) diff --git a/functions/src/definitions/common/constants.ts b/functions/src/definitions/common/constants.ts index ac1fe9e9..25c1e4cf 100644 --- a/functions/src/definitions/common/constants.ts +++ b/functions/src/definitions/common/constants.ts @@ -234,7 +234,7 @@ const thresholds = { falseUpperBound: 1.5, misleadingUpperBound: 3.5, sendInterimMinVotes: 1, - surveyLikelihood: env === "DEV" ? 1 : 0.25, + surveyLikelihood: env !== "PROD" ? 1 : 0.25, satisfactionSurveyCooldownDays: 30, } diff --git a/functions/src/definitions/common/genAI.ts b/functions/src/definitions/common/genAI.ts new file mode 100644 index 00000000..52e75ba5 --- /dev/null +++ b/functions/src/definitions/common/genAI.ts @@ -0,0 +1,70 @@ +import { callChatCompletion, ChatMessage, examples } from "./openai/openai" +import hyperparameters from "./openai/hyperparameters.json" +import * as functions from "firebase-functions" + +type redaction = { + text: string + replaceWith: string +} + +const env = process.env.ENVIRONMENT + +async function anonymiseMessage(message: string) { + if (env === "SIT") { + return message + } + let returnMessage = message.replace(/\u00a0/g, " ") + try { + const anonymisationHyperparameters = hyperparameters?.anonymisation + if (anonymisationHyperparameters) { + const model: string = anonymisationHyperparameters.model + const systemMessage: string = anonymisationHyperparameters?.prompt?.system + + const examples: examples[] = + anonymisationHyperparameters?.prompt?.examples + const userMessage: string = + anonymisationHyperparameters?.prompt?.user.replace( + "{{message}}", + message + ) + if (model && systemMessage && examples && userMessage) { + const response = await callChatCompletion( + model, + systemMessage, + examples, + userMessage + ) + if (response) { + try { + const responseObj = JSON.parse(response) + const redactions: redaction[] = responseObj.redacted + console.log(redactions) + redactions.forEach((redaction) => { + let regex = new RegExp(redaction.text, "g") + returnMessage = returnMessage.replace( + regex, + redaction.replaceWith + ) + }) + return returnMessage + } catch (e) { + functions.logger.error( + "OpenAI completion could not be parsed as JSON" + e + ) + return message + } + } + } else { + functions.logger.error( + "Anonymisation hyperparameters not configured correctly" + ) + return message + } + } + } catch (e) { + functions.logger.error("Anonymisation hyperparameters failed: " + e) + return message + } +} + +export { anonymiseMessage } diff --git a/functions/src/definitions/common/openai/hyperparameters.json b/functions/src/definitions/common/openai/hyperparameters.json new file mode 100644 index 00000000..37c3fc16 --- /dev/null +++ b/functions/src/definitions/common/openai/hyperparameters.json @@ -0,0 +1,23 @@ +{ + "anonymisation": { + "model": "gpt-4", + "prompt": { + "system": "Our company offers a service that allows our users to forward in text messages. We then review the messages and help them check whether the messages contain misinformation, scams, or other online harms. Unfortunately, our users occasionally forward in messages containing their own credit card numbers, transaction IDs, names, addresses, and other information that are of no value to our checkers in fact-checking, but could harm them if our checkers had malicious intent.\n\nGiven this context, I will send your messages, and your job is to redact information that\n\n1) Is not useful for checking the message, and\n2) Contain personal information that could harm the user, i.e. the recipient of the message. There is no need to redact the information of the sender or their organisations, as this is typically useful for checking their legitimacy.\n\nDo NOT redact URLs or phone numbers.\n\nYou will return a JSON string containing two fields, like so.\n\n{\n \"reasoning\": //string, containing your reason why you chose to, or not to, redact each field.\n \"redacted\": [ //list of objects, one for each redacted field, as shown below\n {\n \"text\": //the original text of the redacted field\n \"replaceWith: //the field to replace the original text with, which should be in angular brackets, e.g. or \n },\n ...one object for each redacted field\n ]\n}", + "examples": [ + { + "user": "Hi, reminder to collect your parcel SPXSG030423 at 1745 Ang Mo Kio Ave 10, S123456 Collect by: 2023-08-06 PIN: 191748 Name: Manny", + "assistant": "{\"reasoning\": \"The message appears to be a transaction notification, addressed to the user. The parcel number, address, PIN and name are likely that of the user, and are not meaningful in determining whether the message is from a legitimate source or not.\", \"redacted\": [{\"text\": \"SPXSG030423\", \"replaceWith\": \"\"}, {\"text\": \"1745 Ang Mo Kio Ave 10, S123456\", \"replaceWith\": \"
\"}, {\"text\": \"191748\", \"replaceWith\": \"\"}, {\"text\": \"MANNY\", \"replaceWith\": \"\"}]}" + }, + { + "user": "*Bitter Gourd (Karela)*\nDear Amanda,\n\nI am Wu You.\nPlease spread this message to all your near and dear ones.\nProfessor Chen Hui Ren from the Beijing Army General Hospital confirmed that, if everyone who gets this information and then distributes to at least 10 other people, at least one life could be saved.\n\nYou can read more here: https://yahoo.com/bittergourd-karela\n\nI have done my part.\nI hope, you will also do your part.\nThank you.\n\nBitter gourd *(Karela)* in hot water can help you. No matter how busy you are, you need to read this, and then spread to friends and others.", + "assistant": "{\"reasoning\": \"The message appears to be making a claim. The name Amanda looks to be the name of the user, who has received the message. This is not important to fact checking and may harm the user when divulged. Wu You is the name of the sender, and the message is claiming that Professor Chen Hui Ren has given medical advice. Such information is important when determining whether the message is true or not. Thus, these two names should not be redacted.\", \"redacted\": [{\"text\": \"Amanda\", \"replaceWith\": \"\"}]}" + }, + { + "user": "Drinking sea salt will give energy boosting effect", + "assistant": "{\"reasoning\": \"There is no personal information in this message, and thus there is nothing to redact\", \"redacted\": []}" + } + ], + "user": "{{message}}" + } + } +} diff --git a/functions/src/definitions/common/openai/openai.ts b/functions/src/definitions/common/openai/openai.ts new file mode 100644 index 00000000..61d9ebee --- /dev/null +++ b/functions/src/definitions/common/openai/openai.ts @@ -0,0 +1,45 @@ +import OpenAI from "openai" + +// Define the expected type for a chat message +type ChatMessage = { + role: "system" | "user" | "assistant" + content: string +} + +type examples = { + user: string + assistant: string +} + +async function callChatCompletion( + model: string, + systemMessage: string, + examples: examples[], + user: string, + temperature: number = 0 +): Promise { + const openai = new OpenAI({ + apiKey: process.env.OPENAI_API_KEY, + }) + + const messages: ChatMessage[] = [{ role: "system", content: systemMessage }] + examples.forEach((example) => { + messages.push({ + role: "user", + content: example.user, + }) + messages.push({ + role: "assistant", + content: example.assistant, + }) + }) + messages.push({ role: "user", content: user }) + const chatCompletion = await openai.chat.completions.create({ + messages: messages, + model: model, + temperature: temperature, + }) + return chatCompletion.choices[0].message.content +} + +export { callChatCompletion, ChatMessage, examples } diff --git a/functions/src/definitions/common/utils.ts b/functions/src/definitions/common/utils.ts index 3aa3778e..a042e75b 100644 --- a/functions/src/definitions/common/utils.ts +++ b/functions/src/definitions/common/utils.ts @@ -33,6 +33,13 @@ const checkUrl = function (urlString: string) { return url.protocol === "http:" || url.protocol === "https:" } +async function checkMessageId(messageId: string) { + const db = admin.firestore() + const messageRef = db.collection("messageIds").doc(messageId) + const messageSnap = await messageRef.get() + return messageSnap.exists +} + function stripPhone(originalStr: string, includePlaceholder = false) { const phoneNumbers = findPhoneNumbersInText(originalStr) let newStr = originalStr @@ -91,4 +98,5 @@ export { getThresholds, checkUrl, normalizeSpaces, + checkMessageId, } diff --git a/functions/src/definitions/onInstanceCreate.ts b/functions/src/definitions/onInstanceCreate.ts index 0f34848b..ec6cfb71 100644 --- a/functions/src/definitions/onInstanceCreate.ts +++ b/functions/src/definitions/onInstanceCreate.ts @@ -1,6 +1,6 @@ import * as admin from "firebase-admin" import * as functions from "firebase-functions" -import { getCount } from "./common/counters" +import { anonymiseMessage } from "./common/genAI" import { getThresholds } from "./common/utils" import { respondToInstance } from "./common/responseUtils" import { sendWhatsappTemplateMessage } from "./common/sendWhatsappMessage" @@ -15,6 +15,10 @@ import { Timestamp } from "firebase-admin/firestore" // Define some parameters const numInstanceShards = defineInt("NUM_SHARDS_INSTANCE_COUNT") +interface MessageUpdate { + [x: string]: any +} + if (!admin.apps.length) { admin.initializeApp() } @@ -48,22 +52,48 @@ const onInstanceCreate = functions .orderBy("timestamp", "desc") .get() const lastInstanceDocSnap = instancesQuerySnap.docs[0] - await parentMessageRef.update({ + const messageUpdateObj: MessageUpdate = { instanceCount: instancesQuerySnap.size, lastTimestamp: lastInstanceDocSnap.get("timestamp"), - }) - - await upsertUser(data.from, data.timestamp) + latestInstance: snap.ref, + } + const parentMessageSnap = await parentMessageRef.get() - if (data?.type === "text") { - parentMessageRef.update({ text: data.text, latestInstance: snap.ref }) - } else if (data?.type === "image") { - parentMessageRef.update({ - latestInstance: snap.ref, - caption: data.caption, - }) + try { + const lastRefreshedDate = parentMessageSnap + .get("lastRefreshedTimestamp") + .toDate() + const comparisonDate = new Date() + comparisonDate.setDate(comparisonDate.getDate() - 30) + //if lastRefreshedDate is more than 30 days ago + if (lastRefreshedDate < comparisonDate) { + messageUpdateObj.lastRefreshedTimestamp = + Timestamp.fromDate(comparisonDate) + if ( + data?.type === "text" && + data?.text != parentMessageSnap.get("originalText") + ) { + const strippedMessage = await anonymiseMessage(data.text) + messageUpdateObj.originalText = data.text + messageUpdateObj.text = strippedMessage + } else if (data?.type === "image") { + messageUpdateObj.caption = data.caption + // Don't anonymise image captions for now, since OCR may be inaccurate + // if (data?.text != parentMessageSnap.get("originalText")) { + // const strippedMessage = await anonymiseMessage(data.text) + // messageUpdateObj.originalText = data.text + // messageUpdateObj.text = strippedMessage + // } + } + } + } catch (e) { + functions.logger.error("Error refreshing message: ", e) } + await parentMessageRef.update(messageUpdateObj) + + await upsertUser(data.from, data.timestamp) + if (data?.embedding && data?.text) { const updateObj = { id: snap.ref.path.replace(/\//g, "_"), //typesense id can't seem to take / @@ -81,7 +111,6 @@ const onInstanceCreate = functions } } - const parentMessageSnap = await parentMessageRef.get() if (!data.isReplied) { await respondToInstance(snap, false, true) } diff --git a/functions/src/definitions/onInstanceUpdate.ts b/functions/src/definitions/onInstanceUpdate.ts index 705915aa..1e677f1a 100644 --- a/functions/src/definitions/onInstanceUpdate.ts +++ b/functions/src/definitions/onInstanceUpdate.ts @@ -15,7 +15,7 @@ const onInstanceUpdate = functions // Grab the current value of what was written to Firestore. const before = change.before.data() const after = change.after.data() - if (after.type === "text" && before.text !== after.text) { + if (after.type === "text" && before.originalText !== after.originalText) { const embedding = await getEmbedding(after.text) const updateDocument = { id: change.after.ref.path, diff --git a/functions/src/definitions/onMessageUpdate.ts b/functions/src/definitions/onMessageUpdate.ts index 7c087c6b..71277252 100644 --- a/functions/src/definitions/onMessageUpdate.ts +++ b/functions/src/definitions/onMessageUpdate.ts @@ -1,6 +1,7 @@ import * as functions from "firebase-functions" import { respondToInstance } from "./common/responseUtils" import { Timestamp } from "firebase-admin/firestore" +import {} from "./common/genAI" const onMessageUpdate = functions .region("asia-southeast1") @@ -12,6 +13,7 @@ const onMessageUpdate = functions const after = change.after const messageData = after.data() if (!before.data().isAssessed && messageData.isAssessed) { + //TODO: rationalisation here await after.ref.update({ assessedTimestamp: Timestamp.fromDate(new Date()), }) diff --git a/functions/src/definitions/userHandlers.ts b/functions/src/definitions/userHandlers.ts index 8d877ea2..da210c6f 100644 --- a/functions/src/definitions/userHandlers.ts +++ b/functions/src/definitions/userHandlers.ts @@ -1,7 +1,6 @@ import * as admin from "firebase-admin" import * as functions from "firebase-functions" import { onMessagePublished } from "firebase-functions/v2/pubsub" - import { Timestamp } from "firebase-admin/firestore" import { sendWhatsappTextMessage, @@ -9,7 +8,12 @@ import { sendWhatsappContactMessage, } from "./common/sendWhatsappMessage" import { sendDisputeNotification } from "./common/sendMessage" -import { sleep, hashMessage, normalizeSpaces } from "./common/utils" +import { + sleep, + hashMessage, + normalizeSpaces, + checkMessageId, +} from "./common/utils" import { getResponsesObj, sendMenuMessage, @@ -23,6 +27,7 @@ import { getHash, getSignedUrl, } from "./common/mediaUtils" +import { anonymiseMessage } from "./common/genAI" import { calculateSimilarity } from "./calculateSimilarity" import { performOCR } from "./common/machineLearningServer/operations" import { defineString } from "firebase-functions/params" @@ -44,6 +49,15 @@ const hashids = new Hashids(salt) const db = admin.firestore() const userHandlerWhatsapp = async function (message: Message) { + if (!message?.id) { + functions.logger.error("No message id") + return + } + if (await checkMessageId(message.id)) { + functions.logger.warn(`Message ${message.id} already exists`) + return + } + let from = message.from // extract the phone number from the webhook payload let type = message.type const responses = await getResponsesObj("user") @@ -161,7 +175,7 @@ const userHandlerWhatsapp = async function (message: Message) { step = await newTextInstanceHandler({ text: message.text.body, timestamp: messageTimestamp, - id: message.id || null, + id: message.id, from: from || null, isForwarded: message?.context?.forwarded || null, isFrequentlyForwarded: message?.context?.frequently_forwarded || null, @@ -173,7 +187,7 @@ const userHandlerWhatsapp = async function (message: Message) { step = await newImageInstanceHandler({ caption: message?.image?.caption || null, timestamp: messageTimestamp, - id: message.id || null, + id: message.id, mediaId: message?.image?.id || null, mimeType: message?.image?.mime_type || null, from: from || null, @@ -253,14 +267,15 @@ async function newTextInstanceHandler({ }: { text: string timestamp: Timestamp - id: string | null + id: string from: string | null isForwarded: boolean | null isFrequentlyForwarded: boolean | null isFirstTimeUser: boolean }) { let hasMatch = false - let messageRef + let messageRef: FirebaseFirestore.DocumentReference | null = null + let messageUpdateObj: Object | null = null const machineCategory = (await classifyText(text)) ?? "error" if (from && isFirstTimeUser && machineCategory.includes("irrelevant")) { await db.collection("users").doc(from).update({ @@ -286,7 +301,7 @@ async function newTextInstanceHandler({ let bestMatchingDocumentRef let bestMatchingText let similarityScore = 0 - let matchedParentMessageRef + let matchedParentMessageRef = null if ( similarity.ref && @@ -306,7 +321,9 @@ async function newTextInstanceHandler({ } if (!hasMatch) { - let writeResult = await db.collection("messages").add({ + const strippedMessage = await anonymiseMessage(text) + messageRef = db.collection("messages").doc() + messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: !!( machineCategory && @@ -314,11 +331,13 @@ async function newTextInstanceHandler({ machineCategory !== "unsure" && machineCategory !== "info" ), - text: text, //text + originalText: text, + text: strippedMessage, //text caption: null, latestInstance: null, firstTimestamp: timestamp, //timestamp of first instance (firestore timestamp data type) lastTimestamp: timestamp, //timestamp of latest instance (firestore timestamp data type) + lastRefreshedTimestamp: timestamp, isPollStarted: false, //boolean, whether or not polling has started isAssessed: !!( machineCategory && @@ -349,22 +368,24 @@ async function newTextInstanceHandler({ : null, customReply: null, //string instanceCount: 0, - }) - messageRef = writeResult + rationalisation: null, + } } else { messageRef = matchedParentMessageRef } if (!messageRef) { - throw new Error( + functions.logger.error( `No messageRef created or matched for whatsapp message with id ${id}` ) + return } - const _ = await messageRef.collection("instances").add({ + const instanceRef = messageRef.collection("instances").doc() + const instanceUpdateObj = { source: "whatsapp", id: id || null, //taken from webhook object, needed to reply timestamp: timestamp, //timestamp, taken from webhook object (firestore timestamp data type) type: "text", //message type, taken from webhook object. Can be 'audio', 'button', 'document', 'text', 'image', 'interactive', 'order', 'sticker', 'system', 'unknown', 'video'. - text: text, //text or caption, taken from webhook object + text: text, textHash: textHash ?? null, caption: null, captionHash: null, @@ -394,7 +415,15 @@ async function newTextInstanceHandler({ }, isSatisfactionSurveySent: null, satisfactionScore: null, - }) + } + await addInstanceToDb( + id, + hasMatch, + messageRef, + messageUpdateObj, + instanceRef, + instanceUpdateObj + ) return Promise.resolve(`text_machine_${machineCategory}`) } @@ -413,14 +442,15 @@ async function newImageInstanceHandler({ mediaId: string | null mimeType: string | null timestamp: Timestamp - id: string | null + id: string from: string | null isForwarded: boolean | null isFrequentlyForwarded: boolean | null isFirstTimeUser: boolean }) { let filename - let messageRef + let messageRef: FirebaseFirestore.DocumentReference | null = null + let messageUpdateObj: Object | null = null let hasMatch = false let matchType = "none" // will be set to either "similarity" or "image" or "none" let matchedInstanceSnap @@ -470,6 +500,7 @@ async function newImageInstanceHandler({ let sender = null let isConvo = null let extractedMessage = null + let strippedMessage = null let machineCategory = null if (!hasMatch || !matchedInstanceSnap) { const temporaryUrl = await getSignedUrl(filename) @@ -512,7 +543,7 @@ async function newImageInstanceHandler({ let bestMatchingDocumentRef let bestMatchingText let similarityScore = 0 - let matchedParentMessageRef + let matchedParentMessageRef = null let textHash = null if (ocrSuccess && isConvo && !!extractedMessage && !hasMatch) { @@ -547,18 +578,24 @@ async function newImageInstanceHandler({ } if (!hasMatch || (!matchedInstanceSnap && !matchedParentMessageRef)) { - let writeResult = await db.collection("messages").add({ + if (extractedMessage) { + strippedMessage = await anonymiseMessage(extractedMessage) + } + messageRef = db.collection("messages").doc() + messageUpdateObj = { machineCategory: machineCategory, //Can be "fake news" or "scam" isMachineCategorised: !!( machineCategory && machineCategory !== "unsure" && machineCategory !== "info" ), - text: extractedMessage ?? null, //text + originalText: extractedMessage ?? null, + text: strippedMessage ?? null, //text caption: caption ?? null, latestInstance: null, firstTimestamp: timestamp, //timestamp of first instance (firestore timestamp data type) lastTimestamp: timestamp, //timestamp of latest instance (firestore timestamp data type) + lastRefreshedTimestamp: timestamp, isPollStarted: false, //boolean, whether or not polling has started isAssessed: !!( machineCategory && @@ -587,8 +624,8 @@ async function newImageInstanceHandler({ : null, customReply: null, //string instanceCount: 0, - }) - messageRef = writeResult + rationalisation: null, + } } else { if (matchType === "image" && matchedInstanceSnap) { messageRef = matchedInstanceSnap.ref.parent.parent @@ -600,11 +637,13 @@ async function newImageInstanceHandler({ } } if (!messageRef) { - throw new Error( + functions.logger.error( `No messageRef created or matched for whatsapp message with id ${id}` ) + return } - const _ = await messageRef.collection("instances").add({ + const instanceRef = messageRef.collection("instances").doc() + const instanceUpdateObj = { source: "whatsapp", id: id || null, //taken from webhook object, needed to reply timestamp: timestamp, //timestamp, taken from webhook object (firestore timestamp data type) @@ -644,7 +683,15 @@ async function newImageInstanceHandler({ }, isSatisfactionSurveySent: null, satisfactionScore: null, - }) + } + await addInstanceToDb( + id, + hasMatch, + messageRef, + messageUpdateObj, + instanceRef, + instanceUpdateObj + ) return Promise.resolve("image") } @@ -792,6 +839,33 @@ async function onTextListReceipt(messageObj: Message, platform = "whatsapp") { return Promise.resolve(step) } +async function addInstanceToDb( + id: string, + hasMatch: boolean, + messageRef: FirebaseFirestore.DocumentReference | null, + messageUpdateObj: Object | null = null, + instanceRef: FirebaseFirestore.DocumentReference, + instanceUpdateObj: Object +) { + const messageIdRef = db.collection("messageIds").doc(id) + try { + await db.runTransaction(async (t) => { + const doc = await t.get(messageIdRef) + if (doc.exists) { + return + } + if (!hasMatch && !!messageRef && !!messageUpdateObj) { + t.set(messageRef, messageUpdateObj) + } + t.set(instanceRef, instanceUpdateObj) + t.set(messageIdRef, { instanceRef: instanceRef }) + }) + functions.logger.log(`Transaction success for messageId ${id}!`) + } catch (e) { + functions.logger.error(`Transaction failure for messageId ${id}!`, e) + } +} + async function createNewUser( userRef: admin.firestore.DocumentReference, messageTimestamp: Timestamp @@ -821,6 +895,7 @@ const onUserPublish = onMessagePublished( "TYPESENSE_TOKEN", "ML_SERVER_TOKEN", "TELEGRAM_REPORT_BOT_TOKEN", + "OPENAI_API_KEY", ], timeoutSeconds: 120, }, diff --git a/functions/src/definitions/webhookHandler.ts b/functions/src/definitions/webhookHandler.ts index 5b8c8751..95caf7b0 100644 --- a/functions/src/definitions/webhookHandler.ts +++ b/functions/src/definitions/webhookHandler.ts @@ -5,6 +5,7 @@ import { defineString } from "firebase-functions/params" import { handleSpecialCommands } from "./specialCommands" import { publishToTopic } from "./common/pubsub" import { onRequest } from "firebase-functions/v2/https" +import { checkMessageId } from "./common/utils" const runtimeEnvironment = defineString("ENVIRONMENT") const testUserPhoneNumberId = defineString( @@ -57,6 +58,18 @@ app.post("/whatsapp", async (req, res) => { //handle db commands await handleSpecialCommands(message) } else { + if (message?.id) { + //if message has been processed before, don't even put it in queue. + if (await checkMessageId(message.id)) { + functions.logger.warn(`message ${message.id} already processed`) + res.sendStatus(200) + return + } + } else { + functions.logger.error(`message ${message.id} has no id`) + res.sendStatus(200) + return + } if ( (type == "button" || type == "interactive" || type == "text") && phoneNumberId === checkerPhoneNumberId @@ -122,21 +135,6 @@ app.get("/whatsapp", (req, res) => { } }) -const webhookHandler = functions - .region("asia-southeast1") - .runWith({ - secrets: [ - "WHATSAPP_USER_BOT_PHONE_NUMBER_ID", - "WHATSAPP_CHECKERS_BOT_PHONE_NUMBER_ID", - "WHATSAPP_TOKEN", - "VERIFY_TOKEN", - "TYPESENSE_TOKEN", - "ML_SERVER_TOKEN", - "TELEGRAM_REPORT_BOT_TOKEN", - ], - }) - .https.onRequest(app) - const webhookHandlerV2 = onRequest( { secrets: [ @@ -148,4 +146,4 @@ const webhookHandlerV2 = onRequest( app ) -export { app, webhookHandlerV2, webhookHandler } +export { app, webhookHandlerV2 } diff --git a/functions/src/index.ts b/functions/src/index.ts index 7aa9888c..34ec40ec 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -7,7 +7,6 @@ export { onInstanceCreate } from "./definitions/onInstanceCreate" export { onInstanceDelete } from "./definitions/onInstanceDelete" export { onInstanceUpdate } from "./definitions/onInstanceUpdate" export { onMessageUpdate } from "./definitions/onMessageUpdate" -export { webhookHandler } from "./definitions/webhookHandler" export { webhookHandlerV2 } from "./definitions/webhookHandler" export { onVoteRequestUpdate } from "./definitions/onVoteRequestUpdate" export { healthcheck } from "./definitions/healthcheck" diff --git a/functions/tsconfig.json b/functions/tsconfig.json index 861e26d8..fce7aabb 100644 --- a/functions/tsconfig.json +++ b/functions/tsconfig.json @@ -8,7 +8,8 @@ "strict": true, "target": "es2017", "noErrorTruncation": true, - "esModuleInterop": true + "esModuleInterop": true, + "resolveJsonModule": true }, "include": ["src"], "exclude": ["./lib/**/*"], diff --git a/integration-tests/checkmate.postman_collection.json b/integration-tests/checkmate.postman_collection.json index 97c164ec..3a71fcf8 100644 --- a/integration-tests/checkmate.postman_collection.json +++ b/integration-tests/checkmate.postman_collection.json @@ -1,11186 +1,13299 @@ { - "info": { - "_postman_id": "103b9282-6f00-47a0-8170-35734cf20265", - "name": "checkmate", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "25230076" - }, - "item": [ - { - "name": "000_Healthcheck", - "item": [ - { - "name": "Healthcheck", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", - "host": ["{{FUNCTIONS_URL}}"], - "path": ["checkmate-373101", "asia-southeast1", "healthcheck"] - } - }, - "response": [] - } - ] - }, - { - "name": "001_Mock_Db", - "item": [ - { - "name": "Create mock firestore DB", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"Test User\"\r\n },\r\n \"wa_id\": \"88888888\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"88888888\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/mockdb\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get mock db collection IDs", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check number of collections /mockdb command creates in Firestore\", function () {\r", - " const jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData?.collectionIds?.length).to.eql(2);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "default" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents:listCollectionIds" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "002_Add_Checkers", - "item": [ - { - "name": "Checker 2 Onboarding", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_1 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_1,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"whatsapp\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 input name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_2 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const CHECKER_2_NAME = pm.variables.get(\"CHECKER_2_NAME\");\r", - " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_2_NAME);\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_2\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"privacyOk\",\r", - " \"title\": \"Got it!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 press \"Got it!\" button", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"privacyOk\",\r\n \"title\": \"Got it!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_3 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_3 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3\")\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_3\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"typeformDone\",\r", - " \"title\": \"I've done the quiz!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 2 press \"Ive done the quiz!\" button", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"typeformDone\",\r\n \"title\": \"I've done the quiz!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_4 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", - " const ONBOARDING_4 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4\")\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_4,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": CHECKER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 3 Onboarding", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_1 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", - " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ONBOARDING_1,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_3_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"whatsapp\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Checker 3 input name", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Check Onboarding_2 Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", - " const CHECKER_3_NAME = pm.variables.get(\"CHECKER_3_NAME\");\r", - " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_3_NAME);\r", - "\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_3_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": ONBOARDING_2\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"privacyOk\",\r", - " \"title\": \"Got it!\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "003_New_User", - "item": [ - { - "name": "Send WhatsApp message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"F\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that has is created\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralId = jsonData.fields.referralId.stringValue\r", - " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", - " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", - " pm.expect(referralId.length).to.be.above(0);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "004_Irrelevant_Message", - "item": [ - { - "name": "Send WhatsApp message (7 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"1234567\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (IRRELEVANT_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message auto-categorised as irrelevant returns correct menu\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\",\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_dispute_messages/*/instances/*\",\r", - " \"title\": \"Dispute Assessment\",\r", - " \"description\": \"Dispute CheckMate's assesment of this message\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " // get the id of \"Dispute Assessment\" for validation\r", - " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", - " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", - " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", - "\r", - " // remove the id of \"Dispute Assessment\" for comparison\r", - " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", - " if (row.title === \"Dispute Assessment\") {\r", - " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", - " } else {\r", - " return row;\r", - " }\r", - " });\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 5000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Dispute Categorisation\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (telegram blast)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"On dispute, message is sent out to Telegram group chat\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const DISPUTED_INSTANCE_PATH = pm.collectionVariables.get(\"disputedInstancePath\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/botTELEGRAM_REPORT_BOT_TOKEN/sendMessage\",\r", - " \"body\": {\r", - " \"chat_id\": \"111111111\",\r", - " \"text\": `${USER_1_NUMBER} has disputed the assessment of a message sent by them.\\n \\nmessage/instance path: ${DISPUTED_INSTANCE_PATH}\\n\\ntype: text\\n\\ntext: 1234567\\n\\ncategory: irrelevant`\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get last message (DISPUTE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005_Spam_Human", - "item": [ - { - "name": "005a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a sp-am message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", - " pm.collectionVariables.set(`spamMessageId`, messageId);\r", - " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005b_Interim_Message", - "item": [ - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"spamInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{spamMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button \"No it's not\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_NOT_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_NOT_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update again", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005c_2nd Voter Legitimate", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"legitimate\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005d_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is a sp-am message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SPAM", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SPAM final reply sent to checker 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SPAM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const spamResponse = getFinalResponseText(SPAM)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": spamResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"spamInstanceId\")\r", - " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": SATISFACTION_SURVEY\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Tap to respond\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"10\",\r", - " \"description\": \"Extremely likely 🤩\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"9\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"8\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"7\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"6\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"5\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"4\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"3\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"2\"\r", - " },\r", - " {\r", - " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"1\",\r", - " \"description\": \"Not at all likely 😥\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Votes 10", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "SATISFACTION_SURVEY_THANKS", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const SATISFACTION_SURVEY_THANKS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": SATISFACTION_SURVEY_THANKS,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check instance updated", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const isSatisfactionSurveySent = jsonData.fields.isSatisfactionSurveySent.booleanValue\r", - " const satisfactionScore = parseInt(jsonData.fields.satisfactionScore.integerValue) //for some reason integerValue returns string\r", - "\r", - " pm.expect(isSatisfactionSurveySent).to.be.true;\r", - " pm.expect(satisfactionScore).to.equal(10);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{spamMessageId}}", - "instances", - "{{spamInstanceId}}" - ] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "ALREADY_REPLIED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const ALREADY_REPLIED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": ALREADY_REPLIED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "005e_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"66.67% of our CheckMates thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "006_Info_Machine_Human", - "item": [ - { - "name": "006a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoMessageId`, messageId);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", - " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"1\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER1}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"infoInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{infoMessageId}}", - "instances", - "{{infoInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "006b_2nd_Voter_1", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"1\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER2}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "UNTRUE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"UNTRUE final reply sent to checker 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"infoInstanceId\")\r", - " const UNTRUE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNTRUE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006c_3rd_Voter_5", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an info message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"5\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER3}}_5\",\r\n \"title\": \"5\",\r\n \"description\": \"Totally true\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "006d_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "007_Unsure_Human", - "item": [ - { - "name": "007a_User_Send_First_Vote", - "item": [ - { - "name": "Send WhatsApp message (15 Chars)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get first checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureMessageId`, messageId);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get second checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get third checker message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", - " const CHECKER_NAME = \"CHECKER_NAME\"\r", - " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBER,\r", - " \"type\": \"template\",\r", - " \"template\": {\r", - " \"name\": \"new_message_received\",\r", - " \"language\": {\r", - " \"policy\": \"deterministic\",\r", - " \"code\": \"en\"\r", - " },\r", - " \"components\": [\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 0,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"button\",\r", - " \"sub_type\": \"quick_reply\",\r", - " \"index\": 1,\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"payload\",\r", - " \"payload\": HARD_CODED_ID\r", - " }\r", - " ]\r", - " },\r", - " {\r", - " \"type\": \"body\",\r", - " \"parameters\": [\r", - " {\r", - " \"type\": \"text\",\r", - " \"text\": CHECKER_NAME\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"factChecker\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " //check name in list\r", - " const name = jsonData.body.template.components[2].parameters[0].text\r", - " pm.expect(CHECKER_NAMES).to.include(name);\r", - " //check number in list\r", - " const number = jsonData.body.to\r", - " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", - " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", - " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", - " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", - " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", - " // Replace dynamically created IDs\r", - " jsonData.body.to = CHECKER_PHONE_NUMBER\r", - " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", - " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "First checker selects \"unsure\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_unsure\",\r\n \"title\": \"I'm Unsure\",\r\n \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007b_Interim_Message", - "item": [ - { - "name": "Send /interim command", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Get Instance ID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that there is 1 instance\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.documents?.length).to.eql(1);\r", - " var fullName = jsonData.documents[0].name;\r", - " var splitName = fullName.split(\"/\");\r", - " var docId = splitName[splitName.length - 1];\r", - " pm.collectionVariables.set(\"unsureInstanceId\", docId);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get interim update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007c_1st Voter Change To Legitimate", - "item": [ - { - "name": "First checker selects \"legitimate\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[0],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", - " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", - " \"title\": \"Yes, it's useful\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", - " \"title\": \"No, it's not\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - }, - { - "name": "Press button \"Yes it's useful\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_USEFUL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": INTERIM_USEFUL\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check interim values", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", - " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "messages", - "{{unsureMessageId}}", - "instances", - "{{unsureInstanceId}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "007d_2nd Voter Info \"3\"", - "item": [ - { - "name": "Second checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"info\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_info\",\r\n \"title\": \"News/Information/Opinion\",\r\n \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_NEXT_POLL", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_NEXT_POLL message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const HOLD_FOR_NEXT_POLL = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_NEXT_POLL,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "FACTCHECK_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", - " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": FACTCHECK_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Vote here\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", - " \"title\": \"0\",\r", - " \"description\": \"Totally false\"\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", - " \"title\": \"1\",\r", - " }, \r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", - " \"title\": \"2\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", - " \"title\": \"3\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", - " \"title\": \"4\",\r", - " },\r", - " {\r", - " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", - " \"title\": \"5\",\r", - " \"description\": \"Totally true\"\r", - " },\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Second checker selects \"3\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_3\",\r\n \"title\": \"3\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[1],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Press button to get interim update", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "INTERIM_TEMPLATE_UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": interimResponse\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"Get another update\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " \r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007e_3rd Voter Spam", - "item": [ - { - "name": "Third checker clicks yes", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Message to Check Sent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Message to check sent to checker 2\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"This is an unsure message that will be voted on\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\"\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L1_ASSESSMENT_PROMPT", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L1_ASSESSMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", - " \"title\": \"Scam\",\r", - " \"description\": \"Intended to obtain money/personal information via deception\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", - " \"title\": \"Illicit\",\r", - " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", - " \"title\": \"News/Information/Opinion\",\r", - " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", - " },\r", - " {\r", - " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", - " \"title\": \"It's something else\",\r", - " \"description\": \"Messages that don't fall into the other categories\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " //console.log(JSON.stringify(expected,null,2))\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"It's something else\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "HOLD_FOR_L2_CATEGORISATION", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "L2_CATEGORISATION_MENU", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"Make Selection\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", - " \"title\": \"Spam\",\r", - " \"description\": \"Unsolicited spam, such as marketing messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", - " \"title\": \"Legitimate\",\r", - " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", - " \"title\": \"Trivial\",\r", - " \"description\": \"Trivial/banal messages with nothing to assess\"\r", - " },\r", - " {\r", - " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", - " \"title\": \"I'm Unsure\",\r", - " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Third checker selects \"spam\"", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "RESPONSE_RECORDED", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RESPONSE_RECORDED sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": RESPONSE_RECORDED,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 6000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "NO_OUTSTANDING", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"NO_OUTSTANDING sent to checker 3\", function () {\r", - " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", - " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", - " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": NO_OUTSTANDING,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": CHECKER_PHONE_NUMBERS[2],\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "UNSURE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"UNSURE final reply sent to user 1\", function () {\r", - " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", - " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", - " const UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNSURE\");\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", - " const isMachineCategorised = false\r", - " const instanceCount = 1\r", - " const isImmediate = false\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " function getFinalResponseText(responseText) {\r", - " return responseText\r", - " .replace(\r", - " \"{{thanks}}\",\r", - " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", - " )\r", - " .replace(\r", - " \"{{matched}}\",\r", - " instanceCount >= 5\r", - " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", - " : \"\"\r", - " )\r", - " .replace(\r", - " \"{{methodology}}\",\r", - " isMachineCategorised\r", - " ? METHODOLOGY_AUTO\r", - " : METHODOLOGY_HUMAN\r", - " )\r", - " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", - " }\r", - " const response = getFinalResponseText(UNSURE)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": response\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", - " \"title\": \"See voting results\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "007f_Stats_Message", - "item": [ - { - "name": "Press button to see stats", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "STATS_TEMPLATE", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " //we not using the template for this, its hardcoded.\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": \"33.33% of our CheckMates thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ] - }, - { - "name": "008_Menu_Message", - "item": [ - { - "name": "Send WhatApp message (\"Menu\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (GENERIC_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Check/Report\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (PROCEED_TO_SEND)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Help\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_help\",\r\n \"title\": \"Get Help\",\r\n \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (HOW_TO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"About CheckMate\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_about\",\r\n \"title\": \"About CheckMate\",\r\n \"description\": \"Learn more about CheckMate and the team behind it\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (LEARN_MORE)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Send Feedback\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_feedback\",\r\n \"title\": \"Send Feedback\",\r\n \"description\": \"Send us feedback on anything to do with CheckMate\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (FEEDBACK)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Get Contact\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (contact type)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"contacts\",\r", - " \"contacts\": [\r", - " {\r", - " \"name\": {\r", - " \"formatted_name\": \"CheckMate\",\r", - " \"suffix\": \"CheckMate\"\r", - " },\r", - " \"urls\": [\r", - " {\r", - " \"url\": \"https://checkmate.sg\"\r", - " }\r", - " ],\r", - " \"phones\": [\r", - " {\r", - " \"phone\": \"+1 555-093-3685\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Get last message (CONTACT)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.CONTACT\");\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "Make Menu Selection (\"Referral\")", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_referral\",\r\n \"title\": \"Get Referral Link\",\r\n \"description\": \"Get referral link to forward to others\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (REFERRAL)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL\");\r", - " const link = pm.variables.get(\"referralLink_USER1\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const referralMessage = BODY_TEXT.replace(\"{{link}}\", link)\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": referralMessage,\r", - " \"preview_url\": true\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "009_Scam_Autocategorise", - "item": [ - { - "name": "User sends scam message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "// Allow time for firestore onUpdate event to complete\r", - "setTimeout(() => {}, 1000);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a scam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SCAM, IMMEDIATE, NOT MATCHED, AUTO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"scam immediate autocategorised no matched response\", function () {\r", - " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SCAM\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_1_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"button\",\r", - " \"body\": {\r", - " \"text\": BODY_TEXT\r", - " },\r", - " \"action\": {\r", - " \"buttons\": [\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"Yes\"\r", - " }\r", - " },\r", - " {\r", - " \"type\": \"reply\",\r", - " \"reply\": {\r", - " \"id\": \"ID\",\r", - " \"title\": \"No\"\r", - " }\r", - " }\r", - " ]\r", - " }\r", - " },\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - " }\r", - "\r", - " var jsonData = pm.response.json();\r", - "\r", - " let reply_id_yes = jsonData.body.interactive.action.buttons[0].reply.id;\r", - " let reply_id_no = jsonData.body.interactive.action.buttons[1].reply.id;\r", - " let [, scamInstancePath , ] = reply_id_yes.split(\"_\")\r", - " \r", - " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", - " pm.expect(reply_id_yes).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_consent/);\r", - " pm.expect(reply_id_no).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_decline/);\r", - " pm.collectionVariables.set(\"scamInstancePath\", scamInstancePath);\r", - "\r", - " jsonData.body.interactive.action.buttons[0].reply.id = \"ID\"\r", - " jsonData.body.interactive.action.buttons[1].reply.id = \"ID\"\r", - "\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "010_Spam_Autocategorise", - "item": [ - { - "name": "User sends spam message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [""], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a spam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (SPAM, IMMEDIATE, NOT MATCHED, AUTO)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"spam immediate autocategorised no matched response\", function () {\r", - " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", - " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", - " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", - " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", - " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", - " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", - " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", - " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", - " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_1_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": ["setTimeout(() => {}, 2000);"], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - }, - { - "name": "011_Check_Steps_logging", - "item": [ - { - "name": "[DB CALL] Check steps", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that instance data updated correctly\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", - " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", - " const expected = [\r", - " \"text_machine_irrelevant_length\",\r", - " \"text_machine_irrelevant_length\",\r", - " \"menu_dispute\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"feedbackInterim_no\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"satisfactionSurvey_10\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_info\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_machine_unsure\",\r", - " \"sendInterim\",\r", - " \"sendInterim\",\r", - " \"feedbackInterim_yes\",\r", - " \"sendInterim\",\r", - " \"votingResults\",\r", - " \"text_menu\",\r", - " \"menu_check\",\r", - " \"menu_help\",\r", - " \"menu_about\",\r", - " \"menu_feedback\",\r", - " \"menu_contact\",\r", - " \"menu_referral\",\r", - " \"text_machine_scam\",\r", - " \"text_machine_spam\",\r", - " ]\r", - " pm.expect(actions).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "012_New_User_Referral", - "item": [ - { - "name": "Send WhatsApp message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (NEW_USER_MENU)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Your test name\", function () {\r", - " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", - " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", - " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"recipient_type\": \"individual\",\r", - " \"to\": USER_2_NUMBER,\r", - " \"type\": \"interactive\",\r", - " \"interactive\": {\r", - " \"type\": \"list\",\r", - " \"body\": {\r", - " \"text\": MENU_TEXT\r", - " },\r", - " \"action\": {\r", - " \"button\": \"View Menu\",\r", - " \"sections\": [\r", - " {\r", - " \"rows\": [\r", - " {\r", - " \"id\": \"menu_check\",\r", - " \"title\": \"Check/Report\",\r", - " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", - " },\r", - " {\r", - " \"id\": \"menu_referral\",\r", - " \"title\": \"Get Referral Link\",\r", - " \"description\": \"Get referral link to forward to others\"\r", - " },\r", - " {\r", - " \"id\": \"menu_help\",\r", - " \"title\": \"Get Help\",\r", - " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", - " },\r", - " {\r", - " \"id\": \"menu_about\",\r", - " \"title\": \"About CheckMate\",\r", - " \"description\": \"Learn more about CheckMate and the team behind it\"\r", - " },\r", - " {\r", - " \"id\": \"menu_feedback\",\r", - " \"title\": \"Send Feedback\",\r", - " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", - " },\r", - " {\r", - " \"id\": \"menu_contact\",\r", - " \"title\": \"Get Contact\",\r", - " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", - " }\r", - " ]\r", - " }\r", - " ]\r", - " }\r", - " }\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - }, - { - "name": "[DB CALL] Check referral count", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Check that referral count is incremented to 1\", function () {\r", - "\r", - " var jsonData = pm.response.json();\r", - " const referralCount = jsonData.fields.referralCount.integerValue\r", - " pm.expect(parseInt(referralCount)).to.eql(1);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "Bearer owner", - "type": "text" - } - ], - "url": { - "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", - "host": ["{{FIRESTORE_URL}}"], - "path": [ - "v1", - "projects", - "checkmate-373101", - "databases", - "(default)", - "documents", - "users", - "{{USER_1_NUMBER}}" - ] - } - }, - "response": [] - }, - { - "name": "Send 2nd referral message", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", - "host": ["{{FUNCTIONS_URL}}"], - "path": [ - "checkmate-373101", - "asia-southeast1", - "webhookHandlerV2", - "whatsapp" - ] - } - }, - "response": [] - }, - { - "name": "Get last message (REFERRAL_INVALID)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"REFERRAL_INVALID response received\", function () {\r", - " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID\");\r", - " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", - " const expected = {\r", - " \"hostname\": \"resultserver\",\r", - " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", - " \"body\": {\r", - " \"text\": {\r", - " \"body\": BODY_TEXT,\r", - " \"preview_url\": false\r", - " },\r", - " \"to\": USER_2_NUMBER,\r", - " \"messaging_product\": \"whatsapp\",\r", - " \"context\": {\r", - " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", - " },\r", - " },\r", - " \"method\": \"POST\"\r", - "}\r", - " var jsonData = pm.response.json();\r", - " pm.expect(jsonData).to.eql(expected);\r", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{RESULT_SERVER_URL}}/testresultdata", - "host": ["{{RESULT_SERVER_URL}}"], - "path": ["testresultdata"] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [""] - } - } - ], - "variable": [ - { - "key": "disputedMessagePath", - "value": "" - }, - { - "key": "disputedMessageTextListId", - "value": "" - }, - { - "key": "disputedInstancePath", - "value": "" - }, - { - "key": "scamInstancePath", - "value": "" - }, - { - "key": "spamVoteRequestPath", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "spamVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "spamMessageId_CHECKER3", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "spamMessageId_CHECKER2", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "spamMessageId_CHECKER1", - "value": "" - }, - { - "key": "spamVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "spamMessageId", - "value": "" - }, - { - "key": "spamInstanceId", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "infoMessageId", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "infoVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "infoVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "infoInstanceId", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER3", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER3", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER2", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER2", - "value": "" - }, - { - "key": "unsureInstanceId", - "value": "" - }, - { - "key": "unsureVoteRequestPath_CHECKER1", - "value": "" - }, - { - "key": "unsureMessageId", - "value": "" - }, - { - "key": "unsureVoteRequestId_CHECKER1", - "value": "" - }, - { - "key": "user_1_referralId", - "value": "" - }, - { - "key": "referralLink_USER1", - "value": "" - }, - { - "key": "referralId_USER1", - "value": "" - } - ] -} + "info": { + "_postman_id": "5218f5ab-c512-43d1-b8a3-0831e12514c1", + "name": "checkmate", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "25230076" + }, + "item": [ + { + "name": "000_Healthcheck", + "item": [ + { + "name": "Healthcheck", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.collectionVariables.set(\"messageCounter\", 0);\r", + "\r", + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/healthcheck", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "healthcheck" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "001_Mock_Db", + "item": [ + { + "name": "Create mock firestore DB", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 1\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"Test User\"\r\n },\r\n \"wa_id\": \"88888888\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"88888888\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIDFCMDlDNjhFRDgzMEJCQjA0M0FBM0NEQTc5MEYzRkE4AA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/mockdb\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get mock db collection IDs", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check number of collections /mockdb command creates in Firestore\", function () {\r", + " const jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData?.collectionIds?.length).to.eql(2);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "default" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:listCollectionIds", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:listCollectionIds" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "002_Add_Checkers", + "item": [ + { + "name": "Checker 2 Onboarding", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 2\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_2}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_1 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_1,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"whatsapp\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 input name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 3\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"{{MOCK_WHATSAPP_MSG_ID}}\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_3}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_2 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const CHECKER_2_NAME = pm.variables.get(\"CHECKER_2_NAME\");\r", + " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_2_NAME);\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_2\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"privacyOk\",\r", + " \"title\": \"Got it!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 press \"Got it!\" button", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 4\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"{{MOCK_WHATSAPP_MSG_ID}}\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_4}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"privacyOk\",\r\n \"title\": \"Got it!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_3 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_3 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_3\")\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_3\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"typeformDone\",\r", + " \"title\": \"I've done the quiz!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 2 press \"Ive done the quiz!\" button", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 5\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_5}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"typeformDone\",\r\n \"title\": \"I've done the quiz!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_4 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_2_NUMBER = pm.variables.get(\"CHECKER_2_NUMBER\");\r", + " const ONBOARDING_4 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_4\")\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_4,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": CHECKER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 3 Onboarding", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 6\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_6}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"I'd like to join as a CheckMate to help counter misinformation and scams! 💪🏻\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_1 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", + " const ONBOARDING_1 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_1\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ONBOARDING_1,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_3_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"whatsapp\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Checker 3 input name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 7\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_7}}\",\r\n \"timestamp\": \"{{$timestamp}}\",\r\n \"text\": {\r\n \"body\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Check Onboarding_2 Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const CHECKER_3_NUMBER = pm.variables.get(\"CHECKER_3_NUMBER\");\r", + " const CHECKER_3_NAME = pm.variables.get(\"CHECKER_3_NAME\");\r", + " const ONBOARDING_2 = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.ONBOARDING_2\").replace(\"{{name}}\", CHECKER_3_NAME);\r", + "\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_3_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": ONBOARDING_2\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"privacyOk\",\r", + " \"title\": \"Got it!\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "003_New_User", + "item": [ + { + "name": "Send WhatsApp message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 8\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_8}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"F\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that has is created\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralId = jsonData.fields.referralId.stringValue\r", + " pm.collectionVariables.set(\"referralId_USER1\", referralId);\r", + " pm.collectionVariables.set(\"referralLink_USER1\", `https://ref.checkmate.sg/${referralId}`);\r", + " pm.expect(referralId.length).to.be.above(0);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "004_Irrelevant_Message", + "item": [ + { + "name": "Send WhatsApp message (7 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 9\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_9}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"1234567\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (IRRELEVANT_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message auto-categorised as irrelevant returns correct menu\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.IRRELEVANT_AUTO_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const wamid = pm.variables.get(\"whatsapp_id_9\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\",\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_dispute_messages/*/instances/*\",\r", + " \"title\": \"Dispute Assessment\",\r", + " \"description\": \"Dispute CheckMate's assesment of this message\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " // get the id of \"Dispute Assessment\" for validation\r", + " let disputeAssessmentId = jsonData.body.interactive.action.sections[0].rows.find(row => row.title === \"Dispute Assessment\").id;\r", + " let [, , disputedInstancePath] = disputeAssessmentId.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(disputeAssessmentId).to.match(/menu_dispute_messages\\/[^\\/]+\\/instances\\/[^\\/]+/);\r", + " pm.collectionVariables.set(\"disputedInstancePath\", disputedInstancePath);\r", + "\r", + " // remove the id of \"Dispute Assessment\" for comparison\r", + " jsonData.body.interactive.action.sections[0].rows = jsonData.body.interactive.action.sections[0].rows.map(row => {\r", + " if (row.title === \"Dispute Assessment\") {\r", + " return {...row, id: \"menu_dispute_messages/*/instances/*\"};\r", + " } else {\r", + " return row;\r", + " }\r", + " });\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Dispute Categorisation\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 10\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_10}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_dispute_{{disputedInstancePath}}\",\r\n \"title\": \"Dispute Assessment\",\r\n \"description\": \"Dispute CheckMate's assesment of this message\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (telegram blast)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"On dispute, message is sent out to Telegram group chat\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const DISPUTED_INSTANCE_PATH = pm.collectionVariables.get(\"disputedInstancePath\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/botTELEGRAM_REPORT_BOT_TOKEN/sendMessage\",\r", + " \"body\": {\r", + " \"chat_id\": \"111111111\",\r", + " \"text\": `${USER_1_NUMBER} has disputed the assessment of a message sent by them.\\n \\nmessage/instance path: ${DISPUTED_INSTANCE_PATH}\\n\\ntype: text\\n\\ntext: 1234567\\n\\ncategory: irrelevant`\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (DISPUTE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.DISPUTE\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005_Spam_Human", + "item": [ + { + "name": "005a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 11\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_11}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a sp-am message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const spamVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = spamVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`spamVoteRequestPath_${name}`, spamVoteRequestPath);\r", + " pm.collectionVariables.set(`spamMessageId`, messageId);\r", + " pm.collectionVariables.set(`spamVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 5000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER1}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005b_Interim_Message", + "item": [ + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 12\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_12}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"spamInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{spamMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 13\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_13}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 14\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_14}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"No it's not\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}_no\",\r\n \"title\": \"No, it's not\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_NOT_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_NOT_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_NOT_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_NOT_USEFUL\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_NOT_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update again", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 15\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_15}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE with feedback sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is spam🚧\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",\"\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005c_2nd Voter Legitimate", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"legitimate\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER2}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 16\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_16}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005d_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{spamVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is a sp-am message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{spamMessageId}}_{{spamVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "SPAM", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SPAM final reply sent to checker 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SPAM = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const spamResponse = getFinalResponseText(SPAM)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": spamResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"SATISFACTION_SURVEY sent to user1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"spamInstanceId\")\r", + " const SATISFACTION_SURVEY = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY\");\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": SATISFACTION_SURVEY\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Tap to respond\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `satisfactionSurvey_10_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"10\",\r", + " \"description\": \"Extremely likely 🤩\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_9_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"9\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_8_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"8\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_7_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"7\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_6_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"6\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_5_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"5\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_4_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"4\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_3_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"3\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_2_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"2\"\r", + " },\r", + " {\r", + " \"id\": `satisfactionSurvey_1_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"1\",\r", + " \"description\": \"Not at all likely 😥\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Votes 10", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"satisfactionSurvey_10_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"10\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "SATISFACTION_SURVEY_THANKS", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const SATISFACTION_SURVEY_THANKS = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SATISFACTION_SURVEY_THANKS\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": SATISFACTION_SURVEY_THANKS,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check instance updated", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance data updated correctly\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const isSatisfactionSurveySent = jsonData.fields.isSatisfactionSurveySent.booleanValue\r", + " const satisfactionScore = parseInt(jsonData.fields.satisfactionScore.integerValue) //for some reason integerValue returns string\r", + "\r", + " pm.expect(isSatisfactionSurveySent).to.be.true;\r", + " pm.expect(satisfactionScore).to.equal(10);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{spamMessageId}}/instances/{{spamInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{spamMessageId}}", + "instances", + "{{spamInstanceId}}" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 17\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{{{whatsapp_id_17}}}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "ALREADY_REPLIED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"ALREADY_REPLIED sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const ALREADY_REPLIED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.ALREADY_REPLIED\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": ALREADY_REPLIED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "005e_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 18\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_18}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{spamMessageId}}/instances/{{spamInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_11\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"66.67% of our CheckMates thought this was *spam*. 33.33% thought this was *legitimate*.\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "006_Info_Machine_Human", + "item": [ + { + "name": "006a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 19\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoMessageId`, messageId);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const infoVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = infoVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`infoVoteRequestPath_${name}`, infoVoteRequestPath);\r", + " pm.collectionVariables.set(`infoVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"1\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER1}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"infoInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 20\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_20}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 21\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_21}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is untrue❌\").replace(\"{{info_placeholder}}\",\", with an average score of 1.00 on a scale of 0-5 (5 = completely true)\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.nullValue).to.equal(null);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances/{{infoInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances", + "{{infoInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006b_2nd_Voter_1", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"1\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER2}}_1\",\r\n \"title\": \"1\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "UNTRUE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"UNTRUE final reply sent to checker 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"infoInstanceId\")\r", + " const UNTRUE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNTRUE\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const response = getFinalResponseText(UNTRUE)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": response\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006c_3rd_Voter_5", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{infoVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an info message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"infoVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"5\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{infoMessageId}}_{{infoVoteRequestId_CHECKER3}}_5\",\r\n \"title\": \"5\",\r\n \"description\": \"Totally true\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "006d_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 22\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_22}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{infoMessageId}}/instances/{{infoInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_19\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"100.00% of our CheckMates collectively thought this was *misleading*, with an average score of 2.33 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "007_Unsure_Human", + "item": [ + { + "name": "007a_User_Send_First_Vote", + "item": [ + { + "name": "Send WhatsApp message (15 Chars)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 23\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_23}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an unsure message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (MESSAGE_NOT_YET_ASSESSED)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const MESSAGE_NOT_YET_ASSESSED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MESSAGE_NOT_YET_ASSESSED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": MESSAGE_NOT_YET_ASSESSED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get first checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureMessageId`, messageId);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get second checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get third checker message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const HARD_CODED_ID = \"HARD_CODED_ID\"\r", + " const CHECKER_NAME = \"CHECKER_NAME\"\r", + " const CHECKER_PHONE_NUMBER = \"CHECKER_PHONE_NUMBER\"\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBER,\r", + " \"type\": \"template\",\r", + " \"template\": {\r", + " \"name\": \"new_message_received\",\r", + " \"language\": {\r", + " \"policy\": \"deterministic\",\r", + " \"code\": \"en\"\r", + " },\r", + " \"components\": [\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 0,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"button\",\r", + " \"sub_type\": \"quick_reply\",\r", + " \"index\": 1,\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"payload\",\r", + " \"payload\": HARD_CODED_ID\r", + " }\r", + " ]\r", + " },\r", + " {\r", + " \"type\": \"body\",\r", + " \"parameters\": [\r", + " {\r", + " \"type\": \"text\",\r", + " \"text\": CHECKER_NAME\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"factChecker\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " //check name in list\r", + " const name = jsonData.body.template.components[2].parameters[0].text\r", + " pm.expect(CHECKER_NAMES).to.include(name);\r", + " //check number in list\r", + " const number = jsonData.body.to\r", + " pm.expect(CHECKER_PHONE_NUMBERS).to.include(number);\r", + " const unsureVoteRequestPath = jsonData.body.template.components[0].parameters[0].payload\r", + " const [, messageId, , voteRequestId] = unsureVoteRequestPath.split(\"/\")\r", + " pm.collectionVariables.set(`unsureVoteRequestPath_${name}`, unsureVoteRequestPath);\r", + " pm.collectionVariables.set(`unsureVoteRequestId_${name}`, voteRequestId);\r", + " // Replace dynamically created IDs\r", + " jsonData.body.to = CHECKER_PHONE_NUMBER\r", + " jsonData.body.template.components[0].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[1].parameters[0].payload = HARD_CODED_ID\r", + " jsonData.body.template.components[2].parameters[0].text = CHECKER_NAME\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER1}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "First checker selects \"unsure\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_unsure\",\r\n \"title\": \"I'm Unsure\",\r\n \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007b_Interim_Message", + "item": [ + { + "name": "Send /interim command", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 24\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_24}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"/interim\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"severity\": \"INFO\",\r\n \"message\": \"\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Instance ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that there is 1 instance\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.documents?.length).to.eql(1);\r", + " var fullName = jsonData.documents[0].name;\r", + " var splitName = fullName.split(\"/\");\r", + " var docId = splitName[splitName.length - 1];\r", + " pm.collectionVariables.set(\"unsureInstanceId\", docId);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const INTERIM_PROMPT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get interim update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 25\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_25}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"33.33\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(false);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007c_1st Voter Change To Legitimate", + "item": [ + { + "name": "First checker selects \"legitimate\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_1_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER1}}_legitimate\",\r\n \"title\": \"Legitimate\",\r\n \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[0],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 26\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_26}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_WITH_FEEDBACK", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE\");\r", + " const INTERIM_FEEDBACK = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_FEEDBACK\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE.replace(\"{{%voted}}\", \"33.33\").replace(\"{{prelim_assessment}}\",\"is legitimate✅\").replace(\"{{info_placeholder}}\",\"\").replace(\"{{get_feedback}}\",INTERIM_FEEDBACK)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_yes`,\r", + " \"title\": \"Yes, it's useful\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `feedbackInterim_messages/${messageId}/instances/${instanceId}_no`,\r", + " \"title\": \"No, it's not\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(false);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + }, + { + "name": "Press button \"Yes it's useful\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 27\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_27}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"feedbackInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}_yes\",\r\n \"title\": \"Yes, it's useful\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_USEFUL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_USEFUL sent to user\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_USEFUL = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_USEFUL\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": INTERIM_USEFUL\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check interim values", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData?.fields?.isMeaningfulInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimReplySent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimPromptSent?.booleanValue).to.equal(true);\r", + " pm.expect(jsonData?.fields?.isInterimUseful?.booleanValue).to.equal(true);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{unsureMessageId}}", + "instances", + "{{unsureInstanceId}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007d_2nd Voter Info \"3\"", + "item": [ + { + "name": "Second checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER2}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"info\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_info\",\r\n \"title\": \"News/Information/Opinion\",\r\n \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_NEXT_POLL", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_NEXT_POLL message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"spamVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const HOLD_FOR_NEXT_POLL = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_NEXT_POLL\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_NEXT_POLL,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "FACTCHECK_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER2\").split(\"/\")\r", + " const FACTCHECK_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.FACTCHECK_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": FACTCHECK_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Vote here\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_0`,\r", + " \"title\": \"0\",\r", + " \"description\": \"Totally false\"\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_1`,\r", + " \"title\": \"1\",\r", + " }, \r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_2`,\r", + " \"title\": \"2\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_3`,\r", + " \"title\": \"3\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_4`,\r", + " \"title\": \"4\",\r", + " },\r", + " {\r", + " \"id\": `vote_${messageId}_${voteRequestId}_5`,\r", + " \"title\": \"5\",\r", + " \"description\": \"Totally true\"\r", + " },\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Second checker selects \"3\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_2_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_2_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_2_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"vote_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER2}}_3\",\r\n \"title\": \"3\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[1],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Press button to get interim update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 28\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_28}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"sendInterim_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"Get interim update\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "INTERIM_TEMPLATE_UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"INTERIM_TEMPLATE_UNSURE sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER1\").split(\"/\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const INTERIM_TEMPLATE_UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.INTERIM_TEMPLATE_UNSURE\");\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const interimResponse = INTERIM_TEMPLATE_UNSURE.replace(\"{{%voted}}\", \"66.67\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": interimResponse\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `sendInterim_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"Get another update\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " \r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007e_3rd Voter Spam", + "item": [ + { + "name": "Third checker clicks yes", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"button\",\r\n \"button\": {\r\n \"payload\": \"{{unsureVoteRequestPath_CHECKER3}}\",\r\n \"text\": \"Yes!\"\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Message to Check Sent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Message to check sent to checker 2\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"This is an unsure message that will be voted on\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\"\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L1_ASSESSMENT_PROMPT", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L1_ASSESSMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L1_ASSESSMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L1_ASSESSMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L1_ASSESSMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_scam`,\r", + " \"title\": \"Scam\",\r", + " \"description\": \"Intended to obtain money/personal information via deception\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_illicit`,\r", + " \"title\": \"Illicit\",\r", + " \"description\": \"Other potential illicit activity, e.g. moneylending/prostitution\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_info`,\r", + " \"title\": \"News/Information/Opinion\",\r", + " \"description\": \"Messages intended to inform/convince/mislead a broad base of people\"\r", + " },\r", + " {\r", + " \"id\": `categorize_${messageId}_${voteRequestId}_others`,\r", + " \"title\": \"It's something else\",\r", + " \"description\": \"Messages that don't fall into the other categories\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " //console.log(JSON.stringify(expected,null,2))\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"It's something else\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"categorize_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_others\",\r\n \"title\": \"It's something else\",\r\n \"description\": \"Messages that don't fall into the other categories\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "HOLD_FOR_L2_CATEGORISATION", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"HOLD_FOR_L2_CATEGORISATION message sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const HOLD_FOR_L2_CATEGORISATION = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.HOLD_FOR_L2_CATEGORISATION\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": HOLD_FOR_L2_CATEGORISATION,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "L2_CATEGORISATION_MENU", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"L2_OTHERS_ASSESSEMENT_PROMPT sent to checker 1\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const L2_OTHERS_ASSESSEMENT_PROMPT = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.L2_OTHERS_ASSESSEMENT_PROMPT\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": L2_OTHERS_ASSESSEMENT_PROMPT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"Make Selection\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_spam`,\r", + " \"title\": \"Spam\",\r", + " \"description\": \"Unsolicited spam, such as marketing messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_legitimate`,\r", + " \"title\": \"Legitimate\",\r", + " \"description\": \"Legitimate source but can't be assessed, e.g. transactional messages\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_irrelevant`,\r", + " \"title\": \"Trivial\",\r", + " \"description\": \"Trivial/banal messages with nothing to assess\"\r", + " },\r", + " {\r", + " \"id\": `others_${messageId}_${voteRequestId}_unsure`,\r", + " \"title\": \"I'm Unsure\",\r", + " \"description\": \"Do try your best to categorize! But if really unsure, select this\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Third checker selects \"spam\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_CHECKER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{CHECKER_3_NAME}}\"\r\n },\r\n \"wa_id\": \"{{CHECKER_3_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{CHECKER_3_NUMBER}}\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"others_{{unsureMessageId}}_{{unsureVoteRequestId_CHECKER3}}_spam\",\r\n \"title\": \"Spam\",\r\n \"description\": \"Unsolicited spam, such as marketing messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "RESPONSE_RECORDED", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"RESPONSE_RECORDED sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const RESPONSE_RECORDED = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.RESPONSE_RECORDED\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": RESPONSE_RECORDED,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "NO_OUTSTANDING", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"NO_OUTSTANDING sent to checker 3\", function () {\r", + " const CHECKER_PHONE_NUMBERS = [pm.variables.get(\"CHECKER_1_NUMBER\"), pm.variables.get(\"CHECKER_2_NUMBER\"), pm.variables.get(\"CHECKER_3_NUMBER\")]\r", + " const CHECKER_NAMES = [pm.variables.get(\"CHECKER_1_NAME\"), pm.variables.get(\"CHECKER_2_NAME\"), pm.variables.get(\"CHECKER_3_NAME\")]\r", + " const NO_OUTSTANDING = pm.variables.get(\"__CONSTANTS__.FACTCHECKER_BOT_RESPONSES.NO_OUTSTANDING\");\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_CHECKER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": NO_OUTSTANDING,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": CHECKER_PHONE_NUMBERS[2],\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "UNSURE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"UNSURE final reply sent to user 1\", function () {\r", + " const [, messageId, , voteRequestId] = pm.variables.get(\"unsureVoteRequestPath_CHECKER3\").split(\"/\")\r", + " const instanceId = pm.variables.get(\"unsureInstanceId\")\r", + " const UNSURE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.UNSURE\");\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\");\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\");\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\");\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\");\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " const isMachineCategorised = false\r", + " const instanceCount = 1\r", + " const isImmediate = false\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " function getFinalResponseText(responseText) {\r", + " return responseText\r", + " .replace(\r", + " \"{{thanks}}\",\r", + " isImmediate ? THANKS_IMMEDIATE : THANKS_DELAYED\r", + " )\r", + " .replace(\r", + " \"{{matched}}\",\r", + " instanceCount >= 5\r", + " ? `In fact, others have already sent this message in ${instanceCount} times. `\r", + " : \"\"\r", + " )\r", + " .replace(\r", + " \"{{methodology}}\",\r", + " isMachineCategorised\r", + " ? METHODOLOGY_AUTO\r", + " : METHODOLOGY_HUMAN\r", + " )\r", + " .replace(\"{{results}}\", isImmediate ? \"\" : VOTE_RESULTS_SUFFIX)\r", + " }\r", + " const response = getFinalResponseText(UNSURE)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": response\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": `votingResults_messages/${messageId}/instances/${instanceId}`,\r", + " \"title\": \"See voting results\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "007f_Stats_Message", + "item": [ + { + "name": "Press button to see stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 29\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"6580431949\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"6580431949\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_29}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"button_reply\",\r\n \"button_reply\": {\r\n \"id\": \"votingResults_messages/{{unsureMessageId}}/instances/{{unsureInstanceId}}\",\r\n \"title\": \"See voting results\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "STATS_TEMPLATE", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"STATS_TEMPLATE sent to user 1\", function () {\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_23\")\r", + " //we not using the template for this, its hardcoded.\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": \"33.33% of our CheckMates thought this was *spam*. 33.33% collectively thought this was *misleading*, with an average score of 3.00 on a scale of 0-5 (5 = completely true).\",\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "008_Menu_Message", + "item": [ + { + "name": "Send WhatApp message (\"Menu\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 30\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_30}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": {\r\n \"body\": \"Menu\"\r\n },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (GENERIC_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Check/Report\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 31\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_31}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_check\",\r\n \"title\": \"Check/Report\",\r\n \"description\": \"Send in messages, images, or screenshots for checking!\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (PROCEED_TO_SEND)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.PROCEED_TO_SEND\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Help\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 32\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_32}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_help\",\r\n \"title\": \"Get Help\",\r\n \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (HOW_TO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.HOW_TO\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"About CheckMate\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 33\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_33}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_about\",\r\n \"title\": \"About CheckMate\",\r\n \"description\": \"Learn more about CheckMate and the team behind it\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (LEARN_MORE)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.LEARN_MORE\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Send Feedback\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 34\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_34}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_feedback\",\r\n \"title\": \"Send Feedback\",\r\n \"description\": \"Send us feedback on anything to do with CheckMate\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (FEEDBACK)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.FEEDBACK\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Get Contact\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 35\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_35}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_contact\",\r\n \"title\": \"Get Contact\",\r\n \"description\": \"Get CheckMates contact to add to your contact list\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (contact type)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"contacts\",\r", + " \"contacts\": [\r", + " {\r", + " \"name\": {\r", + " \"formatted_name\": \"CheckMate\",\r", + " \"suffix\": \"CheckMate\"\r", + " },\r", + " \"urls\": [\r", + " {\r", + " \"url\": \"https://checkmate.sg\"\r", + " }\r", + " ],\r", + " \"phones\": [\r", + " {\r", + " \"phone\": \"+1 555-093-3685\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 5000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (CONTACT)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.CONTACT\");\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "Make Menu Selection (\"Referral\")", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 36\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n {\r\n \"profile\": {\r\n \"name\": \"{{USER_1_NAME}}\"\r\n },\r\n \"wa_id\": \"{{USER_1_NUMBER}}\"\r\n }\r\n ],\r\n \"messages\": [\r\n {\r\n \"context\": {\r\n \"from\": \"15550933685\",\r\n \"id\": \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==\"\r\n },\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_36}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"type\": \"interactive\",\r\n \"interactive\": {\r\n \"type\": \"list_reply\",\r\n \"list_reply\": {\r\n \"id\": \"menu_referral\",\r\n \"title\": \"Get Referral Link\",\r\n \"description\": \"Get referral link to forward to others\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (REFERRAL)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL\");\r", + " const link = pm.variables.get(\"referralLink_USER1\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const referralMessage = BODY_TEXT.replace(\"{{link}}\", link)\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": referralMessage,\r", + " \"preview_url\": true\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 2000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "009_Scam_Autocategorise", + "item": [ + { + "name": "User sends scam message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 37\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_37}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a scam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SCAM, IMMEDIATE, NOT MATCHED, AUTO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"scam immediate autocategorised no matched response\", function () {\r", + " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SCAM\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const THANKS_DELAYED = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_DELAYED\")\r", + " const METHODOLOGY_HUMAN = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_HUMAN\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const VOTE_RESULTS_SUFFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.VOTE_RESULTS_SUFFIX\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_37\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\").replace(\"{{results}}\",\"\")\r", + " const USER_1_NAME = pm.variables.get(\"USER_1_NAME\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_1_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"button\",\r", + " \"body\": {\r", + " \"text\": BODY_TEXT\r", + " },\r", + " \"action\": {\r", + " \"buttons\": [\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"Yes\"\r", + " }\r", + " },\r", + " {\r", + " \"type\": \"reply\",\r", + " \"reply\": {\r", + " \"id\": \"ID\",\r", + " \"title\": \"No\"\r", + " }\r", + " }\r", + " ]\r", + " }\r", + " },\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + " }\r", + "\r", + " var jsonData = pm.response.json();\r", + "\r", + " let reply_id_yes = jsonData.body.interactive.action.buttons[0].reply.id;\r", + " let reply_id_no = jsonData.body.interactive.action.buttons[1].reply.id;\r", + " let [, scamInstancePath , ] = reply_id_yes.split(\"_\")\r", + " \r", + " // check if the id matches the pattern \"menu_dispute_messages/*/instances/*\"\r", + " pm.expect(reply_id_yes).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_consent/);\r", + " pm.expect(reply_id_no).to.match(/scamshieldConsent_messages\\/\\w+\\/instances\\/\\w+_decline/);\r", + " pm.collectionVariables.set(\"scamInstancePath\", scamInstancePath);\r", + "\r", + " jsonData.body.interactive.action.buttons[0].reply.id = \"ID\"\r", + " jsonData.body.interactive.action.buttons[1].reply.id = \"ID\"\r", + "\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "010_Spam_Autocategorise", + "item": [ + { + "name": "User sends spam message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 38\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_38}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a spam message\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (SPAM, IMMEDIATE, NOT MATCHED, AUTO)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"spam immediate autocategorised no matched response\", function () {\r", + " const TEMPLATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.SPAM\");\r", + " const THANKS_IMMEDIATE = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.THANKS_IMMEDIATE\")\r", + " const METHODOLOGY_AUTO = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.METHODOLOGY_AUTO\")\r", + " const BODY_TEXT = TEMPLATE.replace(\"{{thanks}}\",THANKS_IMMEDIATE).replace(\"{{methodology}}\",METHODOLOGY_AUTO).replace(\"{{matched}}\",\"\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_38\")\r", + " const USER_1_NUMBER = pm.variables.get(\"USER_1_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_1_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "011_Check_Steps_logging", + "item": [ + { + "name": "[DB CALL] Check steps", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance data updated correctly\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const initialJourney = jsonData.fields.initialJourney.mapValue.fields\r", + " const actions = Object.values(initialJourney).map((obj) => obj.stringValue)\r", + " const expected = [\r", + " \"text_machine_irrelevant_length\",\r", + " \"text_machine_irrelevant_length\",\r", + " \"menu_dispute\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"feedbackInterim_no\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"satisfactionSurvey_10\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_info\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_machine_unsure\",\r", + " \"sendInterim\",\r", + " \"sendInterim\",\r", + " \"feedbackInterim_yes\",\r", + " \"sendInterim\",\r", + " \"votingResults\",\r", + " \"text_menu\",\r", + " \"menu_check\",\r", + " \"menu_help\",\r", + " \"menu_about\",\r", + " \"menu_feedback\",\r", + " \"menu_contact\",\r", + " \"menu_referral\",\r", + " \"text_machine_scam\",\r", + " \"text_machine_spam\",\r", + " ]\r", + " pm.expect(actions).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "012_New_User_Referral", + "item": [ + { + "name": "Send WhatsApp message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 39\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_39}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (NEW_USER_MENU)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Your test name\", function () {\r", + " const MENU = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.MENU\");\r", + " const PREFIX = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.NEW_USER_MENU_PREFIX\");\r", + " const MENU_TEXT = MENU.replace(\"{{prefix}}\",PREFIX)\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"recipient_type\": \"individual\",\r", + " \"to\": USER_2_NUMBER,\r", + " \"type\": \"interactive\",\r", + " \"interactive\": {\r", + " \"type\": \"list\",\r", + " \"body\": {\r", + " \"text\": MENU_TEXT\r", + " },\r", + " \"action\": {\r", + " \"button\": \"View Menu\",\r", + " \"sections\": [\r", + " {\r", + " \"rows\": [\r", + " {\r", + " \"id\": \"menu_check\",\r", + " \"title\": \"Check/Report\",\r", + " \"description\": \"Send in messages, images, or screenshots for checking!\"\r", + " },\r", + " {\r", + " \"id\": \"menu_referral\",\r", + " \"title\": \"Get Referral Link\",\r", + " \"description\": \"Get referral link to forward to others\"\r", + " },\r", + " {\r", + " \"id\": \"menu_help\",\r", + " \"title\": \"Get Help\",\r", + " \"description\": \"Find out how to use CheckMate to check or report dubious messages\"\r", + " },\r", + " {\r", + " \"id\": \"menu_about\",\r", + " \"title\": \"About CheckMate\",\r", + " \"description\": \"Learn more about CheckMate and the team behind it\"\r", + " },\r", + " {\r", + " \"id\": \"menu_feedback\",\r", + " \"title\": \"Send Feedback\",\r", + " \"description\": \"Send us feedback on anything to do with CheckMate\"\r", + " },\r", + " {\r", + " \"id\": \"menu_contact\",\r", + " \"title\": \"Get Contact\",\r", + " \"description\": \"Get CheckMate's contact to add to your contact list\"\r", + " }\r", + " ]\r", + " }\r", + " ]\r", + " }\r", + " }\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Check referral count", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that referral count is incremented to 1\", function () {\r", + "\r", + " var jsonData = pm.response.json();\r", + " const referralCount = jsonData.fields.referralCount.integerValue\r", + " pm.expect(parseInt(referralCount)).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/users/{{USER_1_NUMBER}}", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "users", + "{{USER_1_NUMBER}}" + ] + } + }, + "response": [] + }, + { + "name": "Send 2nd referral message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 40\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_2_NAME}}\" }, \"wa_id\": \"{{USER_2_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_2_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_40}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"{{__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_PREPOPULATED_PREFIX}} {{referralId_USER1}}\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Get last message (REFERRAL_INVALID)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"REFERRAL_INVALID response received\", function () {\r", + " const BODY_TEXT = pm.variables.get(\"__CONSTANTS__.USER_BOT_RESPONSES.REFERRAL_INVALID\");\r", + " const USER_2_NUMBER = pm.variables.get(\"USER_2_NUMBER\")\r", + " const wamid = pm.variables.get(\"whatsapp_id_40\")\r", + " const expected = {\r", + " \"hostname\": \"resultserver\",\r", + " \"path\": \"/v15.0/WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID/messages\",\r", + " \"body\": {\r", + " \"text\": {\r", + " \"body\": BODY_TEXT,\r", + " \"preview_url\": false\r", + " },\r", + " \"to\": USER_2_NUMBER,\r", + " \"messaging_product\": \"whatsapp\",\r", + " \"context\": {\r", + " \"message_id\": wamid\r", + " },\r", + " },\r", + " \"method\": \"POST\"\r", + "}\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData).to.eql(expected);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "setTimeout(() => {}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{RESULT_SERVER_URL}}/testresultdata", + "host": [ + "{{RESULT_SERVER_URL}}" + ], + "path": [ + "testresultdata" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "013_Duplicate_wamid", + "item": [ + { + "name": "[DB CALL] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Info Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that instance interim data values are updated correctly\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.documents.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages/{{infoMessageId}}/instances", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages", + "{{infoMessageId}}", + "instances" + ] + } + }, + "response": [] + }, + { + "name": "Duplicate Info Message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_19}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is an info message that will be voted on\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that message count did not increase\", function () {\r", + " var jsonData = pm.response.json();\r", + " const count = pm.variables.get(\"messageCount\")\r", + " pm.expect(jsonData.documents.length).to.eql(count);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "[DB CALL] Get Count of Info Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that info instance count did not increase\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.collectionVariables.set(\"messageCount\", jsonData.documents.length)\r", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents/messages", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents", + "messages" + ] + } + }, + "response": [] + }, + { + "name": "New unsure message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// 1. Retrieve the current messageCounter and increment it.\r", + "let messageCounter = 41\r", + "\r", + "const whatsappId = \"wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFA1==\";\r", + "\r", + "// 3. Replace the last n characters (excluding the == at the end) of whatsappId with the new messageCounter\r", + "let n = messageCounter.toString().length;\r", + "let basePart = whatsappId.substring(0, whatsappId.length - n - 2);\r", + "let newId = basePart + messageCounter + \"==\";\r", + "\r", + "pm.collectionVariables.set(`whatsapp_id_${messageCounter}`, newId)\r", + "\r", + "// Allow time for firestore onUpdate event to complete\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_41}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a whatever message that will be voted on 24601\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "Mocked immediate retry", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"object\": \"whatsapp_business_account\",\r\n \"entry\": [\r\n {\r\n \"id\": \"WHATSAPP_TEST_USER_WABA_ID\",\r\n \"changes\": [\r\n {\r\n \"value\": {\r\n \"messaging_product\": \"whatsapp\",\r\n \"metadata\": {\r\n \"display_phone_number\": \"15550933685\",\r\n \"phone_number_id\": \"WHATSAPP_TEST_USER_BOT_PHONE_NUMBER_ID\"\r\n },\r\n \"contacts\": [\r\n { \"profile\": { \"name\": \"{{USER_1_NAME}}\" }, \"wa_id\": \"{{USER_1_NUMBER}}\" }\r\n ],\r\n \"messages\": [\r\n {\r\n \"from\": \"{{USER_1_NUMBER}}\",\r\n \"id\": \"{{whatsapp_id_41}}\",\r\n \"timestamp\": {{$timestamp}},\r\n \"text\": { \"body\": \"This is a whatever message that will be voted on 24601\" },\r\n \"type\": \"text\"\r\n }\r\n ]\r\n },\r\n \"field\": \"messages\"\r\n }\r\n ]\r\n }\r\n ]\r\n}\r\n", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FUNCTIONS_URL}}/checkmate-373101/asia-southeast1/webhookHandlerV2/whatsapp", + "host": [ + "{{FUNCTIONS_URL}}" + ], + "path": [ + "checkmate-373101", + "asia-southeast1", + "webhookHandlerV2", + "whatsapp" + ] + } + }, + "response": [] + }, + { + "name": "[DB QUERY] Get Count of Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that only 1 message was created\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Allow time for firestore onUpdate event to complete\r", + "setTimeout(() => {}, 6000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"structuredQuery\": {\r\n \"from\": [{\r\n \"collectionId\": \"messages\"\r\n }],\r\n \"where\": {\r\n \"fieldFilter\": {\r\n \"field\": {\r\n \"fieldPath\": \"text\"\r\n },\r\n \"op\": \"EQUAL\",\r\n \"value\": {\r\n \"stringValue\": \"This is a whatever message that will be voted on 24601\"\r\n }\r\n }\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:runQuery" + ] + } + }, + "response": [] + }, + { + "name": "[DB COLLECTIONGROUP QUERY] Get Count of Instances", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check that only 1 instance was created\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.length).to.eql(1);\r", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer owner", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"structuredQuery\": {\r\n \"from\": [{\r\n \"collectionId\": \"instances\",\r\n \"allDescendants\": true\r\n }],\r\n \"where\": {\r\n \"fieldFilter\": {\r\n \"field\": {\r\n \"fieldPath\": \"text\"\r\n },\r\n \"op\": \"EQUAL\",\r\n \"value\": {\r\n \"stringValue\": \"This is a whatever message that will be voted on 24601\"\r\n }\r\n }\r\n }\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{FIRESTORE_URL}}/v1/projects/checkmate-373101/databases/(default)/documents:runQuery", + "host": [ + "{{FIRESTORE_URL}}" + ], + "path": [ + "v1", + "projects", + "checkmate-373101", + "databases", + "(default)", + "documents:runQuery" + ] + } + }, + "response": [] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "disputedMessagePath", + "value": "" + }, + { + "key": "disputedMessageTextListId", + "value": "" + }, + { + "key": "disputedInstancePath", + "value": "" + }, + { + "key": "scamInstancePath", + "value": "" + }, + { + "key": "spamVoteRequestPath", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "spamVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "spamMessageId_CHECKER3", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "spamMessageId_CHECKER2", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "spamMessageId_CHECKER1", + "value": "" + }, + { + "key": "spamVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "spamMessageId", + "value": "" + }, + { + "key": "spamInstanceId", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "infoMessageId", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "infoVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "infoVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "infoInstanceId", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER3", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER3", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER2", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER2", + "value": "" + }, + { + "key": "unsureInstanceId", + "value": "" + }, + { + "key": "unsureVoteRequestPath_CHECKER1", + "value": "" + }, + { + "key": "unsureMessageId", + "value": "" + }, + { + "key": "unsureVoteRequestId_CHECKER1", + "value": "" + }, + { + "key": "user_1_referralId", + "value": "" + }, + { + "key": "referralLink_USER1", + "value": "" + }, + { + "key": "referralId_USER1", + "value": "" + }, + { + "key": "messageCounter", + "value": "" + }, + { + "key": "whatsapp_id_1", + "value": "" + }, + { + "key": "whatsapp_id_2", + "value": "" + }, + { + "key": "whatsapp_id_3", + "value": "" + }, + { + "key": "whatsapp_id_4", + "value": "" + }, + { + "key": "whatsapp_id_5", + "value": "" + }, + { + "key": "whatsapp_id_6", + "value": "" + }, + { + "key": "whatsapp_id_7", + "value": "" + }, + { + "key": "whatsapp_id_8", + "value": "" + }, + { + "key": "whatsapp_id_9", + "value": "" + }, + { + "key": "whatsapp_id_10", + "value": "" + }, + { + "key": "whatsapp_id_11", + "value": "" + }, + { + "key": "whatsapp_id_12", + "value": "" + }, + { + "key": "whatsapp_id_13", + "value": "" + }, + { + "key": "whatsapp_id_14", + "value": "" + }, + { + "key": "whatsapp_id_15", + "value": "" + }, + { + "key": "whatsapp_id_39", + "value": "" + }, + { + "key": "whatsapp_id_40", + "value": "" + }, + { + "key": "whatsapp_id_16", + "value": "" + }, + { + "key": "whatsapp_id_17", + "value": "" + }, + { + "key": "whatsapp_id_18", + "value": "" + }, + { + "key": "whatsapp_id_19", + "value": "" + }, + { + "key": "whatsapp_id_20", + "value": "" + }, + { + "key": "whatsapp_id_21", + "value": "" + }, + { + "key": "whatsapp_id_22", + "value": "" + }, + { + "key": "whatsapp_id_23", + "value": "" + }, + { + "key": "whatsapp_id_24", + "value": "" + }, + { + "key": "whatsapp_id_25", + "value": "" + }, + { + "key": "whatsapp_id_26", + "value": "" + }, + { + "key": "whatsapp_id_27", + "value": "" + }, + { + "key": "whatsapp_id_28", + "value": "" + }, + { + "key": "whatsapp_id_29", + "value": "" + }, + { + "key": "whatsapp_id_30", + "value": "" + }, + { + "key": "whatsapp_id_31", + "value": "" + }, + { + "key": "whatsapp_id_32", + "value": "" + }, + { + "key": "whatsapp_id_33", + "value": "" + }, + { + "key": "whatsapp_id_34", + "value": "" + }, + { + "key": "whatsapp_id_35", + "value": "" + }, + { + "key": "whatsapp_id_36", + "value": "" + }, + { + "key": "whatsapp_id_37", + "value": "" + }, + { + "key": "whatsapp_id_38", + "value": "" + }, + { + "key": "messageCount", + "value": "" + }, + { + "key": "whatsapp_id_41", + "value": "" + } + ] +} \ No newline at end of file diff --git a/integration-tests/env.json b/integration-tests/env.json index 587eb4fe..40ae6c11 100644 --- a/integration-tests/env.json +++ b/integration-tests/env.json @@ -8,6 +8,11 @@ "type": "default", "enabled": true }, + { + "key": "MOCK_WHATSAPP_MSG_ID", + "value": "wamid.HBgKNjU5Njg4MDMyMBUCABIYIEY4MDAwNTlEODQyMDZDMkNDOEU1NEVEQjc1MTNCMjlFAA==", + "enabled": true + }, { "key": "FIRESTORE_URL", "value": "http://localhost:18080", @@ -377,4 +382,4 @@ "_postman_variable_scope": "environment", "_postman_exported_at": "2023-04-30T14:17:56.196Z", "_postman_exported_using": "Postman/10.13.0" -} \ No newline at end of file +} diff --git a/integration-tests/package.json b/integration-tests/package.json index 40c5552a..24d39a08 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "newman run checkmate.postman_collection.json -g ./env.json --delay-request 2000", + "test": "newman run checkmate.postman_collection.json -g ./env.json", "update-env": "ts-node ./update-env.ts" }, "author": "",