Get chat message
Read the text of a message in a chat app open in a tab, and wait for one to arrive.
Only in
WarpX Browser
Some sites send what you need — a code, a link, a confirmation — to a chat account rather than to a mailbox. If the person is already signed in to that chat in another tab, this block reads it there, the way they would read it themselves. It reads and nothing else: it never signs in, never sends, and never opens a conversation, so the right one has to be on screen already. What it hands on is the message's whole text; pulling a code or a link out of that is RegEx variable's job afterwards, which is why there is nothing about codes here. Where the message arrives by e-mail instead, Read email reads the mailbox itself over IMAP and is the better tool for it.
Settings
- Chat app
Telegram, Discord, Google Chat, Gmail, Zalo, Instagram, Facebook Messenger, or Custom. It is a preset rather than a different way of reading: choosing one fills in which tabs the app lives in, which elements hold one message each, and which end of its list the newest one is at. All three stay editable — these are other people's web apps, and a class name that works today is one release away from not working.
ExampleTelegram- Source tab
A match pattern, one per line. Empty uses the app's own, which the field shows as its placeholder; where the app has none, or where the workflow has already opened the chat itself, empty means the tab the workflow is on. The tab has to be open and signed in already.
Examplehttps://web.telegram.org/*- Messages
The elements holding one message each. Empty uses the app's own. For Google Chat, Zalo, Instagram and Messenger there is no default: their markup carries nothing stable enough to guess at, so pick a message with the element picker — a guess that silently matched nothing would be worse than an empty field. When a default stops matching, the same picker fixes it without waiting for a new build.
Example.message .text-content- Newest message iswhen Chat app is Custom
Which end of the list to read first. A conversation puts the newest at the bottom; a mailbox puts it at the top. Every named app already knows its own, so this is only asked for Custom.
ExampleAt the bottom (a conversation)- Message must match
A regular expression, or plain words. Empty takes the newest message whatever it says. This is a filter and nothing more — what comes out is the text, not a piece of it.
Exampleverification code- Only messages that arrive from now on
Takes a snapshot of what is on screen when the block starts and ignores all of it, so what comes back is something that arrived while it waited. Off, a message already there that matches is a perfectly good answer — which is right for reading the last thing said, and wrong for waiting for something to turn up.
ExampleChecked- Wait up to (ms)
How long to keep looking. The tab is read again every half second until then — not a setting, because half a second is quick enough that nobody notices and slow enough that a long wait is tens of reads rather than hundreds. 0 looks once and leaves by the fallback output if there is nothing there.
Example30000- Bring the chat's tab forward while reading
Some chats only fetch what is pending for the tab in front, so a message sits unseen until its tab is looked at. Whatever was in front before is put back once the block is done, so the blocks after it find the page they expect.
ExampleUnchecked
Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.
What it hands on
The message's text, with runs of whitespace collapsed. It goes to the variable or column you chose, and on as {{prevBlockData}}. No matching tab, and no message within the wait, leave by the fallback output.
Example: Take a code out of a Telegram chat and type it
- Forms
- Get chat message
- Regex variable
- Forms
- Open the chat in a second tab of the same profile, signed in, with the right conversation showing.
- After the password step, add Get chat message, leave the app as Telegram, and put the words the message always contains in Message must match.
- Tick Assign to variable and name it
chatMessage. - Add Regex variable on
chatMessagewith an expression like\d{6}to get the code out. - Follow it with Forms typing that variable into the page's field.
Good to know
- It does not open a conversation. If the tab is showing a different one, the message is not in the page at all — put a Click element on the conversation before this block.
- Telegram and some others only keep the visible part of a long conversation in the page, so only the recent end of it can be read. A message that has just arrived is at that end.
- Where an app gives each message an id of its own — Discord and Telegram do — two messages that read the same are still two messages. Where it does not, the text stands in for the id, and a message repeated word for word reads as the one already seen.
- On Gmail, the list shows the sender, the subject and a snippet; a code further into the body is not in the page until the mail is opened. Over IMAP, Read email has the whole body, real timestamps and the real unread flag — prefer it for a mailbox.
- Nothing is remembered between runs. Two profiles signing in at the same moment through one shared chat account can both read the same message — give each its own account, or sequence them.
See also
- RegEx variable — Replace a text variable with what a regular expression matches, or with a replaced version.
- Read email — Wait for an email in a mailbox and take the code, the link or the text out of it.
- Switch tab — Move the run to another open tab, found by its address, its title or its position.
- Get text — Read the text of one element or many, and save it to the table or a variable.