Full context available in this issue reported by me: Modal submission payload contains plus-separated words · Issue #1631 · slackapi/bolt-js · GitHub
I’m building a Slack Bot with BoltJS to facilitate a slash command that opens a modal UI, which admins can use to enter some information and submit to my Netlify Function. From my function handler, I can see the header 'content-type': 'application/x-www-form-urlencoded'
, and any multi-word sentences have their spaces encoded as +
instead of %20
, which is undesirable.
The BoltJS team doesn’t consider this to be an issue with the Slack API, so I’m wondering if I may have configured my handler wrong in some way. The issue occurs whether I run netlify live
locally, or have my function deployed live.
Here is a snippet of my handler:
const handler: Handler = async (
event: APIGatewayEvent
): Promise<IHandlerResponse> => {
// the raw encoded body has + instead of %20 for spaces
console.log(event.body)
// this runs JSON.parse() and checks the body contents
const payload: any = parseRequestBody(
event.body,
event.headers['content-type']
)
if (isUrlVerificationRequest(payload)) {
return {
statusCode: 200,
body: payload?.challenge,
}
}
// this passes the payload to BoltJS
const slackEvent: ReceiverEvent = generateReceiverEvent(payload)
await app.processEvent(slackEvent)
return {
statusCode: 200,
body: '',
}
}
export { handler }
Ideally, I would prefer the spaces be encoded as %20
so that I can decode them reliably. What can I do? Any help would be appreciated.