botpress / botpress-api.ai

☠ 301 – Moved here (user Botpress NLU) --->
https://github.com/botpress/modules
GNU General Public License v3.0
14 stars 10 forks source link

Slack and API.AI Modules - Error: Channel id format is not valid #18

Open jsalwen opened 6 years ago

jsalwen commented 6 years ago

I created a new bot using the Slack and API.AI modules. API.AI module is in Fulfillment mode.

The following error is returned when the bot tries to send the response to the user in Slack:

Error: Channel id format is not valid (actual: undefined, required: string)
    at Slack.validateChannelId (c:\projects\my-bot\node_modules\botpress-slack\bin\webpack:\src\slack.js:40:13)
    at Slack.validateBeforeSending (c:\projects\my-bot\node_modules\botpress-slack\bin\webpack:\src\slack.js:66:10)
    at Slack.sendText (c:\projects\my-bot\node_modules\botpress-slack\bin\webpack:\src\slack.js:71:10)
    at Object.handleText [as text] (c:\projects\my-bot\node_modules\botpress-slack\bin\webpack:\src\outgoing.js:23:43)
    at outgoingMiddleware (c:\projects\my-bot\node_modules\botpress-slack\bin\webpack:\src\index.js:23:3)
    at exec (c:\projects\my-bot\node_modules\mware\index.js:50:23)
    at Function.run (c:\projects\my-bot\node_modules\mware\index.js:63:7)
    at Object.dispatch (c:\projects\my-bot\node_modules\botpress\lib\webpack:\src\middlewares.js:45:10)
    at Object.sendOutgoing (c:\projects\my-bot\node_modules\botpress\lib\webpack:\src\middlewares.js:159:29)
    at c:\projects\my-bot\node_modules\botpress-api.ai\bin\webpack:\src\index.js:55:43
    at process._tickCallback (internal/process/next_tick.js:109:7)
15:04:29 - warn: botpress-api.ai API Error. Could not process incoming text: Channel id format is not valid (actual: undefined, required: string)

This is because the botpress-slack is excepting a value for raw.channelId when event.bp.middlewares.sendOutgoing is called.

jsalwen commented 6 years ago

@slvnperron I can create a PR for this.

This can be fixed by adding channelId and options: {} to raw https://github.com/botpress/botpress-api.ai/blob/962d4a28b9cb1da2dfd53c86e3cda9a0bdadbaa0/src/index.js#L55-L63

Do you see any problem with this approach?

slvnperron commented 6 years ago

@jsalwen I think that's reasonable. Ideally we would make it as channel-independent as possible but I guess sometimes it's hard to avoid.

Perhaps check copying channelId if provided would be better (i.e. no platform checking)?