- Connect the Discord module and specify the bot token in its settings.
- Set up a custom business process for sending messages.
- Create a POST endpoint to send data from the frontend to the backend.
- Create a form to send a message in your web or mobile application.
For more information about modules, see the article "Basics of Working with Modules"
1. Go to the modules section (1), on the Marketplace tab (2) find the Discord module (3) and install it (4).
2. Open Discord settings and specify your bot token in the appropriate field (1), then save the changes (2).
3. Go to the business logic section (1) and create a new business process. Add Discord block: Send message (2). In the starting block, add input variables for the message text and the ID of the channel to which you will send it (3). Connect the stream and data connections as shown in the screenshot. Don't forget to save the scheme (4). We will tell you more about business processes in the AppMaster.io 101 training course.
4. Now go to the endpoints section (1) and create a new API endpoint. Select the POST method, specify the route and the group to which you want to add it (2). Link it to the newly created business process (3) and click OK (4). You can watch a video about endpoints here.
Form in a web application
5. Let's set up sending messages through the Discord bot in the web application. Go to your web app and open it for editing (1). Create a new form for submitting data, choosing the Create Record type for it and the newly created endpoint (2). Apply the changes (3).
6. Add a button to the form with an onClick trigger, which will trigger the Submit Form action for the created form.
7. This is how the form and button will look in the web application editor (1). Save changes (2) and publish it (3).
Send a message!
8. Check the work of the form. Go to the published application, on the page with the form, enter the message and the ID of the channel you want to send it to.
9. Check that the bot has posted a message to your Discord channel.
A simple form for submitting messages to Discord is ready. You can complicate it, for example, by setting up simultaneous sending of a message to the Discord and Telegram channels. For more information on setting up a Telegram bot, see this article.
In order not to miss information about new modules and settings, follow our blog and subscribe to the Telegram channel.