Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
GITBOOK-1295: apps engine uplevel
Browse files Browse the repository at this point in the history
  • Loading branch information
Funke Olasupo authored and gitbook-bot committed May 15, 2024
1 parent 7183f5f commit 1e988a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
11 changes: 7 additions & 4 deletions apps-engine/adding-features/registering-api-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ Then, let's implement the method `post`, which will be executed every time the A

## Test the result

Deploy your app. You can check the complete endpoint URL you registered for the app on the **App Info** page.
[Deploy your app](../getting-started/creating-an-app.md). You can check the complete endpoint URL you registered for the app on the **App Info** page.

![](<../../.gitbook/assets/image (19) (1).png>)

Open the terminal and use curl to post some data to the endpoint. The result should be as follows:
Open the terminal and use curl to post some data to the endpoint. For example, use the following command snippet:

{% code overflow="wrap" %}
```bash
> curl --data 'Jack=Hello :)&Lucy=Hi!' -X POST http://localhost:3000/api/apps/public/bc4dd4a1-bf9b-408e-83a4-aba7eba0bf02/api
{"messageId":"dREmKaR7qHyN98rtZ"}
curl -X POST http://localhost:3000/api/apps/public/0b57f89a-5753-4298-9695-caba6eb21e12/api \
-H "Content-Type: application/json" \
-d '{"Jack":"Hello :)", "Lucy":"Hi!"}'
```
{% endcode %}

It returns a response with the `messageId` similar to `{"messageId":"NNWbiDHbpa5Tn27XB"}`. The app bot also sends the message to the general channel as shown below:

![](<../../.gitbook/assets/image (20).png>)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ protected async extendConfiguration(configuration: IConfigurationExtend, environ
```
{% endcode %}

{% hint style="info" %}
Add the following import statement to your file for `UIActionButtonContext`:

```
import {UIActionButtonContext } from '@rocket.chat/apps-engine/definition/ui';
```
{% endhint %}

Registering a button requires `ui.registerButton` permission. Add it to your app manifest file (`app.json`) as shown below:

{% code title="app.json" %}
Expand Down Expand Up @@ -120,6 +129,14 @@ protected async extendConfiguration(configuration: IConfigurationExtend, environ
```
{% endcode %}

{% hint style="info" %}
Add the following import statement to your file for `UIActionButtonContext` and `RoomTypeFilter`:

```
import { RoomTypeFilter, UIActionButtonContext } from '@rocket.chat/apps-engine/definition/ui';
```
{% endhint %}

Now the button can only be seen in public and private channels and direct messages, by users that have the `create-d` permission and the `admin` role. The user must also be a `moderator` of the channel to see the action button for messages in that channel.&#x20;

## Add localization
Expand Down
2 changes: 1 addition & 1 deletion apps-engine/getting-started/creating-an-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Learn more about the module details from the [Rocket.Chat Apps Typescript Defini

### Step 4: Implement the app functionality

For this example, the app records "Hello, World!" in the Rocket.Chat administration interface.&#x20;
For this example, the app records "Hello, World!" in the app's log.

To log data, you must first have access to the logger, that is, an object of type `ILogger`. The parent class logs data to the administration interface using an `ILogger` object. We only require access to this object. Since the logger object is private to the `App` class, the `this` keyword cannot be used to access it directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ npm install
npm run compile
```

3. Setup your Rocket.Chat environment following the guide on:

[rocket.chat-server](../../rocket.chat/rocket.chat-server "mention")

3. Setup your Rocket.Chat environment following the guide on [server-environment-setup](../../open-source-projects/server/server-environment-setup/ "mention")
4. After setting up, go to the directory and run the following command:

```bash
Expand Down

0 comments on commit 1e988a7

Please sign in to comment.