Triggers

Wit specific triggers

The facebook.wit trigger will call your Wit model's "message meaning" API with the user's input text, and will match if the intent confidence threshold is reached.

- expect: wit
  integration: integration.wit
  intent_regex: weather
  • expect: The name of the NLU provider, in this case wit

  • integration: The Wit integration reference path. Because the trigger needs to make an API call to Wit, it will need the Wit integration configuration settings.

  • intent_regex: The regex pattern to use for matching the intent.

Simple example

In this example the trigger will match if the returned confidence is about 0.75* and below 1.0**, and the intent is equal to ``.

triggers:
  - expect: wit
    integration: integration.facebook.wit
    intent: weather_condition

steps:
  - say: The weather conditions are nice and sunny today ☀️

Intent routing example

A common use case for NLU is to handle user questions and bot answers. The user input will be sent to Wit to match the intent and then the flow will route the matched intent to a corresponding answer flow.

In this example the faq_component intent is routed to the flow.faq.answers.component flow. If the intent does not have a corresponding flow, then the flow.catchall flow is called.

triggers:
  - expect: wit
    integration: integration.facebook.wit
    min_confidence: 0.8
    max_confidence: 1.0

steps:
  - value: (@ flow.result )
    match:
      ^faq_component$:
        flow: flow.faq.answers.component
        data: (@ flow )
        transfer: true
    default:
      flow: flow.catchall
      data: (@ flow )
      transfer: true
steps:
  - say: >-
      (% trans %)
      A component in Meya is the action that a bot takes at each step of a flow.
      Meya comes with a number of built-in components (see https://docs.meya.ai/reference/meya-component-element),
      but also allows you to create your own custom components (https://docs.meya.ai/docs/getting-started-with-custom-components)
      in **Python**.
      (% endtrans %)

Flow scope variables

The Wit intent and API response get's stored in the following flow scope variables when the trigger matches:

  • (@ flow.result ): contains the matched intent.
  • (@ flow.wit_response ): contains the Wit "message meaning" API response.

Example Wit API response:

{
  "entities": {
    "wit$datetime:datetime": [
      {
        "body": "tomorrow",
        "confidence": 0.9995,
        "end": 27,
        "entities": {},
        "grain": "day",
        "id": "545603966403909",
        "name": "wit$datetime",
        "role": "datetime",
        "start": 19,
        "type": "value",
        "value": "2022-12-03T00:00:00.000-08:00",
        "values": [
          {
            "grain": "day",
            "type": "value",
            "value": "2022-12-03T00:00:00.000-08:00"
          }
        ]
      }
    ]
  },
  "intents": [
    {
      "confidence": 0.9855456948280334,
      "id": "216622623546890",
      "name": "wit$check_weather_condition"
    }
  ],
  "text": "it's going to rain tomorrow",
  "traits": {
    "wit$sentiment": [
      {
        "confidence": 0.5127460956573486,
        "id": "5ac2b50a-44e4-466e-9d49-bad6bd40092c",
        "value": "positive"
      }
    ]
  }
}