botpress/botpress-api.ai

add support for additional fulfillment types

Opened this issue · 2 comments

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] (botpress/botpress#335)

I just need help with the architectural design.

Below, the text fulfillment is sent to sendOutgoing

event.bp.middlewares.sendOutgoing({
type: 'text',
platform: event.platform,
text: result.fulfillment.speech,
raw: {
to: event.user.id,
message: result.fulfillment.speech,
channelId: event.platform !== 'slack' ? null : event.channel.id,
options: event.platform !== 'slack' ? null : {}
}

Assuming the {PR 335](botpress/botpress#335) is merged, how do I submit UMM messages to be sent?

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

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

  • adding a new mode: fulfillmentPlus
    • to support backward compatibility
  • add a regex filter of actions to fulfill
    • our current bots auto handle fulfillment for most actions, but there are some that need to be handled with custom code