Add, list and tick off Google Tasks by sending /add, /list and /done to your Telegram bot.

UsesGoogle TasksTelegram

Run your Google Tasks list from Telegram

TelegramTelegramWhen a new message is received. Save it as incomingMessage.When a new message is received. Save it as incomingMessage.
ValuesSet taskListName to blank.Set taskListName to blank.
ValuesSet maxTasksListed to 20.Set maxTasksListed to 20.
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 incomingMessage.text and save it as messageText.Trim incomingMessage.text and save it as messageText.
On error
No steps
Decisions & LoopsIf messageText is emptyIf messageText is empty
Yes
Decisions & LoopsFinish the run: That message carried no text, so there was no command in it.Finish the run: That message carried no text, so there was no command in it.
No
No steps
Decisions & LoopsIf messageText doesn't start with /If messageText doesn't start with /
Yes
Decisions & LoopsFinish the run: That message was not a command, so it was left alone. Commands start with a slash: /add, /list or /done.Finish the run: That message was not a command, so it was left alone. Commands start with a slash: /add, /list or /done.
No
No steps
ValuesSet chatId to incomingMessage.chat_id.Set chatId to incomingMessage.chat_id.
TextSplit messageText by a space and save it as words.Split messageText by a space and save it as words.
ListsGet the first item of words and save it as firstWord.Get the first item of words and save it as firstWord.
TextMake the first item of firstWord split by @ lowercase and save it as command.Make the first item of firstWord split by @ lowercase and save it as command.
TextReplace / with in command and save it as verb.Replace / with in command and save it as verb.
TextTrim the items from index 1 onward of words joined by a space and save it as commandArgument.Trim the items from index 1 onward of words joined by a space and save it as commandArgument.
ValuesSet isKnownCommand to verb is add or verb is list or verb is done.Set isKnownCommand to verb is add or verb is list or verb is done.
Decisions & LoopsIf isKnownCommand is noIf isKnownCommand is no
Yes
ValuesSet helpIntro to:Set helpIntro to:I look after your Google Tasks list. Send me one of these:
ValuesSet helpAdd to:Set helpAdd to:/add Call the dentist adds a task
ValuesSet helpList to:Set helpList to:/list shows what is still open, with each task's ID
ValuesSet helpDone to:Set helpDone to:/done Call the dentist ticks off the open task with exactly that name
ValuesSet helpNote to If two open tasks share a name I will not guess between them - send /done with the ID from /list instead..Set helpNote to If two open tasks share a name I will not guess between them - send /done with the ID from /list instead..
MathSet helpText to helpIntro plus helpAdd plus helpList plus helpDone plus helpNote.Set helpText to helpIntro plus helpAdd plus helpList plus helpDone plus helpNote.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.helpText
Decisions & LoopsFinish the run: The message was not one of /add, /list or /done, so the chat was sent the list of commands.Finish the run: The message was not one of /add, /list or /done, so the chat was sent the list of commands.
No
No steps
Google TasksGoogle TasksList lists. Save it as taskListsResult.List lists. Save it as taskListsResult.
ValuesSet taskLists to taskListsResult.task_lists.Set taskLists to taskListsResult.task_lists.
TextMake taskListName lowercase and save it as wantedList.Make taskListName lowercase and save it as wantedList.
ValuesSet taskListId to blank.Set taskListId to blank.
ValuesSet knownListNames to an empty list.Set knownListNames to an empty list.
Decisions & LoopsFor each taskList in taskLists:For each taskList in taskLists:
ValuesSet candidateListName to blank.Set candidateListName to blank.
Decisions & LoopsIf a step below fails, save the error as listNameErrorIf a step below fails, save the error as listNameError
Try
TextTrim taskList.title and save it as candidateListName.Trim taskList.title and save it as candidateListName.
On error
No steps
Decisions & LoopsIf candidateListName isn't emptyIf candidateListName isn't empty
Yes
ListsAdd candidateListName to the end of knownListNames and save it as knownListNames.Add candidateListName to the end of knownListNames and save it as knownListNames.
Decisions & LoopsIf candidateListName in lowercase is wantedList and taskListId is emptyIf candidateListName in lowercase is wantedList and taskListId is empty
Yes
Decisions & LoopsIf a step below fails, save the error as listIdErrorIf a step below fails, save the error as listIdError
Try
TextTrim taskList.id and save it as taskListId.Trim taskList.id and save it as taskListId.
On error
No steps
No
No steps
No
No steps
Decisions & LoopsIf taskListId is emptyIf taskListId is empty
Yes
TextJoin knownListNames with , and save it as knownLists.Join knownListNames with , and save it as knownLists.
ValuesSet noListText to I could not find a Google Tasks list called '@taskListName'. The lists on this account are: knownLists.Set noListText to I could not find a Google Tasks list called '@taskListName'. The lists on this account are: knownLists.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.noListText
Decisions & LoopsStop and report a problem: No Google Tasks list is named '@taskListName'. Correct the 'taskListName' step to match one of the lists on the account.Stop and report a problem: No Google Tasks list is named '@taskListName'. Correct the 'taskListName' step to match one of the lists on the account.
No
No steps
Decisions & LoopsIf verb is addIf verb is add
Yes
Decisions & LoopsIf commandArgument is emptyIf commandArgument is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Send the task after the command, like this: /add Call the dentist
No
Google TasksGoogle TasksCreate task commandArgument in Google Tasks list taskListId.Create task commandArgument in Google Tasks list taskListId.
ValuesSet addedText to Added to taskListName: commandArgument.Set addedText to Added to taskListName: commandArgument.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.addedText
No
No steps
Decisions & LoopsIf verb is listIf verb is list
Yes
Google TasksGoogle TasksList tasks in Google Tasks list taskListId. Save it as openTasksResult.List tasks in Google Tasks list taskListId. Save it as openTasksResult.
ValuesSet openTasks to openTasksResult.tasks.Set openTasks to openTasksResult.tasks.
ValuesSet openTaskCount to 0.Set openTaskCount to 0.
Decisions & LoopsIf a step below fails, save the error as openCountErrorIf a step below fails, save the error as openCountError
Try
ListsCount the items in openTasks and save it as openTaskCount.Count the items in openTasks and save it as openTaskCount.
On error
No steps
ValuesSet taskLines to an empty list.Set taskLines to an empty list.
ValuesSet listedCount to 0.Set listedCount to 0.
Decisions & LoopsFor each task in openTasks:For each task in openTasks:
Decisions & Loops If listedCount multiplied by 1 is greater than or equal to maxTasksListed… If listedCount multiplied by 1 is greater than or equal to maxTasksListed…
Yes
Decisions & LoopsStop repeating.Stop repeating.
No
No steps
Values Set lineId to blank. Set lineId to blank.
Decisions & Loops If a step below fails, save the error as lineIdError If a step below fails, save the error as lineIdError
Try
TextTrim task.id and save it as lineId.Trim task.id and save it as lineId.
On error
No steps
Values Set lineTitle to blank. Set lineTitle to blank.
Decisions & Loops If a step below fails, save the error as lineTitleError If a step below fails, save the error as lineTitleError
Try
TextTrim task.title and save it as lineTitle.Trim task.title and save it as lineTitle.
On error
No steps
Decisions & Loops If lineId isn't empty If lineId isn't empty
Yes
Decisions & LoopsIf lineTitle is emptyIf lineTitle is empty
Yes
ValuesChange lineTitle to (this task has no title).Change lineTitle to (this task has no title).
No
No steps
ListsAdd lineTitleAdd lineTitle ID: lineId to the end of taskLines and save it as taskLines.
ValuesAdd 1 to listedCount.Add 1 to listedCount.
No
No steps
Decisions & LoopsIf taskLines is emptyIf taskLines is empty
Yes
ValuesSet nothingOpenText to Nothing is open in taskListName right now.Set nothingOpenText to Nothing is open in taskListName right now.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.nothingOpenText
No
ValuesSet listHeading to Open in taskListName:Set listHeading to Open in taskListName: .
TextJoin taskLines with a blank line and save it as listBody.Join taskLines with a blank line and save it as listBody.
ValuesSet listFooter to blank.Set listFooter to blank.
Decisions & LoopsIf openTaskCount multiplied by 1 is greater than listedCount multiplied by 1If openTaskCount multiplied by 1 is greater than listedCount multiplied by 1
Yes
ValuesChange listFooter to Change listFooter to Showing the first listedCount of openTaskCount open tasks.
No
No steps
MathSet listText to listHeading plus listBody plus listFooter.Set listText to listHeading plus listBody plus listFooter.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.listText
No
No steps
Decisions & LoopsIf verb is doneIf verb is done
Yes
Decisions & LoopsIf commandArgument is emptyIf commandArgument is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Say which task to tick off, like this: /done Call the dentist Or send /done with the task's ID from /list.
No
Google TasksGoogle TasksList tasks in Google Tasks list taskListId. Save it as candidateResult.List tasks in Google Tasks list taskListId. Save it as candidateResult.
ValuesSet candidateTasks to candidateResult.tasks.Set candidateTasks to candidateResult.tasks.
TextMake commandArgument lowercase and save it as wantedTask.Make commandArgument lowercase and save it as wantedTask.
ValuesSet matchedIds to an empty list.Set matchedIds to an empty list.
ValuesSet matchedTitles to an empty list.Set matchedTitles to an empty list.
Decisions & LoopsFor each candidate in candidateTasks:For each candidate in candidateTasks:
Values Set candidateId to blank. Set candidateId to blank.
Decisions & Loops If a step below fails, save the error as candidateIdError If a step below fails, save the error as candidateIdError
Try
TextTrim candidate.id and save it as candidateId.Trim candidate.id and save it as candidateId.
On error
No steps
Values Set candidateTitle to blank. Set candidateTitle to blank.
Decisions & Loops If a step below fails, save the error as candidateTitleError If a step below fails, save the error as candidateTitleError
Try
TextTrim candidate.title and save it as candidateTitle.Trim candidate.title and save it as candidateTitle.
On error
No steps
Decisions & Loops If candidateId isn't empty If candidateId isn't empty
Yes
ValuesSet idMatches to candidateId is commandArgument.Set idMatches to candidateId is commandArgument.
ValuesSet titleMatches to the length of candidateTitle is greater than 0 and candidateTitle in lowercase is wantedTask.Set titleMatches to the length of candidateTitle is greater than 0 and candidateTitle in lowercase is wantedTask.
Decisions & LoopsIf idMatches is yes or titleMatches is yesIf idMatches is yes or titleMatches is yes
Yes
ListsAdd candidateId to the end of matchedIds and save it as matchedIds.Add candidateId to the end of matchedIds and save it as matchedIds.
ListsAdd candidateTitle to the end of matchedTitles and save it as matchedTitles.Add candidateTitle to the end of matchedTitles and save it as matchedTitles.
No
No steps
No
No steps
Decisions & LoopsIf matchedIds is emptyIf matchedIds is empty
Yes
ValuesSet noMatchText to Nothing open in taskListName is called '@commandArgument', so nothing was ticked off. Send /list to see what is open.Set noMatchText to Nothing open in taskListName is called '@commandArgument', so nothing was ticked off. Send /list to see what is open.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.noMatchText
No
No steps
Decisions & LoopsIf the length of matchedIds is greater than 1If the length of matchedIds is greater than 1
Yes
TextJoin matchedIds with "Join matchedIds with ID: and save it as ambiguousIds.
ValuesSet ambiguousIntro to More than one open task is called '@commandArgument', so nothing was ticked off.Set ambiguousIntro to More than one open task is called '@commandArgument', so nothing was ticked off.
ValuesSet ambiguousText to ambiguousIntro Send /done with one of these IDs instead:Set ambiguousText to ambiguousIntro Send /done with one of these IDs instead: ID: ambiguousIds.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.ambiguousText
No
No steps
Decisions & LoopsIf the length of matchedIds is 1If the length of matchedIds is 1
Yes
ListsGet the first item of matchedIds and save it as targetId.Get the first item of matchedIds and save it as targetId.
ListsGet the first item of matchedTitles and save it as targetTitle.Get the first item of matchedTitles and save it as targetTitle.
Decisions & LoopsIf targetTitle is emptyIf targetTitle is empty
Yes
ValuesChange targetTitle to targetId.Change targetTitle to targetId.
No
No steps
Google TasksGoogle TasksComplete task targetId in Google Tasks list taskListId.Complete task targetId in Google Tasks list taskListId.
ValuesSet doneText to Ticked off: targetTitle.Set doneText to Ticked off: targetTitle.
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.doneText
No
No steps
No
No steps