People opt in with /subscribe, their chat is kept in Baserow, and your /announce goes out to all of them at once.

UsesBaserowTelegram

Announce to everyone who subscribed on Telegram

Whenever someone messages your Telegram bot, the workflow looks for one of three commands. A /subscribe sent in a private chat adds that person to a Baserow table, /unsubscribe removes them straight away, and /announce from you sends whatever you typed after it to everyone on the table, each in their own chat with the bot. Any other message is left alone.

Your announcement goes out word for word, with one fixed line under it telling people how to unsubscribe, and no AI touches it. Only you can send one, and only from a direct message, so an /announce typed by anyone else is refused. A /subscribe from a group chat is refused rather than signing up the whole group. A chat stored twice is messaged once, one run reaches a limited number of people, and you get a report saying how many were reached and how many could not be delivered.

Before the first run you need a Telegram bot and a Baserow table with three columns named 'ChatId', 'Name' and 'Subscribed'.

TelegramTelegramWhen a new message is received. Save it as message.When a new message is received. Save it as message.
ValuesSet subscriberTableId to blank.Set subscriberTableId to blank.
ValuesSet ownerUserId to blank.Set ownerUserId to blank.
ValuesSet maxRecipients to 50.Set maxRecipients to 50.
MathSet recipientCap to maxRecipients multiplied by 1.Set recipientCap to maxRecipients multiplied by 1.
Decisions & LoopsIf recipientCap is less than 1If recipientCap is less than 1
Yes
Decisions & LoopsStop and report a problem: Set 'maxRecipients' to 1 or more - it is the most people one announcement can reach in a single run.Stop and report a problem: Set 'maxRecipients' to 1 or more - it is the most people one announcement can reach in a single run.
No
No steps
TextTrim message.chat_id and save it as chatId.Trim message.chat_id and save it as chatId.
TextTrim message.from_user_id and save it as senderId.Trim message.from_user_id and save it as senderId.
ValuesSet isDirectMessage to chatId is senderId and senderId is not null.Set isDirectMessage to chatId is senderId and senderId is not null.
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 do..Show in the output: This message carried no text, so there was nothing to do..
Decisions & LoopsIf messageText is emptyIf messageText is empty
Yes
Decisions & LoopsFinish the run: This message carried no text, so nobody was added, removed or sent to.Finish the run: This message carried no text, so nobody was added, removed or sent to.
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 /subscribe and command is not /unsubscribe and command is…If command is not /subscribe and command is not /unsubscribe and command is…
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./subscribe - start getting announcements (message me directly) /unsubscribe - stop getting them
No
No steps
Decisions & LoopsFinish the run: This message was not a /subscribe, /unsubscribe or /announce command, so nobody was added, removed or sent to.Finish the run: This message was not a /subscribe, /unsubscribe or /announce command, so nobody was added, removed or sent to.
No
No steps
ValuesSet listPage to nothing.Set listPage 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
BaserowBaserowList rows in table subscriberTableId. Save it as listPage.List rows in table subscriberTableId. Save it as listPage. Rows per page: 200
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 reach the subscriber list just now, so nothing was changed and nothing was sent. Try again in a moment.
Decisions & LoopsStop and report a problem: The subscriber list could not be read.Stop and report a problem: The subscriber list could not be read.
No
No steps
ValuesSet storedRows to listPage.results.Set storedRows to listPage.results.
MathSet storedTotal to listPage.count multiplied by 1.Set storedTotal to listPage.count multiplied by 1.
ValuesSet storedIds to an empty list.Set storedIds to an empty list.
ValuesSet myRowIds to an empty list.Set myRowIds to an empty list.
Decisions & LoopsFor each storedRow in storedRows:For each storedRow in storedRows:
Decisions & LoopsIf a step below fails, save the error as rowErrorIf a step below fails, save the error as rowError
Try
TextTrim storedRow.ChatId and save it as storedId.Trim storedRow.ChatId and save it as storedId.
Decisions & LoopsIf storedId isn't empty and storedId is not nullIf storedId isn't empty and storedId is not null
Yes
ListsAdd storedId to the end of storedIds and save it as storedIds.Add storedId to the end of storedIds and save it as storedIds.
Decisions & LoopsIf storedId is senderIdIf storedId is senderId
Yes
ListsAdd storedRow.id to the end of myRowIds and save it as myRowIds.Add storedRow.id to the end of myRowIds and save it as myRowIds.
No
No steps
No
No steps
On error
ValuesShow in the output: Skipped a subscriber row with no chat ID in it..Show in the output: Skipped a subscriber row with no chat ID in it..
Decisions & LoopsIf command is /subscribeIf command is /subscribe
Yes
Decisions & LoopsIf isDirectMessage is noIf isDirectMessage is no
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Message me directly to subscribe - open a one-to-one chat with me and send /subscribe there. Subscribing from a group would sign the whole group up, so I do not do it.
Decisions & LoopsFinish the run: A /subscribe from a group chat was refused.Finish the run: A /subscribe from a group chat was refused.
No
No steps
Decisions & LoopsIf myRowIds isn't emptyIf myRowIds isn't empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.You are already on the list, so I have not added you again. Send /unsubscribe whenever you want to stop.
Decisions & LoopsFinish the run: That chat was already subscribed.Finish the run: That chat was already subscribed.
No
No steps
ValuesSet subscriberName to unknown.Set subscriberName to unknown.
Decisions & LoopsIf a step below fails, save the error as noNameErrorIf a step below fails, save the error as noNameError
Try
TextTrim message.from_username and save it as subscriberName.Trim message.from_username and save it as subscriberName.
On error
ValuesShow in the output: This subscriber has no Telegram username..Show in the output: This subscriber has no Telegram username..
ValuesSet joinFailed to false.Set joinFailed to false.
Decisions & LoopsIf a step below fails, save the error as joinErrorIf a step below fails, save the error as joinError
Try
BaserowBaserowCreate a row in table subscriberTableId.Create a row in table subscriberTableId.
On error
ValuesChange joinFailed to true.Change joinFailed to true.
Decisions & LoopsIf joinFailed is yesIf joinFailed is yes
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not add you to the list, so you are not subscribed. Send /subscribe again in a moment.
Decisions & LoopsStop and report a problem: The subscriber row could not be created.Stop and report a problem: The subscriber row could not be created.
No
No steps
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.You are on the list and will get the announcements. Send /unsubscribe at any time to stop - it takes effect straight away.
Decisions & LoopsFinish the run: Subscribed.Finish the run: Subscribed.
Else if @command is "/unsubscribe"
Decisions & LoopsIf myRowIds is emptyIf myRowIds is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.You are not on the list, so there is nothing to stop. You will not get any announcements.
Decisions & LoopsFinish the run: That chat was not subscribed.Finish the run: That chat was not subscribed.
No
No steps
ValuesSet removed to 0.Set removed to 0.
ValuesSet removeFailed to false.Set removeFailed to false.
Decisions & LoopsFor each myRowId in myRowIds:For each myRowId in myRowIds:
Decisions & Loops If a step below fails, save the error as removeError If a step below fails, save the error as removeError
Try
BaserowBaserowDelete row myRowId from table subscriberTableId.Delete row myRowId from table subscriberTableId.
ValuesAdd 1 to removed.Add 1 to removed.
On error
ValuesChange removeFailed to true.Change removeFailed to true.
Decisions & LoopsIf removeFailed is yesIf removeFailed is yes
Yes
Decisions & LoopsIf removed is 0If removed is 0
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not take you off the list, so you are still subscribed. Send /unsubscribe again in a moment.
Decisions & LoopsStop and report a problem: No subscriber row could be deleted.Stop and report a problem: No subscriber row could be deleted.
No
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I took you off the list, but one of your entries would not delete, so you may still get an announcement. Send /unsubscribe again to clear it.
Decisions & LoopsStop and report a problem: Only some subscriber rows could be deleted.Stop and report a problem: Only some subscriber rows could be deleted.
No
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.You are off the list. You will not get any more announcements. Send /subscribe if you change your mind.
Decisions & LoopsFinish the run: Unsubscribed.Finish the run: Unsubscribed.
Otherwise
Decisions & LoopsIf senderId is not ownerUserId or senderId is nullIf senderId is not ownerUserId or senderId is null
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Only the owner of this list can send an announcement, so nothing was sent.
Decisions & LoopsFinish the run: An /announce from someone other than the owner was refused.Finish the run: An /announce from someone other than the owner was refused.
No
No steps
Decisions & LoopsIf isDirectMessage is noIf isDirectMessage is no
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Send /announce in a direct message to me rather than in a group. Nothing was sent.
Decisions & LoopsFinish the run: An /announce sent from a group chat was refused.Finish the run: An /announce sent from a group chat was refused.
No
No steps
Decisions & LoopsIf rest is emptyIf rest is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Write the announcement after /announce. Nothing was sent.
Decisions & LoopsFinish the run: The /announce command had nothing after it.Finish the run: The /announce command had nothing after it.
No
No steps
ListsRemove duplicates from storedIds and save it as uniqueIds.Remove duplicates from storedIds and save it as uniqueIds.
Decisions & LoopsIf uniqueIds is emptyIf uniqueIds is empty
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Nobody has subscribed yet, so nothing was sent.
Decisions & LoopsFinish the run: The subscriber list is empty.Finish the run: The subscriber list is empty.
No
No steps
ListsTake the first recipientCap items of uniqueIds and save it as recipients.Take the first recipientCap items of uniqueIds and save it as recipients.
ValuesSet announcement to restSet announcement to rest --- You are getting this because you subscribed. Send /unsubscribe to stop.
ValuesSet sentCount to 0.Set sentCount to 0.
ValuesSet failedCount to 0.Set failedCount to 0.
Decisions & LoopsFor each recipientId in recipients:For each recipientId in recipients:
Decisions & Loops If a step below fails, save the error as sendError If a step below fails, save the error as sendError
Try
TelegramTelegramSend a message to chat recipientId.Send a message to chat recipientId.announcement
ValuesAdd 1 to sentCount.Add 1 to sentCount.
On error
ValuesAdd 1 to failedCount.Add 1 to failedCount.
ValuesSet report to Sent to sentCount as text of the length of uniqueIds as text subscribers.Set report to Sent to sentCount as text of the length of uniqueIds as text subscribers.
Decisions & LoopsIf failedCount is greater than 0If failedCount is greater than 0
Yes
ValuesChange report to report failedCount as text could not be delivered.Change report to report failedCount as text could not be delivered.
No
No steps
Decisions & LoopsIf the length of uniqueIds is greater than the length of recipientsIf the length of uniqueIds is greater than the length of recipients
Yes
ValuesChange report to report The 'maxRecipients' cap stopped it at the length of recipients as text - raise the cap and send it again to reach the rest, but the ones already reached will get it a second time.Change report to report The 'maxRecipients' cap stopped it at the length of recipients as text - raise the cap and send it again to reach the rest, but the ones already reached will get it a second time.
No
No steps
Decisions & LoopsIf storedTotal is greater than 200If storedTotal is greater than 200
Yes
ValuesChange report to report Your table holds more than the 200 rows one read returns, so the rest were not considered.Change report to report Your table holds more than the 200 rows one read returns, so the rest were not considered.
No
No steps
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.report