Question about how to parse blocks in a message easily
The complexity of getting messages' text and type using java sdk is high . I want to get the type and text that are in the blocks key. Is there any sample code to do it using SDK. I tried below but I believe this isn't a feasible apporach.
Hi, the rich_text type blocks were added for Slack's WYSIWYG editor support. So, for most 3rd party apps, they are not useful. Refer to the following guide if you're interested in the details of rick_text blocks.
https://api.slack.com/changelog/2019-09-what-they-see-is-what-you-get-and-more-and-less
From a 3rd party app perspective, using text field (message.getText() in your code) would be an easier and more relevant approach for reacting incoming messages.
If your app composes a message with common types of blocks you can find here, you may check what the blocks in a message are. For such use cases, there is no way to parse them without checking their types and casting to their concrete types as you're doing.
Thanks