- When a user types the slash command
/modify-power-config
,handleModifyPowerConfig
will be called, presenting the user with options. - When the user selects an option,
handleBlockActions
will be called, which will open a modal usingopenParameterInputModal
. - When the user submits the modal,
handleViewSubmission
will be called, which will then callhandleParameterUpdate
to process the update.
a. Go to https://api.slack.com/apps b. Click "Create New App" c. Choose "From scratch" d. Name your app (e.g., "Power Capping Config") and select your workspace
a. In the left sidebar, click on "Slash Commands" b. Click "Create New Command" c. Set the command to "/modify-power-config" d. Set the Request URL to "https://your-domain.com/slack/command" e. Add a short description and usage hint f. Save the command
a. In the left sidebar, click on "Interactivity & Shortcuts" b. Turn on Interactivity c. Set the Request URL to "https://your-domain.com/slack/interact" d. Save the changes
a. In the left sidebar, click on "OAuth & Permissions" b. Under "Scopes", add the following Bot Token Scopes:
- commands
- chat:write
- im:write
c. Scroll up and click "Install to Workspace" d. Authorize the app
a. In the left sidebar, click on "Basic Information" b. Under "App Credentials", you'll find your Signing Secret c. Go back to "OAuth & Permissions" to find your Bot User OAuth Token
In your server environment, set these variables:
export SLACK_SIGNING_SECRET=your_signing_secret_here export SLACK_BOT_TOKEN=your_bot_token_here
Ensure your CreateWebhook
function is being called with the correct port:
func main() {
// ... other setup code ...
CreateWebhook(8080) // or whatever port you're using
}
Deploy your Go application to a server that's accessible via HTTPS. Slack requires HTTPS for all webhook URLs.
a. In your Slack workspace, type "/modify-power-config" b. You should see the options to modify efficiency level or power cap percentage c. Select an option, enter a new value, and submit d. Verify that your backend receives and processes the request correctly
Implement proper error handling and logging in your webhook handlers to help with debugging.
- Always verify the request signature using the signing secret
- Use HTTPS for all communications
- Implement proper access controls to ensure only authorized users can modify configurations
Note: Remember to replace "https://your-domain.com" with your actual domain where your webhook is hosted.
Make sure to update your Slack app configuration to point to these webhook URLs:
- Set the slash command URL to
https://your-domain.com/slack/command
- Set the interactivity request URL to
https://your-domain.com/slack/interact