6

Trying to send a dialog to slack channel via the dialog.open api, but always get the error:

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

I am using node.js, here is how my code looks like:

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

Is there someone experienced to point me to the right direction? Many thanks in advance.

Psidom
  • 209,562
  • 33
  • 339
  • 356
  • 6
    It could be related to the token. The error will occur when you are not using the token from the Slack app that belongs to the slash command, but some other token. – Erik Kalkoken Jan 26 '18 at 22:24
  • 3
    Thanks @ErikKalkoken I had the exact same problem, but after reading your comment realized I just needed to reinstall the app to update installed instance to a new token. – terrafirma9 Jan 29 '18 at 13:32
  • I had the same issue and fought with it for about an hour or so. Thanks @ ErikKalkoken, reinstall and using the updated token worked for me. – Sleeping_Giant Nov 26 '18 at 20:13

0 Answers0