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 `triggerEvent` #11

Closed jbuchacher closed 6 years ago

jbuchacher commented 6 years ago

Adds basic support for triggering events in API.ai.

Use cases

Conditional API.ai intent routing via logic in Botpress

bp.hear({'nlp.action': 'some-action-name'}, (event, next) => {
  const someParameter = event.nlp.parameters.SomeParameter
  if (someParameter === someCondition) {
    event.nlp.triggerEvent("some-other-event")
  } else {    
    event.reply('#otherResponse')
  }
})

Proactive messaging

someOtherSystem.on('some_event', () => {
  event.nlp.triggerEvent("some-other-event", { someData: '' } )
})
CLAassistant commented 6 years ago

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

slvnperron commented 6 years ago

Hi Joshua, thanks for your contribution. I just wanted to hear more about the use case behind this feature?

jbuchacher commented 6 years ago

@slvnperron I'm using Dialogflow prompts and context quite a bit. When a user is halfway through an intent that has a bunch of prompts, and they answer a question, I can trigger a Dialogflow event and immediately get back fulfillment information for the other intent, instead of adding context and then requiring the user to say something to actually trigger the other intent.