Extending Rasa
Extending Rasa
Developing a custom Rasa NLU component, channel, or policy is straightforward.
In the project you created with botfront init
you will find a rasa
folder containing the material needed to build your Rasa image. When you run botfront up
, the Rasa image used is built from this folder.
Example: custom NLU component
We provided you with an exemple of custom NLU component. Look for the ignore_sample_component.py
file in the rasa
folder.
All this component does is adding a field called it_works
to the NLU results.
Let's use it:
- Start your project
botfront up
and runbotfront watch
. This will watch therasa
andactions
folders for changes and rebuild/restart the images when necessary so every change you make will be reloaded automatically. - Rename
ignore_sample_component.py
tosample_component.py
(the watcher ignores files containingignore
). Botfront will rebuild and restart the Rasa image with your extensions installed as a pip package. - Go to NLU -> Settings -> Pipeline and add you new component:
pipeline:- name: sample_component.SampleComponent- name: WhitespaceTokenizer...
- Train
- Head to the API tab and observe the result, it_works :)
{"intent": {"name": "chitchat.greet","confidence": 0.9417732358},"entities": [],"language": "en","it_works": true, // It just works"intent_ranking": [{"name": "chitchat.greet","confidence": 0.9417732358},{"name": "chitchat.bye","confidence": 0.0582267493}],"text": "hello"}
That's it. Creating a custom connector or core policy works exactly the same.