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

Trello Integration by Team 3 members #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isiddharthsingh
Copy link

Teammates:
Siddharth Singh - sms10221@nyu.edu
Adittya Mittal - am14079@nyu.edu

We implemented functionality that allows users to add tasks to their Trello 'To Do' list directly through Slack by simply typing a command (e.g., 'add "study at 5" to my todo'). Additionally, the bot retrieves and displays the current tasks from Trello within Slack, ensuring seamless task management across both platforms."

This version highlights the added functionality and emphasizes the integration between Slack and Trello.

WhatsApp Image 2024-10-06 at 23 37 38_d1d75861

WhatsApp Image 2024-10-06 at 23 38 03_85d500bd

raise Exception(f"Could not find list {TRELLO_LIST_NAME} on the board")

# Add a card to the "To Do" list in Trello
def add_card_to_trello(card_name):

Choose a reason for hiding this comment

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

Can add a docstring to explain the function’s purpose, input parameters, and return value. This will improve readability and make it easier for other developers to understand its purpose.
For example:
"""Adds a card with the specified name to a predefined Trello list.

Args:
    card_name (str): The name of the card to add.

Returns:
    response.json(): The JSON response containing the details of the added card.

Raises:
    Exception: If the request to Trello fails.
"""

Copy link

Choose a reason for hiding this comment

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

The add_card_to_trello function should validate card_name before making the API call.

raise Exception(f"Failed to fetch tasks from Trello: {response.status_code}, {response.text}")

# Post a message to Slack channel
def post_to_slack(channel, message):

Choose a reason for hiding this comment

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

adding type hints can improve clarity regarding the expected input and output types.
For example:
def post_to_slack(channel: str, message: str) -> dict:

# Extract the task from the message
task_to_add = context['matches'][0]

# Add the task to Trello
Copy link

Choose a reason for hiding this comment

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

The error message is directly exposed to users. Consider sanitizing error messages for production.

Choose a reason for hiding this comment

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

Thanks for pointing that out!
Did you mean to mark a different line of code?

Copy link

@Sidhved Sidhved left a comment

Choose a reason for hiding this comment

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

1. Change Granularity

  • Observations: The changes are well-segmented across multiple files, each serving a specific purpose. The PR introduces a set of changes to integrate Trello with Slack, particularly focusing on the “show me todo” and “add todo” commands. The changes appear adequate. However, some commits could be split further to isolate different aspects of functionality (e.g., command handling vs. API interaction).

2. Code Functionality

  • Does the Code Meet Requirements?:
    The code meets some of the basic requirements by adding two Slack commands that interact with Trello. The “show my todo” command fetches tasks, while “add todo” allows new tasks to be added. Both commands appear functional based on the code. We would recommend wrapping Trello functionality as a package.
  • Logic Flow:
    The logic is mostly sound, but there are a few areas where flow could be improved (check comments on trello_bot.py)

3. Readability & Structure

  • Naming Conventions: Generally good, with clear function names like get_trello_list_id, and add_card_to_trello.
  • Modularity: Functions are well-encapsulated with single responsibilities. However, some improvements could be made:
    • Consider separating Trello and Slack operations into different modules
    • Create a configuration module for environment variables

4. Standards Compatibility

  • Linting: Consider adding more linting rules and try to fix current linting issues.
  • API Exposure: API keys and other sensitive information are handled securely, which is good. Using environment variables is a good practice, and the code seems to follow this approach.

5. Testing

  • Coverage: Testing coverage could be expanded. Missing test for Trello module (would recommend: error handling, validation, integration)
  • Readability: The current tests, while limited, are easy to understand. Improving test readability by adding comments, using more descriptive names for test cases, or adding API documentation to the defined methods would be helpful.

trello integration with show mw toto and add todo comands on slack

Add .DS_Store to .gitignore

Add correct python version and uv

Add correct python version

Add correct python version and checks

fix: correct python version and enbled all ruff checks

Update Readme.md

Update CircleCi with uv package manager

Added uv.lock

Update README with uv dependency installation instructions

Added .DS_Store to ignored files

trello integration with show mw toto and add todo comands on slack

Add .DS_Store to .gitignore

Add correct python version

Add correct python version and checks

fix: correct python version and enbled all ruff checks

Update Readme.md

Update CircleCi with uv package manager
Copy link
Collaborator

@kyotov kyotov left a comment

Choose a reason for hiding this comment

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

Major work left.

  • How is each file in your PR connected to the task at hand?
    • You should not have files that are irrelevant to the task.
  • Make sure files that should be .gitignore are in .gitignore
    • E.g. .DS_Store
  • Make sure secrets are not checked in!
  • Make sure there is a clear and separated API!

Address these and I will look again.


# Fetch Trello list ID for the "To Do" list
def get_trello_list_id():
url = f"https://api.trello.com/1/boards/{TRELLO_BOARD_ID}/lists?key={TRELLO_API_KEY}&token={TRELLO_TOKEN}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are client libraries for trello for python -- did you decide not to use them on purpose?

kyotov pushed a commit that referenced this pull request Feb 8, 2025
added some code to be able to parse the message payloads (bodies)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants