Skip to content

feat(models): add BlockChunk type to chat.{start,append,stop}Stream methods#1872

Open
srtaalej wants to merge 1 commit intomainfrom
ale-feat-block-chunks
Open

feat(models): add BlockChunk type to chat.{start,append,stop}Stream methods#1872
srtaalej wants to merge 1 commit intomainfrom
ale-feat-block-chunks

Conversation

@srtaalej
Copy link
Copy Markdown
Contributor

@srtaalej srtaalej commented May 5, 2026

Summary

This PR adds BlocksChunk model class to support the new blocks chunk type in the streaming API (chat.startStream, chat.appendStream, chat.stopStream). Follows the April 16, 2026 changelog which notes updates to the text-streaming API methods to support streaming blocks.

Testing

Sample app.py
from slack_sdk.models.blocks import CardBlock, CarouselBlock                                                                                                                                                                
from slack_sdk.models.messages.chunk import BlocksChunk                                                                                                                                                                     
                                                                                                                                                                                                                              
  streamer = client.chat_stream(                                                                                                                                                                                              
      channel="C0123456789",                                                                                                                                                                                                  
      thread_ts="1700000001.123456",                                                                                                                                                                                          
      recipient_team_id="T0123456789",                                                                                                                                                                                        
      recipient_user_id="U0123456789",                                                                                                                                                                                        
  )                                                                                                                                                                                                                           
                                                                                                                                                                                                                              
  streamer.append(markdown_text="Here's a **card** streamed via `BlocksChunk`:\n\n")                                                                                                                                          
                                                                                                                                                                                                                              
  streamer.append(                                                                                                                                                                                                            
      chunks=[    
          BlocksChunk(                                                                                                                                                                                                        
              blocks=[                                                                                                                                                                                                        
                  CardBlock(                                                                                                                                                                                                  
                      title="Streaming Card",                                                                                                                                                                                 
                      subtitle="Sent via BlocksChunk",                                                                                                                                                                        
                      body="This card was streamed inside a chunks array.",                                                                                                                                                   
                  ),                                                                                                                                                                                                          
              ]                                                                                                                                                                                                               
          ),                                                                                                                                                                                                                  
      ]                                                                                                                                                                                                                       
  )               
                                                                                                                                                                                                                              
  streamer.stop(                                                                                                                                                                                                              
      chunks=[
          BlocksChunk(                                                                                                                                                                                                        
              blocks=[                                                                                                                                                                                                        
                  CarouselBlock(                                                                                                                                                                                              
                      elements=[                                                                                                                                                                                              
                          CardBlock(title="Card 1", subtitle="First", body="First card in carousel."),                                                                                                                        
                          CardBlock(title="Card 2", subtitle="Second", body="Second card in carousel."),                                                                                                                      
                          CardBlock(title="Card 3", subtitle="Third", body="Third card in carousel."),                                                                                                                        
                      ]                                                                                                                                                                                                       
                  ),                                                                                                                                                                                                          
              ]                                                                                                                                                                                                               
          ),      
      ]                                                                                                                                                                                                                       
  )           

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

@srtaalej srtaalej self-assigned this May 5, 2026
@srtaalej srtaalej requested a review from a team as a code owner May 5, 2026 20:50
@srtaalej srtaalej added enhancement M-T: A feature request for new functionality semver:minor labels May 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.15%. Comparing base (73d255a) to head (3c0d3ba).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1872      +/-   ##
==========================================
+ Coverage   84.09%   84.15%   +0.06%     
==========================================
  Files         117      117              
  Lines       13325    13337      +12     
==========================================
+ Hits        11205    11224      +19     
+ Misses       2120     2113       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@srtaalej srtaalej changed the title feat: add BlockChunk type to chat.{start,append,stop}Stream methods feat(models): add BlockChunk type to chat.{start,append,stop}Stream methods May 5, 2026
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srtaalej Nice! LGTM with a note on alphabetics I'd like us to keep pattern for since it makes later finding and additions less difficult I think!

Comment on lines +42 to +43
elif type == BlocksChunk.type:
return BlocksChunk(**chunk)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧮 quibble: Might this be alright to move up for alphabetical ordering to match other entries?

@zimeg zimeg added this to the 3.41.1 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants