def _create_or_join_channel(client: WebClient, channel_name: str) -> str:
        """Creates or joins the specified slack channel and returns its channel_id"""
        for channel in client.conversations_list()["channels"]:
            if channel["name"] == channel_name:
                try:
                    # Attempt to join the channel if not already joined
                    client.conversations_join(channel=channel["id"])
                except Exception as e:
                    # It's ok if already in channel or can't join (e.g., private and no permission)
                    logging.warning(f"Could not join channel {channel_name}: {e}")
                return channel["id"]

        # TODO: make this a private channel not a public channel. it shouldn't be visible to anyone who joins the public
        # robusta workspace
        result = client.conversations_create(name=channel_name)
        return result["channel"]["id"]
Creates or joins the specified slack channel and returns its channel_id
tests/utils/slack_utils.py