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

add support for additional fulfillment types #22

Open jsalwen opened 6 years ago

jsalwen commented 6 years ago

currently, the module only supports text

I have botkit code I use to convert api.ai fulfillment types into messenger format. It would be pretty easy to add support to convert these to UMM (see [Botpress PR 335] (https://github.com/botpress/botpress/pull/335)

I just need help with the architectural design.

Below, the text fulfillment is sent to sendOutgoing https://github.com/botpress/botpress-api.ai/blob/d9ce9a5b214ac2d18bccf4caf532040d1c300823/src/index.js#L55-L64

Assuming the {PR 335](https://github.com/botpress/botpress/pull/335) is merged, how do I submit UMM messages to be sent?

jsalwen commented 6 years ago

at the moment, I have code inside the bot's index.js

note: this only handles custom payload, but it gives the idea. I am using event.reply to send the UMM.

bp.hear({'nlp.source': 'agent'}, (event, next) => {
  let messages = event.nlp.fulfillment && event.nlp.fulfillment.messages
  if (messages.length) {
    messages.forEach(message => {
      if (message.type === 4 && message.payload && message.payload.umm) {
        let umm = { umm: message.payload.umm }
        let ummBloc = jsYaml.safeDump(umm)
        event.reply(ummBloc)
      }
    })
    return
  }
  next()
})
jsalwen commented 6 years ago

I started working on this: https://github.com/smalltalk-ai/botpress-api.ai/tree/issue-22-additional-fulfillment-types