Sends /quiz a word from your Google Sheet and marks your /answer against what the sheet says.

UsesGoogle SheetsOpenAITelegram

Drill your vocabulary list in Telegram

Keep your vocabulary in a Google Sheet, one row per word with a 'Term' column and an 'Answer' column, and drill yourself on it from Telegram. Whenever you send /quiz to your bot, it picks a word from the sheet at random and asks it. Send /answer followed by the word, an equals sign and what you think it means, and it marks you against what the sheet says.

Your sheet is the source of truth and nothing overrules it. An answer that matches the sheet word for word is marked correct straight away, before any AI is involved. Only an answer that does not match is passed to the AI, with a single question, whether it means the same thing, so a near miss can become a pass but a matching answer can never be marked wrong. If that check fails or comes back unclear, you are told the sheet's answer and the attempt is left unmarked. Messages that are not /quiz or /answer are ignored.

You need a Telegram bot in a private chat of your own.

TelegramTelegramWhen a new message is received. Save it as message.When a new message is received. Save it as message.
ValuesSet vocabSheetUrl to blank.Set vocabSheetUrl to blank.
ValuesSet sheetName to blank.Set sheetName to blank.
ValuesSet maxWordsRead to 500.Set maxWordsRead to 500.
MathSet wordsToRead to maxWordsRead multiplied by 1.Set wordsToRead to maxWordsRead multiplied by 1.
Decisions & LoopsIf wordsToRead is less than 1If wordsToRead is less than 1
Yes
Decisions & LoopsStop and report a problem: Set 'maxWordsRead' to 1 or more - it is how many rows of your sheet the drill reads.Stop and report a problem: Set 'maxWordsRead' to 1 or more - it is how many rows of your sheet the drill reads.
No
No steps
ValuesSet chatId to message.chat_id.Set chatId to message.chat_id.
ValuesSet messageText to blank.Set messageText to blank.
Decisions & LoopsIf a step below fails, save the error as noTextErrorIf a step below fails, save the error as noTextError
Try
TextTrim message.text and save it as messageText.Trim message.text and save it as messageText.
On error
ValuesShow in the output: This message carried no text, so there was nothing to mark..Show in the output: This message carried no text, so there was nothing to mark..
Decisions & LoopsIf messageText is emptyIf messageText is empty
Yes
Decisions & LoopsFinish the run: This message carried no text, so nothing was asked or marked.Finish the run: This message carried no text, so nothing was asked or marked.
No
No steps
TextSplit messageText by a space and save it as words.Split messageText by a space and save it as words.
TextMake the first item of words[0] split by @ lowercase and save it as command.Make the first item of words[0] split by @ lowercase and save it as command.
TextTrim the items from index 1 onward of words joined by a space and save it as rest.Trim the items from index 1 onward of words joined by a space and save it as rest.
Decisions & LoopsIf command is not /quiz and command is not /answerIf command is not /quiz and command is not /answer
Yes
Decisions & LoopsIf messageText starts with / (ignoring case)If messageText starts with / (ignoring case)
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I drill you on the words in your vocabulary sheet. /quiz - I pick a word from your sheet and ask it /answer <word> = <what you think it means> - I mark it against your sheet
No
No steps
Decisions & LoopsFinish the run: This message was not a /quiz or /answer command, so nothing was marked.Finish the run: This message was not a /quiz or /answer command, so nothing was marked.
No
No steps
ValuesSet sheetData to nothing.Set sheetData to nothing.
ValuesSet readFailed to false.Set readFailed to false.
Decisions & LoopsIf a step below fails, save the error as readErrorIf a step below fails, save the error as readError
Try
Google SheetsGoogle SheetsRead the rows of vocabSheetUrl. Save it as sheetData.Read the rows of vocabSheetUrl. Save it as sheetData.
On error
ValuesChange readFailed to true.Change readFailed to true.
Decisions & LoopsIf readFailed is yesIf readFailed is yes
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not read your vocabulary sheet just now, so nothing was asked or marked. Try again in a moment.
Decisions & LoopsStop and report a problem: The vocabulary sheet could not be read.Stop and report a problem: The vocabulary sheet could not be read.
No
No steps
ValuesSet vocabRows to sheetData.rows.Set vocabRows to sheetData.rows.
Decisions & LoopsIf command is /quizIf command is /quiz
Yes
ValuesSet askable to an empty list.Set askable to an empty list.
Decisions & LoopsFor each vocabRow in vocabRows:For each vocabRow in vocabRows:
Decisions & Loops If a step below fails, save the error as termError If a step below fails, save the error as termError
Try
TextTrim vocabRow.Term and save it as term.Trim vocabRow.Term and save it as term.
TextTrim vocabRow.Answer and save it as meaning.Trim vocabRow.Answer and save it as meaning.
Decisions & LoopsIf term isn't empty and meaning isn't emptyIf term isn't empty and meaning isn't empty
Yes
ListsAdd term to the end of askable and save it as askable.Add term to the end of askable and save it as askable.
No
No steps
On error
ValuesShow in the output: Skipped a row missing its Term or Answer column..Show in the output: Skipped a row missing its Term or Answer column..
Decisions & LoopsIf askable is emptyIf askable is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not find anything to ask you. The tab needs a Term column and an Answer column, with a heading row, and at least one row filled in on both.
Decisions & LoopsFinish the run: The vocabulary sheet held no complete rows.Finish the run: The vocabulary sheet held no complete rows.
No
No steps
ListsGet the first item of 1 random items from askable and save it as askedWord.Get the first item of 1 random items from askable and save it as askedWord.
ValuesSet quizLine to Your word: askedWord.Set quizLine to Your word: askedWord.
ValuesSet quizHow to Set quizHow to When you have an answer, send: /answer askedWord = your answer.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.quizLine plus quizHow
Decisions & LoopsFinish the run: Asked one word from the sheet.Finish the run: Asked one word from the sheet.
No
Decisions & LoopsIf rest doesn't contain =If rest doesn't contain =
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Send it as /answer <word> = <what you think it means>, for example: /answer ephemeral = lasting a very short time
Decisions & LoopsFinish the run: The /answer command was not in the word = answer shape.Finish the run: The /answer command was not in the word = answer shape.
No
No steps
TextSplit rest by = and save it as halves.Split rest by = and save it as halves.
TextTrim halves[0] and save it as askedTerm.Trim halves[0] and save it as askedTerm.
TextTrim the items from index 1 onward of halves joined by = and save it as learnerAnswer.Trim the items from index 1 onward of halves joined by = and save it as learnerAnswer.
Decisions & LoopsIf askedTerm is empty or learnerAnswer is emptyIf askedTerm is empty or learnerAnswer is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Send it as /answer <word> = <what you think it means>, for example: /answer ephemeral = lasting a very short time
Decisions & LoopsFinish the run: The /answer command was missing the word or the answer.Finish the run: The /answer command was missing the word or the answer.
No
No steps
ValuesSet sheetAnswers to an empty list.Set sheetAnswers to an empty list.
Decisions & LoopsFor each vocabRow in vocabRows:For each vocabRow in vocabRows:
Decisions & Loops If a step below fails, save the error as matchError If a step below fails, save the error as matchError
Try
TextTrim vocabRow.Term and save it as term.Trim vocabRow.Term and save it as term.
TextTrim vocabRow.Answer and save it as meaning.Trim vocabRow.Answer and save it as meaning.
Decisions & LoopsIf term in lowercase is askedTerm in lowercase and meaning isn't emptyIf term in lowercase is askedTerm in lowercase and meaning isn't empty
Yes
ListsAdd meaning to the end of sheetAnswers and save it as sheetAnswers.Add meaning to the end of sheetAnswers and save it as sheetAnswers.
No
No steps
On error
ValuesShow in the output: Skipped a row missing its Term or Answer column..Show in the output: Skipped a row missing its Term or Answer column..
Decisions & LoopsIf sheetAnswers is emptyIf sheetAnswers is empty
Yes
ValuesSet notOnList to “@askedTerm” is not on your list, so I have nothing to mark it against. Send /quiz for a word that is.Set notOnList to “@askedTerm” is not on your list, so I have nothing to mark it against. Send /quiz for a word that is.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.notOnList
Decisions & LoopsFinish the run: That word is not in the sheet.Finish the run: That word is not in the sheet.
No
No steps
ListsGet the first item of sheetAnswers and save it as statedAnswer.Get the first item of sheetAnswers and save it as statedAnswer.
ValuesSet matchesTheSheet to false.Set matchesTheSheet to false.
Decisions & LoopsFor each sheetAnswer in sheetAnswers:For each sheetAnswer in sheetAnswers:
Decisions & Loops If sheetAnswer in lowercase is learnerAnswer in lowercase If sheetAnswer in lowercase is learnerAnswer in lowercase
Yes
ValuesChange matchesTheSheet to true.Change matchesTheSheet to true.
No
No steps
Decisions & LoopsIf matchesTheSheet is yesIf matchesTheSheet is yes
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Correct. Your sheet gives that as the answer for “@askedTerm”.
Decisions & LoopsFinish the run: Answer matched the sheet exactly.Finish the run: Answer matched the sheet exactly.
No
No steps
ValuesSet markPrompt to You are marking one vocabulary answer. Reply with exactly one word: SAME if the learner's answer means the same as the expected answer, or DIFFERENT if it does not. Do not explain and do not add anything else..Set markPrompt to You are marking one vocabulary answer. Reply with exactly one word: SAME if the learner's answer means the same as the expected answer, or DIFFERENT if it does not. Do not explain and do not add anything else..
ValuesSet markDetail to Set markDetail to Word: askedTerm Expected answer: statedAnswer.
ValuesSet markLearner to Set markLearner to Learner's answer: learnerAnswer.
ValuesSet verdict to blank.Set verdict to blank.
ValuesSet markFailed to false.Set markFailed to false.
Decisions & LoopsIf a step below fails, save the error as markErrorIf a step below fails, save the error as markError
Try
OpenAIOpenAIAsk OpenAI: '@markPrompt plus markDetail plus markLearner'. Save it as marking.Ask OpenAI: '@markPrompt plus markDetail plus markLearner'. Save it as marking.
TextTrim marking.response_text and save it as verdict.Trim marking.response_text and save it as verdict.
On error
ValuesChange markFailed to true.Change markFailed to true.
ValuesSet sheetSays to Your sheet says: “@statedAnswer”.Set sheetSays to Your sheet says: “@statedAnswer”.
Decisions & LoopsIf markFailed is yesIf markFailed is yes
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not check that one, so I am not marking it either way. sheetSays
Decisions & LoopsFinish the run: The wording check did not come back.Finish the run: The wording check did not come back.
No
No steps
Decisions & LoopsIf verdict starts with same (ignoring case)If verdict starts with same (ignoring case)
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Correct - not word for word, but it means the same. sheetSays
Decisions & LoopsFinish the run: Answer accepted as meaning the same.Finish the run: Answer accepted as meaning the same.
Else if @verdict starts with "different" (ignoring case)
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Not quite. sheetSays
Decisions & LoopsFinish the run: Answer did not match the sheet.Finish the run: Answer did not match the sheet.
Otherwise
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not check that one, so I am not marking it either way. sheetSays
Decisions & LoopsFinish the run: The wording check came back in an unusable shape.Finish the run: The wording check came back in an unusable shape.