Comments (2)
Hi, thanks :)
Yes, actually the way we've done this is to serialize JSON into the value of the button action.
So we have utility functions like this:
let common = {
// args takes a JSON stringify'd string and returns an object,
// fails silently returning an empty object
unmarshall: (str) => {
try {
return JSON.parse(str)
} catch (ex) {
console.error(`Error unmarshalling ${str}`, ex)
return {}
}
},
marshall: JSON.stringify
}
So then your button actions might look something like this:
actions: [{
name: 'match_confirmation_yes',
text: 'Yep, good game.',
style: 'primary',
type: 'button',
value: common.marshall({ id: 'some-id', value: 'yes' })
},
{
name: 'match_confirmation_no',
text: 'NO WAY ! That\' a lie!',
type: 'button',
value: common.marshall({ id: 'some-id', value: 'no' })
}]
And your action handlers would unmarshall the value and then have an object to deal with:
slapp.action('match_confirmation_callback', 'match_confirmation_yes', (msg, args) => {
args = common.unmarshall(args)
// args.id is 'some-id'
msg.respond('Too bad, maybe next time :wink:!')
});
slapp.action('match_confirmation_callback', 'match_confirmation_no', (msg, args) => {
args = common.unmarshall(args)
// args.id is 'some-id'
msg.respond('What what what ? Someone is trying to cheat then. You need to see this IRL!')
});
from bolt-js.
Ok that's a neat trick ! It could be awesome to have the state being handled the same way routes does.
Thank you ;)
from bolt-js.
Related Issues (20)
- How was the Google Calendar Event Details built with Slack's Block Kit? HOT 1
- How to ideally test Slack apps locally in a multi member team HOT 5
- uploadV2 method always returns error `not_authed` but upload method works HOT 3
- How to built customisable form using slack api HOT 4
- Can I require choosing a channel when authorizing a Slack App? HOT 2
- Using AWS Lambda Handler while retrieving Bot Token and Signing Secret from Vault HOT 2
- Add slack_file object to image block element HOT 1
- How to document `optional` field from housing Block and how it applies to Block Elements within? HOT 8
- app_home_opened not firing on iOS client HOT 15
- Duplicate message getting created when trying to update bot message using chat.update HOT 1
- Unfurl links when the app is installed in the workspace HOT 2
- State verification during OAuth process HOT 8
- `context.matches.groups` becomes undefined after a Web API call HOT 8
- Is it possible to get typing event or indicator when a user in slack starts typing in a message HOT 1
- `files` property missing in `app_mention` event HOT 3
- How to track of deleted users HOT 3
- External select not refreshing HOT 4
- Issue with extracting headers from incoming requests HOT 1
- User scope not working in OAuth HOT 3
- Message event payloads missing `team_id` in enterprise on mobile slack clients HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolt-js.