From a1ab724d06ed1f5101c2074c4f01290ec679ca81 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 15:13:57 +0800 Subject: [PATCH 1/7] added message at the end of onboarding --- .../eventHandlers/checkerHandlerTelegram.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index d765624f..aa2299c2 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -669,15 +669,11 @@ const sendCompletionPrompt = async ( }) await bot.telegram.sendMessage( chatId, - `You have now successfully onboarded as a checker! You will now receive notifications when there are messages that need checking. - -Feel free to explore the Checker's Portal below, or by pressing the button at the bottom left of the screen. Here, you can view the leaderboard, your accuracy, and more. + `Finally, check out the Checker's Portal below, which is where you will vote on messages, and see the leaderboard and your statistics. ${resources} -You may view these resources with the command /resources. - -`, +You may view these resources with the command /resources.`, { reply_markup: { inline_keyboard: [ @@ -692,6 +688,10 @@ You may view these resources with the command /resources. parse_mode: "HTML", } ) + await bot.telegram.sendMessage( + chatId, + `You've now successfully onboarded as a Checker. Stay tuned - you'll receive notifications in this chat when users submit messages for checking. You'll then do the fact-checks on the Checkers' Portal.` + ) } const checkCheckerIsUser = async (whatsappId: string) => { From 0be898edc17a16484cfe22915d97286effb0d410 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 18:44:59 +0800 Subject: [PATCH 2/7] welcome message --- .../eventHandlers/checkerHandlerTelegram.ts | 1 - .../definitions/webhookHandlers/handler.ts | 19 +++++- .../handlers/adminHandlerTelegram.ts | 61 +++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index d765624f..ea9431cd 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -8,7 +8,6 @@ import { getThresholds } from "../common/utils" import { CheckerData } from "../../types" import { message, callbackQuery } from "telegraf/filters" import { isNumeric } from "../common/utils" -import { send } from "process" const TOKEN = String(process.env.TELEGRAM_CHECKER_BOT_TOKEN) const ADMIN_BOT_TOKEN = String(process.env.TELEGRAM_ADMIN_BOT_TOKEN) diff --git a/functions/src/definitions/webhookHandlers/handler.ts b/functions/src/definitions/webhookHandlers/handler.ts index e5763991..ce7ec280 100644 --- a/functions/src/definitions/webhookHandlers/handler.ts +++ b/functions/src/definitions/webhookHandlers/handler.ts @@ -8,6 +8,7 @@ import { publishToTopic } from "../common/pubsub" import { onRequest } from "firebase-functions/v2/https" import { checkMessageId } from "../common/utils" import { Request, Response } from "express" +import { adminBotHandlerTelegram } from "./handlers/adminHandlerTelegram" import { AppEnv } from "../../appEnv" const runtimeEnvironment = defineString(AppEnv.ENVIRONMENT) @@ -15,6 +16,7 @@ const runtimeEnvironment = defineString(AppEnv.ENVIRONMENT) const webhookPathWhatsapp = process.env.WEBHOOK_PATH_WHATSAPP const webhookPathTelegram = process.env.WEBHOOK_PATH_TELEGRAM const webhookPathTypeform = process.env.WEBHOOK_PATH_TYPEFORM +const webhookPathTelegramAdmin = process.env.WEBHOOK_PATH_TELEGRAM_ADMIN const typeformSecretToken = process.env.TYPEFORM_SECRET_TOKEN const typeformURL = process.env.TYPEFORM_URL const ingressSetting = @@ -254,6 +256,20 @@ const postHandlerTypeform = async (req: CustomRequest, res: Response) => { } } +const postHandlerTelegramAdmin = async (req: Request, res: Response) => { + if ( + req.header("x-telegram-bot-api-secret-token") === + process.env.TELEGRAM_WEBHOOK_TOKEN + ) { + await adminBotHandlerTelegram(req.body) + } else { + functions.logger.warn( + "Telegram handler endpoint was called from unexpected source" + ) + } + res.sendStatus(200) +} + const verifySignature = function (receivedSignature: string, payload: string) { const hash = crypto .createHmac("sha256", typeformSecretToken as string) @@ -268,7 +284,7 @@ app.post(`/${webhookPathWhatsapp}`, postHandlerWhatsapp) app.get(`/${webhookPathWhatsapp}`, getHandlerWhatsapp) app.post(`/${webhookPathTelegram}`, postHandlerTelegram) - +app.post(`/${webhookPathTelegramAdmin}`, postHandlerTelegramAdmin) app.post(`/${webhookPathTypeform}`, postHandlerTypeform) // Accepts GET requests at the /webhook endpoint. You need this URL to setup webhook initially. @@ -285,6 +301,7 @@ const webhookHandlerV2 = onRequest( "WHATSAPP_USERS_WABA_ID", "TELEGRAM_WEBHOOK_TOKEN", "TYPEFORM_SECRET_TOKEN", + "TELEGRAM_ADMIN_BOT_TOKEN", ], }, app diff --git a/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts b/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts new file mode 100644 index 00000000..471f3a18 --- /dev/null +++ b/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts @@ -0,0 +1,61 @@ +import * as admin from "firebase-admin" +import { Telegraf } from "telegraf" +import { logger } from "firebase-functions/v2" +import { message } from "telegraf/filters" + +const ADMIN_BOT_TOKEN = String(process.env.TELEGRAM_ADMIN_BOT_TOKEN) +const CHECKERS_CHAT_ID = Number(process.env.CHECKERS_CHAT_ID) +const adminBot = new Telegraf(ADMIN_BOT_TOKEN) + +if (!admin.apps.length) { + admin.initializeApp() +} + +const db = admin.firestore() + +//check when new user joins chat +adminBot.on(message("new_chat_members"), async (ctx) => { + const chatId = ctx.chat.id + if (chatId === CHECKERS_CHAT_ID) { + //may want to check chatID in future + const newMembers = ctx.message.new_chat_members + const messagePromises = newMembers.map(async (member) => { + const checkerQueryRef = db + .collection("checkers") + .where("telegramId", "==", member.id) + const checkerQuerySnapshot = await checkerQueryRef.get() + if (checkerQuerySnapshot.empty) { + logger.log( + `Telegram username ${member.id} not found in checkers collection` + ) + return + } + const name = checkerQuerySnapshot.docs[0].get("name") ?? "Checker" + const username = member.username ? ` @${member.username}` : "" + const message = `Hi ${name}${username}, + +Welcome to the CheckMate comms channel 👋 + +This channel will be used to: +1. Inform CheckMates when updates/improvements are deployed to the bots + +2. Inform CheckMates of any downtime in the system + +3. Share relevant links from reputable news sources to aid fact checking. Note: Beyond this, CheckMates should not discuss what scores to assign, as this may make the collective outcome of CheckMates' votes biased. + +4. You can refer to bit.ly/checkmates-wiki for more tips on safe checking 😊 + +If you've any feedback or queries, you can share them in the chat too 🤗` + + return ctx.reply(message) + }) + await Promise.all(messagePromises) + } +}) + +// FIREBASE FUNCTIONS +const adminBotHandlerTelegram = async function (body: any) { + await adminBot.handleUpdate(body) +} + +export { adminBotHandlerTelegram } From 2421953b8f9d5323154c9cd526d6dea7368aae8b Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 19:26:10 +0800 Subject: [PATCH 3/7] added step indicators to onboarding --- .../eventHandlers/checkerHandlerTelegram.ts | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index 1f85499d..c484af57 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -35,6 +35,19 @@ if (!admin.apps.length) { const db = admin.firestore() +function progressBars(currentStep: number) { + const totalSteps = 6 + let progress = "" + for (let i = 0; i < totalSteps; i++) { + if (i < currentStep) { + progress += "🟩" + } else { + progress += "⬜" + } + } + return progress +} + // COMMAND HANDLERS bot.command("start", async (ctx) => { @@ -354,7 +367,9 @@ bot.on(callbackQuery("data"), async (ctx) => { if (checkerDocSnap.data()?.isQuizComplete) { isUser = await checkCheckerIsUser(whatsappId) ctx.reply( - "Thank you for completing the quiz! We hope you found it useful." + `Thank you for completing the quiz!💪🎉 We hope you found it useful. + +Progress: ${progressBars(3)}` ) if (isUser) { await sendTGGroupPrompt(chatId, checkerDocSnap, true) @@ -368,7 +383,9 @@ bot.on(callbackQuery("data"), async (ctx) => { case "WA_COMPLETED": isUser = await checkCheckerIsUser(whatsappId) if (isUser) { - ctx.reply("Thank you for onboarding to the WhatsApp service!") + ctx.reply(`Thank you for onboarding to the WhatsApp service! 🙌 + +Progress: ${progressBars(4)}`) await sendTGGroupPrompt(chatId, checkerDocSnap, true) } else { await sendWABotPrompt(chatId, checkerDocSnap, false) @@ -423,7 +440,7 @@ const sendNamePrompt = async ( ) => { const namePrompt = await bot.telegram.sendMessage( chatId, - "First up, how shall we address you?", + `First up, how shall we address you?`, { reply_markup: { force_reply: true }, } @@ -440,7 +457,9 @@ const sendNumberPrompt = async ( ) => { const numberPrompt = await bot.telegram.sendMessage( chatId, - `What is your WhatsApp phone number? Please include the country code, but omit the "+", e.g 6591234567`, + `What is your WhatsApp phone number? Please include the country code, but omit the "+", e.g 6591234567 + +Progress: ${progressBars(1)}`, { reply_markup: { force_reply: true }, } @@ -551,7 +570,9 @@ const sendQuizPrompt = async ( isFirstPrompt ? "Thank you for verifying your WhatsApp number" : "We noticed you have not completed the quiz yet" - }. Please proceed to complete the onboarding quiz here. This will equip you with the skills and knowledge to be a better checker!`, + }. Please proceed to complete the onboarding quiz here. This will equip you with the skills and knowledge to be a better checker! + +Progress: ${progressBars(2)}`, { reply_markup: { inline_keyboard: [ @@ -647,7 +668,9 @@ const sendNLBPrompt = async (chatId: number, checkerSnap: DocumentSnapshot) => { await bot.telegram.sendPhoto(chatId, NLB_SURE_IMAGE, { caption: `One last thing - CheckMate is partnering with the National Library Board to grow a vibrant learning community aimed at safeguarding the community from scams and misinformation. -If you'd like to get better at fact-checking, or if you're keen to meet fellow checkers in person, do check out and join the SURE Learning Community. It'll be fun!`, +If you'd like to get better at fact-checking, or if you're keen to meet fellow checkers in person, do check out and join the SURE Learning Community. It'll be fun! + +Progress: ${progressBars(5)}`, parse_mode: "HTML", reply_markup: { inline_keyboard: [ @@ -689,7 +712,7 @@ You may view these resources with the command /resources.`, ) await bot.telegram.sendMessage( chatId, - `You've now successfully onboarded as a Checker. Stay tuned - you'll receive notifications in this chat when users submit messages for checking. You'll then do the fact-checks on the Checkers' Portal.` + `Hooray! You've now successfully onboarded as a Checker! 🥳 Stay tuned - you'll receive notifications in this chat when users submit messages for checking. You'll then do the fact-checks on the Checkers' Portal.` ) } From 3fe9e600eb27608035e7dd801fcca885bc0547bd Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 19:41:39 +0800 Subject: [PATCH 4/7] show onboarding progress --- .../eventHandlers/checkerHandlerTelegram.ts | 204 ++++++++---------- 1 file changed, 95 insertions(+), 109 deletions(-) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index c484af57..32704f59 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -238,108 +238,99 @@ bot.on(message("text"), async (ctx) => { await ctx.reply("Sorry, this command is not supported.") return } - if (!msg.reply_to_message) { - // Ignore commands as they are handled separately - await ctx.reply( - "Sorry, this bot is unable to respond to free-form messages. Please reply to the last message asking for either your name, phone number, or OTP to continue the onboarding flow." - ) - } else if (msg.text && msg.reply_to_message) { - const checkerId = msg.from?.id - const chatId = msg.chat.id - - const userQuerySnap = await db - .collection("checkers") - .where("telegramId", "==", checkerId) - .get() + const checkerId = msg.from?.id + const chatId = msg.chat.id - const userSnap = userQuerySnap.docs[0] - - if ( - userSnap.data().lastTrackedMessageId == msg.reply_to_message.message_id - ) { - let currentStep = userSnap.data().onboardingStatus - let whatsappId = "" - - switch (currentStep) { - case "name": - const name = msg.text - if (name.replace(/\s+/g, "").length === 0) { - await ctx.reply( - "Name cannot be just spaces. Please enter a valid name." - ) - await sendNamePrompt(chatId, userSnap) - return - } - await userSnap.ref.update({ - name, - }) - await sendNumberPrompt(chatId, userSnap) - break - case "number": - whatsappId = msg.text.replace("+", "").replace(" ", "") - - if ( - whatsappId.length === 8 && - (whatsappId.startsWith("9") || whatsappId.startsWith("8")) - ) { - whatsappId = `65${whatsappId}` - } - //check if whatsappId is numeric - if (!isNumeric(whatsappId)) { - await ctx.reply( - `The phone number you entered is invalid. Please enter a valid phone number.` - ) - return - } + const userQuerySnap = await db + .collection("checkers") + .where("telegramId", "==", checkerId) + .get() - await userSnap.ref.update({ - whatsappId, - }) + const userSnap = userQuerySnap.docs[0] + let currentStep = userSnap.data().onboardingStatus + const expectingRepliesTo = ["name", "number", "verify"] + if (!expectingRepliesTo.includes(currentStep)) { + await ctx.reply( + "Sorry, this bot is unable to respond to free-form messages." + ) + } else if (msg.text) { + let whatsappId = "" + + switch (currentStep) { + case "name": + const name = msg.text + if (name.replace(/\s+/g, "").length === 0) { + await ctx.reply( + "Name cannot be just spaces. Please enter a valid name." + ) + await sendNamePrompt(chatId, userSnap) + return + } + await userSnap.ref.update({ + name, + }) + await sendNumberPrompt(chatId, userSnap) + break + case "number": + whatsappId = msg.text.replace("+", "").replace(" ", "") + + if ( + whatsappId.length === 8 && + (whatsappId.startsWith("9") || whatsappId.startsWith("8")) + ) { + whatsappId = `65${whatsappId}` + } + //check if whatsappId is numeric + if (!isNumeric(whatsappId)) { + await ctx.reply( + `The phone number you entered is invalid. Please enter a valid phone number.` + ) + return + } - await sendOTPPrompt(chatId, userSnap, whatsappId) - break - case "verify": - const otpAttempt = msg?.text || "" - whatsappId = userSnap.data().whatsappId - - const result = await checkOTP(otpAttempt, whatsappId, userSnap.id) - - const status = result.status - const message = result.message - try { - if (status === "success") { - await userSnap.ref.update({ - whatsappId, - onboardingStatus: "quiz", - lastTrackedMessageId: null, - }) - await sendQuizPrompt(chatId, userSnap, true) + await userSnap.ref.update({ + whatsappId, + }) + + await sendOTPPrompt(chatId, userSnap, whatsappId) + break + case "verify": + const otpAttempt = msg?.text || "" + whatsappId = userSnap.data().whatsappId + + const result = await checkOTP(otpAttempt, whatsappId, userSnap.id) + + const status = result.status + const message = result.message + try { + if (status === "success") { + await userSnap.ref.update({ + whatsappId, + onboardingStatus: "quiz", + lastTrackedMessageId: null, + }) + await sendQuizPrompt(chatId, userSnap, true) + } else { + if (message === "OTP mismatch") { + await sendVerificationPrompt(chatId, userSnap, true) + } else if (message === "OTP max attempts") { + await ctx.reply( + `Maximum OTP attempts reached. We will send a new OTP.` + ) + await sendOTPPrompt(chatId, userSnap, whatsappId) } else { - if (message === "OTP mismatch") { - await sendVerificationPrompt(chatId, userSnap, true) - } else if (message === "OTP max attempts") { - await ctx.reply( - `Maximum OTP attempts reached. We will send a new OTP.` - ) - await sendOTPPrompt(chatId, userSnap, whatsappId) - } else { - console.error(`OTP error with ${chatId}: ${message}`) - await ctx.reply( - "Apologies - an error occurred, please try again later." - ) - } + console.error(`OTP error with ${chatId}: ${message}`) + await ctx.reply( + "Apologies - an error occurred, please try again later." + ) } - break - } catch (error) { - logger.log("Error in OTP verification", error) } - default: - logger.log("Unhandled onboarding stage: ", currentStep) - } - } else { - await ctx.reply( - "Sorry, we don't support replies to messages except in certain cases. Please reply to the last message asking for either your name, phone number, or OTP to continue the onboarding flow." - ) + break + } catch (error) { + logger.log("Error in OTP verification", error) + } + default: + logger.log("Unhandled onboarding stage: ", currentStep) } } } catch (error) { @@ -416,9 +407,9 @@ Progress: ${progressBars(4)}`) case "SEND_OTP": await sendOTPPrompt(chatId, checkerDocSnap, whatsappId) break - case "VERIFY_OTP": - await sendVerificationPrompt(chatId, checkerDocSnap, false) - break + // case "VERIFY_OTP": + // await sendVerificationPrompt(chatId, checkerDocSnap, false) + // break case "ONBOARD_AGAIN": await checkerDocSnap.ref.update({ onboardingStatus: "name", @@ -486,22 +477,17 @@ const sendOTPPrompt = async ( if (postOTPHandlerRes.status === "success") { await bot.telegram.sendMessage( chatId, - `We have sent a 6-digit OTP to your WhatsApp at +${whatsappId}. Please check your WhatsApp for the OTP, and hit "Verify OTP" below.`, + `We have sent a 6-digit OTP to your WhatsApp at +${whatsappId}. Please check your WhatsApp for the OTP.`, { reply_markup: { - inline_keyboard: [ - [ - inlineButtons.verifyOTP, - inlineButtons.resendOTP, - inlineButtons.rekey, - ], - ], + inline_keyboard: [[inlineButtons.resendOTP, inlineButtons.rekey]], }, } ) await checkerSnap.ref.update({ - onboardingStatus: "otpSent", + onboardingStatus: "verify", }) + sendVerificationPrompt(chatId, checkerSnap, false) } else { switch (postOTPHandlerRes.message) { case "OTP request limit exceeded": @@ -712,7 +698,7 @@ You may view these resources with the command /resources.`, ) await bot.telegram.sendMessage( chatId, - `Hooray! You've now successfully onboarded as a Checker! 🥳 Stay tuned - you'll receive notifications in this chat when users submit messages for checking. You'll then do the fact-checks on the Checkers' Portal.` + `Hooray! You've now successfully onboarded as a Checker! 🥳 You can chill for now, but stay tuned - you'll receive notifications in this chat when users submit messages for checking. You'll then do the fact-checks on the Checkers' Portal.` ) } From 6ab91bfe781a8523137f85104e5106c6d8c8a07e Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 19:58:12 +0800 Subject: [PATCH 5/7] more resources --- .../eventHandlers/checkerHandlerTelegram.ts | 3 ++- .../webhookHandlers/handlers/adminHandlerTelegram.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index 32704f59..d8198251 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -27,7 +27,8 @@ const NLB_SURE_IMAGE = const resources = `Here are some resources 📚 you might find useful: 1) Our official CheckMate website 2) Our fact-checking wiki -3) The Typeform quiz you just took` +3) The Typeform quiz you just took +4) The S.U.R.E Learning Community that we're partnering the National Library Board on` if (!admin.apps.length) { admin.initializeApp() diff --git a/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts b/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts index 471f3a18..a54596b8 100644 --- a/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts +++ b/functions/src/definitions/webhookHandlers/handlers/adminHandlerTelegram.ts @@ -43,11 +43,18 @@ This channel will be used to: 3. Share relevant links from reputable news sources to aid fact checking. Note: Beyond this, CheckMates should not discuss what scores to assign, as this may make the collective outcome of CheckMates' votes biased. -4. You can refer to bit.ly/checkmates-wiki for more tips on safe checking 😊 +4. You can refer to our fact-checking wiki for more tips on safe checking 😊 + +5. To explore more resources, head to your personal Checker's bot and type / resources If you've any feedback or queries, you can share them in the chat too 🤗` - return ctx.reply(message) + return ctx.reply(message, { + link_preview_options: { + is_disabled: true, + }, + parse_mode: "HTML", + }) }) await Promise.all(messagePromises) } From 7284a1f190950fd68e7e587d1745dc2cd06a5899 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 20:10:56 +0800 Subject: [PATCH 6/7] removed redundant update --- .../src/definitions/eventHandlers/checkerHandlerTelegram.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index d8198251..73be2061 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -485,9 +485,6 @@ const sendOTPPrompt = async ( }, } ) - await checkerSnap.ref.update({ - onboardingStatus: "verify", - }) sendVerificationPrompt(chatId, checkerSnap, false) } else { switch (postOTPHandlerRes.message) { From 150e0cb7e9690b97424c959749299e561fb0add0 Mon Sep 17 00:00:00 2001 From: Bing Wen Tan Date: Sat, 17 Aug 2024 20:40:37 +0800 Subject: [PATCH 7/7] wording fix --- .../eventHandlers/checkerHandlerTelegram.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts index 73be2061..e1052204 100644 --- a/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts +++ b/functions/src/definitions/eventHandlers/checkerHandlerTelegram.ts @@ -38,7 +38,7 @@ const db = admin.firestore() function progressBars(currentStep: number) { const totalSteps = 6 - let progress = "" + let progress = "Onboarding Progress: " for (let i = 0; i < totalSteps; i++) { if (i < currentStep) { progress += "🟩" @@ -361,7 +361,7 @@ bot.on(callbackQuery("data"), async (ctx) => { ctx.reply( `Thank you for completing the quiz!💪🎉 We hope you found it useful. -Progress: ${progressBars(3)}` +${progressBars(3)}` ) if (isUser) { await sendTGGroupPrompt(chatId, checkerDocSnap, true) @@ -377,7 +377,7 @@ Progress: ${progressBars(3)}` if (isUser) { ctx.reply(`Thank you for onboarding to the WhatsApp service! 🙌 -Progress: ${progressBars(4)}`) +${progressBars(4)}`) await sendTGGroupPrompt(chatId, checkerDocSnap, true) } else { await sendWABotPrompt(chatId, checkerDocSnap, false) @@ -451,7 +451,7 @@ const sendNumberPrompt = async ( chatId, `What is your WhatsApp phone number? Please include the country code, but omit the "+", e.g 6591234567 -Progress: ${progressBars(1)}`, +${progressBars(1)}`, { reply_markup: { force_reply: true }, } @@ -556,7 +556,7 @@ const sendQuizPrompt = async ( : "We noticed you have not completed the quiz yet" }. Please proceed to complete the onboarding quiz here. This will equip you with the skills and knowledge to be a better checker! -Progress: ${progressBars(2)}`, +${progressBars(2)}`, { reply_markup: { inline_keyboard: [ @@ -654,7 +654,7 @@ const sendNLBPrompt = async (chatId: number, checkerSnap: DocumentSnapshot) => { If you'd like to get better at fact-checking, or if you're keen to meet fellow checkers in person, do check out and join the SURE Learning Community. It'll be fun! -Progress: ${progressBars(5)}`, +${progressBars(5)}`, parse_mode: "HTML", reply_markup: { inline_keyboard: [