.. _custom_code: Architecture Deep Dive ====================== The whole platform is dockerized, so we suggest you run your custom code in a docker container as well. Overview -------- Let's get started with an overview of the different parts of the Rasa Platform and where your application (e.g. custom actions, in/out channels) fit in: .. image:: ../_static/images/platform_overview_drawio.png The ``Chat User`` is the person talking to your bot. The ``Platform User`` is a user of the management interface to train and test models. The image shows the server (docker host) running a number of different containers: - application code (a docker container running your custom actions and input / output connectors) - Rasa platform (different apis, the platform ui as well as Core and NLU) - database The part you need to provide is highlighted in green. The following instructions are will show you how to create that container. Creating your application ------------------------- There are a couple of things your application needs to do: 1. **send and receive messages** from the chat channel - the ``Input Connector`` and ``Output Connector``. Your code needs to connect to the chat channel, e.g. for facebook that means starting a webservice, listening for the webhook calls from facebook messenger and sending messages using the facebook API. 2. **execute custom action logic** - the ``Custom Action Logic`` block. This contains any custom action code written, e.g. to validate input or connect to external APIs (`see Rasa Core Action docs `_). 3. **connect to Rasa Core** - the ``Rasa Core Remote Connector``. For python this implementation is part of the platform python package. If you want to use a different language, you can use the python connector as inspiration. It implements the `remote action execution `_ interface from Rasa Core. 4. **upload models to Core / NLU** - the green model containers ``nlu model`` and ``core model``. This is not done directly in your application container, instead you upload your stored models to Rasa NLU and Rasa Core. You can write your application code in any language. We suggest you use python, which will allow you to reuse the *Rasa Core Remote Connector* as well as existing *Input* and *Output Connectors* (like Facebook Messenger). Throughout the docs, we assume that your application container is started on the same server as the Platform deployment. On the server, requests to ``https://rasa.example.com/app`` are automatically forwarded to port ``5001``. If your container is started and listening to that port it will automatically accept requests from that url. You are free to run your application container on a different server though. .. topic:: What's next? To make it easier to get started, we created an :ref:`example_application` and a small tutorial that guides you through that example.