Code Monkey home page Code Monkey logo

Comments (4)

filmaj avatar filmaj commented on June 11, 2024

If I understand the situation, you are using Google Cloud Run to host your app. GCR is a serverless system, meaning, it runs on containers that are ephemeral and disappear after each Slack event is processed by your app.

However, to store app installation information, you are using the FileInstallationStore:

FileInstallationStore(base_dir = "./data/installations"),

So, Bolt assumes that every time it runs, there will be a file in the ./data/installation directory that contains all of your applications' installation data. This will not work in a serverless environment, as the file system in each serverless invocation is clean and isolated and stateless between invocations. Nothing stored on the file system in GCR will be available the next time your GCR function is invoked.

The File Installation Store we provide as an example in Bolt is not recommended for production. For your situation, it is much better to store implement your own Installation Store that is compatible with serverless. For example, you could use a separate database that your GCR functions could interact with (store and retrieve installation information) on each invocation.

from bolt-python.

dwiq-pfaratin avatar dwiq-pfaratin commented on June 11, 2024

Hi

Thank you for pointing out the obvious error in my approach. Ofcourse, duh. I found and implemented this datastore pattern but am still getting failed with the error "dispatch_failed" when I run my /command <TEXT>

My setup is:

oauth_settings = OAuthSettings(
    client_id = os.environ["SLACK_CLIENT_ID"],
    client_secret = os.environ["SLACK_CLIENT_SECRET"],
    scopes = bot_scopes,
    user_scopes = user_scopes,
    install_path = "/slack/install",
    redirect_uri_path = "/slack/oauth_redirect",
    installation_store = installation_store,
    state_store = GoogleDatastoreOAuthStateStore(
        datastore_client = datastore_client,
        logger = logging.getLogger(__name__),
        ),
    callback_options = CallbackOptions(success = success, failure = failure),
    )

app = App(
    client = WebClient(token = slack_token),
    oauth_settings = oauth_settings,
    signing_secret = ss,
    raise_error_for_unhandled_request = True,
    process_before_response = True
    )
    
flask_app = Flask(__name__)
handler = SlackRequestHandler(app)

@flask_app.route("/slack/events", methods = ["POST"])
def events():
    logging.info(f'/slack/events: {request.get_json(silent = True)}')
    return handler.handle(request)

I see the following in the logs INFO:root:/slack/events: None

from bolt-python.

github-actions avatar github-actions commented on June 11, 2024

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

from bolt-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.