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)
- Intermittent UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined HOT 2
- How do you develop at 2 at the same time with Slack? HOT 2
- Incorrectly formatted threaded broadcast reply message will raise `thread_broadcast` event HOT 6
- `PinnedMessageItem` interface missing `ts` HOT 1
- Multiple fields missing in `ChannelCreatedEvent` interface
- (Set a clear title describing the issue) HOT 2
- `client.chat.postMessage` with a user token throws `invalid_auth` error HOT 3
- Allow in thread response in `respondFn` HOT 1
- How do I ignore threaded messages from within the message listener? HOT 3
- ERROR : Please try again or contact the app owner (reason: slack_oauth_missing_code) HOT 15
- chat:write:bot permission needed even though I have chat:write permission HOT 5
- Slack Block Builder do not update static select value in modal HOT 2
- Keep getting ETIMEDOUT errors / warning messages HOT 7
- How to get rich_text_input in slack modal ? HOT 13
- Receiving multiple events for simple messages in web socket mode HOT 1
- Upgrade axios to resolve CVE-2024-39338 HOT 3
- Supporting for Socket client & server timeout missing HOT 5
- Install and authorize multiple slack app clients with a single bolt js server HOT 3
- Using bolt's redirect URI for OIDC HOT 10
- Bolt App Methods Hanging with `ETIMEDOUT` Warning During `chat.postMessage` Execution HOT 10
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.