botpress/botpress-api.ai

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

Opened this issue · 2 comments

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.

@slvnperron I can create a PR for this.

This can be fixed by adding channelId and options: {} to raw

event.bp.middlewares.sendOutgoing({
type: 'text',
platform: event.platform,
text: result.fulfillment.speech,
raw: {
to: event.user.id,
message: result.fulfillment.speech
}
})

Do you see any problem with this approach?

@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)?