Skip to content

Pass variables as "secret" payload #8

Answered by jlindblom-godaddy
freebuu asked this question in Q&A
Discussion options

You must be logged in to vote

This is a good use case for the modal's private_metadata field (see https://api.slack.com/reference/surfaces/views).

Within the slack-php framework, there is a simple abstraction for this that is very much like what you've requested.

To set (during step 2):

$previewModal = Modal::new()
    // ...
    ->tap(function (Modal $modal){
        $modal->encodePrivateMetadata([
            'var1' => 'value1',
            'var2' => 'value2',
        ]);
        // ...
    });

To get (during step 3):

$ctx->payload()->getMetadata()->get('var1');

Note: If you inspect the private_metadata in the modal's JSON, you will see a base64-encoded string. The framework does http_build_query and base64_encode t…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by freebuu
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants