In event "block_actions" error parsing string to JSON.
Description
Describe your issue here.
What type of issue is this? (place an x in one of the [ ])
- [x] bug
- [ ] enhancement (feature request)
- [ ] question
- [ ] documentation related
- [ ] testing related
- [ ] discussion
Requirements (place an x in each of the [ ])
- [x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [ x] I've read and agree to the Code of Conduct.
- [ x] I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Packages:
Select all that apply:
- [ ]
@slack/web-api - [ x]
@slack/events-api - [ ]
@slack/interactive-messages - [ ]
@slack/rtm-api - [ ]
@slack/webhooks - [ ] I don't know
Reproducible in:
package version:2.3.0
node version:12.14.0
OS version(s):Ubuntu 19.10
Steps to reproduce:
1.initializate createEventAdapter(eventsAPI) and configurate 2.Construction message with interactive components like this const b = [ { "type": "section", "text": { "type": "mrkdwn", "text": "Are you ready?" } }, { "type": "divider" }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "Yes" }, "value": "1" }, { "type": "button", "text": { "type": "plain_text", "text": "No" }, "value": "0" } ] } ]; {channel: event.channel, text: message, blocks: b,as_user: true, username: 'hr_bot'} 3. It happens when a user clicking interactive button - event name "block_actions"
Expected result:
{ type: 'block_actions', team: { id: 'T0C19Q6C9', domain: 'priem' }, user: { id: 'UJK90BEHY', username: 'i.rogatkin', name: 'i.rogatkin', team_id: 'T0C19Q6C9' }, api_app_id: 'ARAQNMQAV', token: 's22XosPjLJLtZ98IBQKvyFls', container: { type: 'message', message_ts: '1577441400.006300', channel_id: 'DRLKLAH1A', is_ephemeral: false }, trigger_id: '889120914679.12043822417.79e76366889733291684d95af6363e74', channel: { id: 'DRLKLAH1A', name: 'directmessage' }, message: { bot_id: 'BRNUVV7E3', type: 'message', text: "Hello!+I'm+hr-bot.", user: 'UR9K7UGQ3', ts: '1577441400.006300', team: 'T0C19Q6C9', blocks: [ [Object], [Object], [Object] ] }, response_url: 'https://hooks.slack.com/actions/T0C19Q6C9/887262060496/P89fKE8hj1oFpbOvdtMLEN1E', actions: [ { action_id: 'SA0', block_id: 'SI0j', text: [Object], value: '1', type: 'button', action_ts: '1577441403.978548' } ] }
What you expected to happen Get the value of the button that the user clicked on for further information processing
Actual result:
SyntaxError: Unexpected token p in JSON at position 0
at JSON.parse (
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
@Sparksss Hello, for handling block_actions requests, @slack/interactive-messages is the right npm package to use. Check the usage of slackInteractions.action(...) in its official document.
@Sparksss if you've been able to handle block_actions interactions, please close the issue. if you haven't, we can still help.
You might also want to see the documentation about starting a server for an example of using an HTTP server or Express. That would be necessary if you're trying to use both @slack/events-api and @slack/interactive-messages in the same app.
@Sparksss I'm going to close this issue. Feel free to re-open or file a new issue if needed!
@Sparksss if you've been able to handle
block_actionsinteractions, please close the issue. if you haven't, we can still help.You might also want to see the documentation about starting a server for an example of using an HTTP server or Express. That would be necessary if you're trying to use both
@slack/events-apiand@slack/interactive-messagesin the same app.
Dude, all you know how to say is "close issue" u never actually help. Please if u don't have something constructive to say, keep quiet
Hi @itonyeig 👋🏻
Are you running into the same JSON.parse error related to this issue? It looks like as though the original response was helpful to a few developers. However, if you're experiencing the same issue, we'd appreciate some steps to reproduce to help you out!
Also, as a heads up, the @slack/events-api is deprecated in favour of Bolt-JS. The deprecation notice includes some samples to help migrate over to Bolt.
I'd also like to point out that our CODE OF CONDUCT strives to maintain an inclusive, safe, friendly, and helpful community. Please keep this space friendly and do not personally attack others. Open source is hard and maintainers are humans too. 🙂 🙇🏻