Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_blocks error when using type rich_text #1527

Closed
1 task done
marcopiii opened this issue Aug 31, 2022 · 8 comments
Closed
1 task done

invalid_blocks error when using type rich_text #1527

marcopiii opened this issue Aug 31, 2022 · 8 comments
Labels
pkg:web-api applies to `@slack/web-api` question M-T: User needs support to use the project

Comments

@marcopiii
Copy link

Packages:

  • @slack/web-api

Reproducible in:

The Slack SDK version

"slack/web-api": "^6.7.2",
"slack/logger": "^3.0.0",
"slack/types": "^2.7.0",

Node.js runtime version

v12.22.10

OS info

ProductName:	macOS
ProductVersion:	12.2.1
BuildVersion:	21D62
Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64

Steps to reproduce:

slackWebClient.chat.postMessage({
    channel: "ABC123",
    blocks: [{
        "type": "rich_text",
        "elements": [{
            "type": "rich_text_list",
            "elements": [{
                    "type": "rich_text_section",
                    "elements": [{
                        "type": "text",
                        "text": "First"
                    }]
                },
                {
                    "type": "rich_text_section",
                    "elements": [{
                        "type": "text",
                        "text": "Second"
                    }]
                }
            ],
            "style": "bullet",
            "indent": 0
        }]
    }],
});

Expected result:

I would expect this to work since in the Slack Block Kit Builder it seems a legit block

Actual result:

Error: An API error occurred: invalid_blocks
@srajiang
Copy link
Contributor

Hey @marcopiii - When I put those blocks you supplied into block kit builder, I get a type error, so I'm curious whether there's a version of the sample you provided that block kit builder accepts, or what you're referencing that refers to rich_text and rich_text_list

Based on this there is plain_text and mrkdwn as supported types for text.

@marcopiii
Copy link
Author

marcopiii commented Aug 31, 2022

I'm can't see any reference to a version of the tool. If it can be useful this is the exact fragment that should allow you to recreate the same block

#%7B"blocks":%5B%7B"type":"rich_text","elements":%5B%7B"type":"rich_text_list","elements":%5B%7B"type":"rich_text_section","elements":%5B%7B"type":"text","text":"First"%7D%5D%7D,%7B"type":"rich_text_section","elements":%5B%7B"type":"text","text":"Second"%7D%5D%7D%5D,"style":"bullet","indent":0%7D%5D%7D%5D%7D

and this is the preview

Schermata 2022-08-31 alle 20 48 14

Based on this there is plain_text and mrkdwn as supported types for text.

yes, I saw the supported types and i tried to cast it with an any to make it compile in case it was some kind of "hide" feature but that's not the case.
It seems there is a discrepancy between the preview tool and the API.

@seratch seratch added question M-T: User needs support to use the project pkg:web-api applies to `@slack/web-api` and removed untriaged labels Aug 31, 2022
@seratch
Copy link
Member

seratch commented Aug 31, 2022

@marcopiii Unfortunately, "rich_text" blocks are unavailable for 3rd party Slack apps. Only Slack client apps (Desktop/Web/iOS/Android) can send those blocks to Slack API servers. Block Kit Builder may work with more blocks like you've observed because the tool can be used for crafting a human message too (You can find "Send to Slack" button).

Thus, please go with the blocks listed here instead.

@marcopiii
Copy link
Author

@seratch thank you for the clarification 🙏

A bit off-topic but, is there any other way to represent a real bullet point list for a 3rd part app (I mean, besides using some visual trick like characters)? It looks like - doesn't work in the markdown block.

@seratch
Copy link
Member

seratch commented Sep 1, 2022

@marcopiii I see your point here very well ... but

using some visual trick like • characters

this is the only way to list items in Slack text messages 🙇

If everything is clear now, would you mind closing this issue?

@vvo
Copy link

vvo commented Oct 27, 2023

@seratch

Unfortunately, "rich_text" blocks are unavailable for 3rd party Slack apps.

Is that still true? I mean, I can definitely craft API requests to send rich_text blocks and it just works

@seratch
Copy link
Member

seratch commented Oct 27, 2023

@vvo Great question! Almost a month ago, the platform unlocked the feature to 3rd party apps, so as you've noticed, you can now use rich_text blocks in a message and modal inputs!

See also:

@vvo
Copy link

vvo commented Oct 29, 2023

Nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:web-api applies to `@slack/web-api` question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

4 participants