1

I am using slack APP with slack commands configured which post the message to my firebase functions. This is working fine. Now i have a requirement to launch a dialog. So, i did create a new slack command and pointed to my cloud functions. I am doing the below but receive 500 error and failing to understand. please advise

import * as rp from "request-promise-native";
export const queue_command = functions.https.onRequest(async (request, response) => {
 var payload = 
            {
                "trigger_id": request.body.trigger_id,
                "dialog": {
                  "callback_id": "send_feedback",
                  "title": "Request a Ride",
                  "submit_label": "Request",
                  "notify_on_cancel": true,
                  "elements": [
                      {
                          "type": "text",
                          "label": "Pickup Location",
                          "name": "loc_origin"
                      },
                      {
                          "type": "text",
                          "label": "Dropoff Location",
                          "name": "loc_destination"
                      }
                  ]
                }
              }

              console.log('trying response uri:' + request.body.response_url)
              const options = {
                uri: request.body.response_url, 
                method: "POST",
                json: true,
                body: payload,
                headers: {
                    'content-type' : 'application/json'
                }

            };
            console.log("sending data as:" + JSON.stringify(options))  
            rp(options).then(function(body){
                return response.send("hang on...")
            })
}

I do not see it working with just service error. firebase logs are

StatusCodeError: 500 - "no_text"
    at new StatusCodeError (/user_code/node_modules/request-promise-native/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/user_code/node_modules/request-promise-native/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/user_code/node_modules/request-promise-native/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/user_code/node_modules/request/request.js:185:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/user_code/node_modules/request/request.js:1157:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/user_code/node_modules/request/request.js:1079:12)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Vik
  • 8,721
  • 27
  • 83
  • 168
  • I'll just a comment in case someone will end up here from google results as well - `500 - "no_text"` is response when the payload is not formatted properly and it's missing some kind of message text. – yedpodtrzitko Oct 07 '22 at 10:42

0 Answers0