New in 3.6You can now extend Sanic features such as middlewares, listeners, background tasks
and additional routes.
rasa-sdk when starting the action server.
Step-by-step guide on creating your own Sanic extension in rasa_sdk
This example will show you how to create a Sanic listener using plugins.Create the rasa_sdk_plugins package
Create a package in your action server project which you must namerasa_sdk_plugins. Rasa SDK will try to instantiate this package in your project to start plugins.
If no plugins are found, it will print a debug log that there are no plugins in your project.
Register modules containing the hooks
Create the packagerasa_sdk_plugins and initialize the hooks by creating an __init__.py file where the plugin manager will look for the module where the hooks are implemented:
rasa_sdk_plugins/__init__.py
Implement your hook
Implement the hookattach_sanic_app_extensions. This hook forwards the app object created by Sanic in the rasa_sdk and allows you to create additional routes, middlewares, listeners and background tasks. Here’s an example of this implementation that creates a listener.
In your rasa_sdk_plugins.your_module.py:
rasa_sdk_plugins/your_module.py