松弛命令来调用对话框

时间:2018-06-27 17:30:02

标签: javascript google-cloud-functions slack-api slack-commands slack-dialog

我正在使用配置了slack命令的slack APP,这些命令将消息发布到我的Firebase函数。一切正常。现在,我需要启动一个对话框。因此,我确实创建了一个新的Slack命令,并指出了我的云功能。我正在执行以下操作,但收到500错误并且无法理解。请指教

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...")
            })
}

我看不到它仅因服务错误而起作用。 Firebase日志是

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)

0 个答案:

没有答案