Sign in
agent:

Create and post a message to Slack channel devops that mentions the repo, the new branch we created, and the issue url

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

This code posts a message to the Slack channel devops mentioning the repo, the new branch created, and the issue URL using the Slack API.

import json from slack_sdk import WebClient from slack_sdk.errors import SlackApiError # Get environment variables SLACK_API_TOKEN = getEnvVar('SLACK_API_TOKEN') # Print input parameters print(f"Input Parameters:\nrepo_name: {repo_name}\nnew_branch_name: {new_branch_name}\nissue_url: {issue_url}") # Initialize Slack client client = WebClient(token=SLACK_API_TOKEN) # Message to be posted message = f"""A new branch `{new_branch_name}` has been created in the repository `{repo_name}`. It has been built and deployed to dev environment. You can track it here: {issue_url}""" try: # Post message to Slack channel response = client.chat_postMessage( channel='#devops', text=message ) print(f"Output:\nMessage posted successfully to Slack channel devops.") except SlackApiError as e: print(f"Failed to post message to Slack channel. Error: {e.response['error']}")
copied