Discord module: connect bot and send messages
Instruction to configure the Discord module to send messages directly from your application.

The Discord module allows you to send messages with a bot directly from your application. To implement this function, you need:
- 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".
Discord module
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).

Business process
1. 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.

Endpoint
1. 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
1. 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).

2. Add a button to the form with an onClick trigger, which will trigger the Submit Form action for the created form.

3. 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!
1. 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.

2. 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.
FAQ
Install the Discord module from the Marketplace, open its settings, enter your Discord bot token, and save. Your app can then use the module to send messages through that bot.
Create a custom business process and add the Discord block named Send message. Give the process inputs for the message text and the target channel ID, then connect and save the process.
Use a POST endpoint linked to your message-sending business process. The frontend sends the form values to this endpoint, and the process passes them to the Discord bot.
The channel ID tells Discord where the bot should post. Enter the ID of the specific Discord channel you want the message to reach.
Create a form in the web app editor, select the Create Record form type, and connect it to the POST endpoint. Add fields that supply the message and channel ID.
Add a button with an onClick trigger and set its action to Submit Form for the form you created. Save and publish the application so people can use it.
Open the published app, enter a message and a valid channel ID, then submit the form. Check the chosen Discord channel to confirm that the bot posted it.
Check the bot token in the module settings, the channel ID entered in the form, and the endpoint link to the business process. Also make sure the bot belongs to the Discord server and has permission to post in that channel.
Yes. Use the same form data in a business process that includes both Discord and Telegram message blocks. Each block needs the destination details and its own configured bot or module settings.
Yes. You can use the Discord module in a mobile app by creating a form that sends data to the same POST endpoint. The backend business process stays the same.


