CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-slacker

Slack API client providing comprehensive Python interface for messaging, file sharing, user management, and team communication features.

Pending
Overview
Eval results
Files

rtm.mddocs/

Real-time Messaging

Connect to Slack's Real Time Messaging API for live message streams and event handling.

Capabilities

RTM Connection

Establish real-time connections to receive live events from Slack.

def start(self, simple_latest=False, no_unreads=False, mpim_aware=False):
    """
    Start RTM connection with comprehensive workspace data.
    
    Args:
        simple_latest (bool): Return simple message format (default: False)
        no_unreads (bool): Skip unread counts in initial data (default: False)
        mpim_aware (bool): Include multi-party IM awareness (default: False)
    
    Returns:
        Response: WebSocket URL and complete workspace state including:
        - WebSocket URL for connection
        - User and team information
        - Channel and group lists
        - IM and MPIM conversations
        - Bot information
    """

def connect(self):
    """
    Connect to RTM with minimal initial data.
    
    Returns:
        Response: WebSocket URL and basic connection information
    """

Usage:

# Full RTM start with complete workspace data
response = slack.rtm.start()
if response.successful:
    ws_url = response.body['url']
    users = response.body['users']
    channels = response.body['channels']
    # Connect to WebSocket URL to receive events

# Lightweight RTM connection
response = slack.rtm.connect()
ws_url = response.body['url']
# Connect to WebSocket for events only

Event Handling

Once connected to the WebSocket URL, you'll receive real-time events including:

  • Message events: New messages in channels and DMs
  • User events: User status changes, typing indicators
  • Channel events: Channel joins, leaves, renames
  • File events: File uploads and shares
  • Team events: Team changes and member updates

WebSocket Integration

The RTM API provides a WebSocket URL that you'll need to connect to using a WebSocket client library:

import websocket
import json

def on_message(ws, message):
    event = json.loads(message)
    if event['type'] == 'message':
        print(f"New message: {event['text']}")

def on_error(ws, error):
    print(f"WebSocket error: {error}")

# Get WebSocket URL from RTM
response = slack.rtm.start()
ws_url = response.body['url']

# Connect to WebSocket
ws = websocket.WebSocketApp(ws_url,
                          on_message=on_message,
                          on_error=on_error)
ws.run_forever()

Types

class RTM(BaseAPI):
    """Real-time messaging connection management."""
    def start(self, simple_latest=False, no_unreads=False, mpim_aware=False): ...
    def connect(self): ...

Install with Tessl CLI

npx tessl i tessl/pypi-slacker

docs

advanced.md

auth.md

channels.md

chat.md

files.md

index.md

interactive.md

rtm.md

search.md

users.md

tile.json