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

docs: Consider using the bolt-python Block Kit wrapper classes instead of JSON #1139

Closed
filmaj opened this issue Aug 27, 2024 · 4 comments
Closed
Labels
area:examples issues related to example or sample code auto-triage-stale docs Improvements or additions to documentation

Comments

@filmaj
Copy link
Contributor

filmaj commented Aug 27, 2024

A developer on the Community Workspace noted that some of our docs use example Block Kit JSON payloads, while bolt-py provides helper wrapper classes for modeling Block Kit that may provide a better authoring experience.

Example here: https://slack.dev/bolt-python/concepts/shortcuts/ is:

@app.shortcut("open_modal")
def open_modal(ack, shortcut, client):
    # Acknowledge the shortcut request
    ack()
    # Call the views_open method using the built-in WebClient
    client.views_open(
        trigger_id=shortcut["trigger_id"],
        # A simple view payload for a modal
        view={
            "type": "modal",
            "title": {"type": "plain_text", "text": "My App"},
            "close": {"type": "plain_text", "text": "Close"},
            "blocks": [ ... ]
        }
    )

but perhaps that could be replaced with:

View(
    type="modal",
    callback_id="modal-id",
    title=PlainTextObject(text="My App"),
    close=PlainTextObject(text="Close"),
    blocks=[ ... ]
)

The page URLs

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@filmaj filmaj added docs Improvements or additions to documentation area:examples issues related to example or sample code labels Aug 27, 2024
@seratch
Copy link
Member

seratch commented Aug 27, 2024

@filmaj Thanks for creating this issue.

I personally don't think we should replace it. Having the dict data structure can still be beneficial as it's easier to convert JSON data in Block Kit Builder into dict objects. If the documents only encourage the class-based ones, first-time developers could be confused by the difference between the api.slack.com documents and the bolt-python docs. If we add equivalent ones using classes rather than replacing the current ones, it might be helpful for developers who prefer using classes.

The only exception is bolt-java. Java doesn't provide a handy way to describe Map (dict in Python; objects in JS) data structures, unlike TS and Python. Thus, it's straightforward to ask developers to use classes and their factories and/or Kotlin DSLs.

@filmaj
Copy link
Contributor Author

filmaj commented Aug 27, 2024

Ah yes good point @seratch ! Perhaps our documents in Bolt-Python should provide examples in both dict data structure style as well as the slack sdk models? Not sure. I think it's something to discuss with our colleagues in devrel education cc @lukegalbraithrussell

Copy link

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

Copy link

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:examples issues related to example or sample code auto-triage-stale docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants