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

How to create canvas using models? #1650

Open
primko opened this issue Feb 4, 2025 · 1 comment
Open

How to create canvas using models? #1650

primko opened this issue Feb 4, 2025 · 1 comment
Labels
question M-T: User needs support to use the project Version: 3x web-client

Comments

@primko
Copy link

primko commented Feb 4, 2025

The Slack SDK version

"slack-sdk>=3.34.0"

Python runtime version

Python 3.12.3

OS info

ProductName: macOS
ProductVersion: 14.5
BuildVersion: 23F79
Darwin Kernel Version 23.5.0: Wed May 1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020

How to create canvas using models?

block1 = SectionBlock(text="foo")
block2 = SectionBlock(text="bar")

canvas_blocks=View(blocks=[block1, block2], type="modal").to_dict() 

slack_client.canvases_create(title="debug", document_content=canvas_blocks)

I understand that View is not related to canvases, but it creates the required structure except for the type. How should the structure be correctly created from blocks, and how should the blocks[...] structure itself be passed if View is not used?

Currently, I am getting the following error:

'response_metadata': {'messages': ['[ERROR] failed to match exactly one allowed schema [json-pointer:/document_content]']}

This error does not provide specific information about what exactly is wrong.

@primko primko changed the title (Set a clear title describing your question) How to create canvas using models? Feb 4, 2025
@seratch seratch added question M-T: User needs support to use the project web-client Version: 3x and removed untriaged labels Feb 5, 2025
@seratch
Copy link
Member

seratch commented Feb 5, 2025

Hi @primko, thanks for asking the question!

Unfortunately, the public APIs do not support view objects and its block kit components for building a canvas document content as of today. Instead, you can pass a standard markdown text data like this e2e test code does: https://github.com/slackapi/python-slack-sdk/blob/main/integration_tests/web/test_canvases.py

I hope this was helpful to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project Version: 3x web-client
Projects
None yet
Development

No branches or pull requests

2 participants