This document covers various examples to help you use the Apps-Engine UI blocks so you can create meaningful user interactions in your apps. The UI blocks are triggered by an action or a condition. In these examples, the UI blocks will be triggered when a message is starred. First, we will see how to create a single block and then we will add more elements to create complex visual layouts.
Create a section block
Let’s create a basic section that contains some text. This will be displayed in a room when a message is starred. The main app class looks like this:
Whenever a message is starred, the app bot returns the text message as shown in this screenshot:
Stack multiple blocks
In the same example, we are going to add more blocks and elements to demonstrate how you can create complex UI layouts.
Add an image block
Add a divider block and an action block
Now, instead of the image, we will add a divider and an action block. The action block contains a button element.
The following screenshot shows the UI:
Add an input block
We will define an input block containing the static menu element type:
The following screenshot shows the blocks returned by the app bot:
Add a context block
To the previous code snippet, we will add a context block definition as follows:
The following screenshot shows what the context block looks like:
Add a preview block
To this example, we will now add a preview block as follows:
The following screenshot shows how the preview block appears in the UI: