为什么松弛会给我带来无效的触发错误?

时间:2018-01-26 20:43:51

标签: node.js slack slack-api

尝试通过dialog.open api向松弛频道发送对话框,但总是收到错误:

trigger id 305394181715.285081825728.e91e087e5199b235c8678aeaaedf6450
type of trigger id string 
{ 
    ok: false,   
    error: 'invalid_trigger',  
    warning: 'missing_charset',   
    response_metadata: { 
        warnings: [
            'missing_charset' 
        ] 
    } 
}

我正在使用node.js,这是我的代码的样子:

dialog_url = "https://slack.com/api/dialog.open"

dialog = {
  "callback_id": "ryde-46e2b0",
  "title": "Request a Ride",
  "submit_label": "Request",
  "elements": [
    {
      "type": "text",
      "label": "Pickup Location",
      "name": "loc_origin"
    },
    {
      "type": "text",
      "label": "Dropoff Location",
      "name": "loc_destination"
    }
  ]
}

// handle the post triggered by slash command using node express
app.post('/dialog', (req, res) => {

  console.log('trigger id', req.body.trigger_id)
  console.log('type of trigger id', typeof(req.body.trigger_id))

  // post dialog to dialog url
  axios.post(dialog_url, { 
    dialog, 
    trigger_id: req.body.trigger_id
  }, {
    headers: {
      'Content-type': 'application/json',
      'charset': 'UTF-8',
      'Authorization': process.env.token || process.env.bot_token
    }
  }).then(res => {
    console.log(res.data)
  }).catch(err => console.log(err))
})

有没有经验的人指出我正确的方向?非常感谢提前。

0 个答案:

没有答案