Package: slack-okta-bot
slack-okta-botProvides the backend service for an Okta application that gives users the ability to execute common tasksThe backend can run:As a standalone serverAWS Lambda Function URLAWS Lambda as an ELB targetCurrent features:Reset MFA FactorsReset passwordConfigurationThe following env vars are used for configurationNameDescriptionRequiredDefaultHELP_CHANNELHelp channel displayed in responses to userno#devops-helpHOME_HEADERHeader displayed in app home pageno:gear: Get help with common DevOps Okta tasks :gear:HOME_VIEWAdditional info to show in app home pagenoRESET_MFA_COMMANDCommand the user sends to reset MFAno/reset-mfaRESET_PASSWORD_COMMANDCommand the user sends to reset passwordno/reset-passwordTEST_USERAn email address that, if set, be used instead of the user's slack email.noPORTPort to run the local server onno3000SLACK_BOT_TOKENSlack Bot User Oauth TokenyesSLACK_SIGNING_SECRETSlack Signing SecretyesOKTA_URLOkta api endpoint <yourdomain.okta.com/api/v1>yesOKTA_TOKENOkta API tokenyesUsageWith AWS Lambda: The easy wayFor convenience, if you don't need any additional logic in your handler, you can just
build your package usingbuild_lambda.sh(Described below) and set your Lambda's handler toslack_okta_bot.aws_lambda.lambda_handler.AWS Lambda: Manual wayfromjsonimportdumpsfromloggingimportgetLoggerfromslack_okta_bot.slackimportslack_appfromslack_okta_bot.aws_lambdaimportLambdaHandlergetLogger().setLevel("INFO")defhandler(event,context):getLogger().info(dumps(event,indent=2))handler=LambdaHandler(slack_app)try:res=handler.handle(event,context)getLogger().info(res)returnresexceptExceptionase:getLogger().info(e)In your Lambda config You would set your lambda handler tomodule.handlerwheremoduleis the name of your Lambda package moduleBuilding a basic Lambda packageFrom source:Runbuild_with_poetry.sh. It requires thatpoetrybe installed and will install it if missing.Upload the created zip file to S3 and configure your Lambda to pull from S3Optionally upload the package manually in the AWS Lambda consoleSet your Lambda's handler toslack_okta_bot.aws_lambda.lambda_handlerUsing PIPRunpip install slack-okta-bot -t packagescdinto ./packages directoryRunzip -r ../lambda.zip . -x '*.pyc'Upload ../lambda.zip to S3 and configure your Lambda to pull from S3Optionally upload the package manually in the AWS Lambda consoleSet your Lambda's handler toslack_okta_bot.aws_lambda.lambda_handlerRunning as a serverThe package will install a shell script that can run a server> slack-okta-bot
INFO:slack_okta_bot:Logging to stdout
⚡️ Bolt app is running! (development server)
127.0.0.1 - - [23/Dec/2022 12:11:02] "POST /slack/events HTTP/1.1" 200 -If you need to import and run from your own script:fromslack_okta_botimportrun_local# do cool stuffrun_local()Slack AppTo install in Slack:Update slack-okta-bot.yaml with the domain you will be usingUpdate any other options you would like to changeGo to applications in your Slack org's admin area (https://api.slack.com/apps)Click the "Create New App" buttonClick "From an app manifest"Select workspace to install toMake sure that "YAML" tab is selectedUnder "Basic Information" save your Signing Secret so you can export it to the required env varGet the Bot User Oauth Token from the "Oauth & Permissions" tab so you can export it to the required env varDeploy your application backendIn the Slack app configuration page go to "Event Subscriptions"If the Request URL is not marked as "Verified" click the verify button/linkYour app's homepage should now show and commands will become active. Test by entering a slash command in any channel in slack. Your interaction with the bot will be private and won't be displayed to other users in the chat. If the application is installed into the Apps side pane in Slack then you can also access the app's home page to see the description and available commands.