Closed AndromedaPerseus closed 2 months ago
Hi @AndromedaPerseus, thanks for asking the question. Instead of doing "In Manage Distribution -> click "Add to Slack"", you can install this app from /slack/install
of your public ngrok domain.
Ah, perhaps you unintentionally enabled the OAuth flow by settings OAuth related env variables such as SLACK_CLIENTID etc. Please follow the exact steps here: https://github.com/slack-samples/bolt-python-ai-chatbot?tab=readme-ov-file#environment-variables and remove all SLACK * env variables that are not mentioned there.
Hi @seratch, thank you for getting back to me on this. I am not exporting the SLACK_CLIENT_ID etc, but they are used within this template in app_oauth.py. Somehow, I was able to make it work but I decided to repeat the steps to ensure that the logic is valid, and it is not. I guess that was pure fluke that I got it to work.
I am able to install the app, but when it comes to running the slask command /ask-bolty, it keeps throwing me the same error message: We apologize, but for some unknown reason, your installation with this app is no longer available. Please reinstall this app into your workspace
I made some changes to the app.py and app_oauth.py because it seems like its partially missing some arguments:
import logging
import os
from slack_bolt import App, BoltResponse
from slack_bolt.oauth.callback_options import CallbackOptions, SuccessArgs, FailureArgs
from slack_bolt.oauth.oauth_settings import OAuthSettings
from slack_sdk.oauth.installation_store import FileInstallationStore
from slack_sdk.oauth.state_store import FileOAuthStateStore
from listeners import register_listeners
logging.basicConfig(level=logging.DEBUG)
def success(args: SuccessArgs) -> BoltResponse:
print(f"Success: {args}")
return args.default.success(args)
def failure(args: FailureArgs) -> BoltResponse:
print(f"Failure: {args}")
return args.default.failure(args)
os.makedirs("./data", exist_ok=True)
filestore_installation = FileInstallationStore(base_dir="./data", client_id=os.environ.get("SLACK_CLIENT_ID"))
# OAuth Settings
oauth_settings = OAuthSettings(
client_id=os.environ.get("SLACK_CLIENT_ID"),
client_secret=os.environ.get("SLACK_CLIENT_SECRET"),
scopes=[
"app_mentions:read",
"channels:history",
"channels:read",
"chat:write",
"chat:write.public",
"commands",
"groups:history",
"groups:read",
"im:history",
"im:read",
"im:write",
"mpim:history",
"mpim:read",
"mpim:write",
"users:read",
],
user_scopes=[],
install_path="/slack/install",
redirect_uri_path="/slack/oauth_redirect",
installation_store=filestore_installation,
state_store=FileOAuthStateStore(expiration_seconds=600, base_dir="./data"),
callback_options=CallbackOptions(success=success, failure=failure),
state_validation_enabled=False,
)
# Initialization
app = App(
signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),
installation_store=filestore_installation,
oauth_settings=oauth_settings,
)
# Register Listeners
register_listeners(app)
# Start Bolt app
if __name__ == "__main__":
app.start(3000)
import os
import logging
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
from listeners import register_listeners
from dotenv import load_dotenv
load_dotenv()
slack_bot_token = os.environ.get("SLACK_BOT_TOKEN")
signing_secret = os.environ.get("SLACK_SIGNING_SECRET")
slack_app_token = os.environ.get("SLACK_APP_TOKEN")
# Initialization
app = App(token=slack_bot_token, signing_secret=signing_secret)
logging.basicConfig(level=logging.DEBUG)
# Register Listeners
register_listeners(app)
# Start Bolt app
if __name__ == "__main__":
SocketModeHandler(app, slack_app_token).start()
I read the documentation multiple times, and I dont see why its not seeing the installation. I can confirm that the installation within ./data is stored as well so it has installed it correctly. I wish it would output more error logs to debug the issue, and I can't get anything out besides that error message above. " We apologize, but for some unknown reason, your installation with this app is no longer available. Please reinstall this app into your workspace "
@seratch So I deleted signing_secret=os.environ.get("SLACK_SIGNING_SECRET"), client_id=os.environ.get("SLACK_CLIENT_ID"), and client_secret=os.environ.get("SLACK_CLIENT_SECRET"),. It works now. What is the reason behind this? And why have it in the template is the first place?
Hi,
Thank you for creating the template starter. I am facing an issue with getting the app to install and for me to be able to use /ask-bolty to work. I am going to outline each step I have taken:
I tried installing the APP several times, but it still shows Installation Count == 0