Slack API Rate Limits
Problem:
get_channel_members() uses conversations.members, which is a Tier 3 method (50+ requests/minute, with bursts). For very large workspaces or frequent runs, this could hit rate limits, though it's less likely for a single call.
post_pairs_to_slack() makes a separate chat.postMessage call for each pair. This method has a special rate limit: generally 1 message per second per channel, with bursts allowed. If you generate many pairs, you could easily hit this limit, leading to messages being dropped or delayed.
Example Bug:
If you have 50 pairs to post, and the script fires them off quickly, many messages might not be delivered, or Slack might temporarily block your bot.
Recommendation:
Batching post_pairs_to_slack: Consider posting all pairs in a single message using Slack's Block Kit, or at least breaking them into smaller batches with a time.sleep() in between to respect the 1 msg/sec limit. For example, instead of "User A meets User B" and "User C meets User D" as separate messages, you could have one message
Implement Retry-After: If Slack returns a 429 Too Many Requests error, it will usually include a Retry-After header. Your code should respect this by waiting for the specified duration before retrying the request.
Slack API Rate Limits
Problem:
get_channel_members() uses conversations.members, which is a Tier 3 method (50+ requests/minute, with bursts). For very large workspaces or frequent runs, this could hit rate limits, though it's less likely for a single call.
post_pairs_to_slack() makes a separate chat.postMessage call for each pair. This method has a special rate limit: generally 1 message per second per channel, with bursts allowed. If you generate many pairs, you could easily hit this limit, leading to messages being dropped or delayed.
Example Bug:
If you have 50 pairs to post, and the script fires them off quickly, many messages might not be delivered, or Slack might temporarily block your bot.
Recommendation:
Batching post_pairs_to_slack: Consider posting all pairs in a single message using Slack's Block Kit, or at least breaking them into smaller batches with a time.sleep() in between to respect the 1 msg/sec limit. For example, instead of "User A meets User B" and "User C meets User D" as separate messages, you could have one message
Implement Retry-After: If Slack returns a 429 Too Many Requests error, it will usually include a Retry-After header. Your code should respect this by waiting for the specified duration before retrying the request.