Integration

Building a Discord Bot with No Code (Part 1)

Want to send automated messages to a Discord channel on a schedule — without touching a line of code? With Xano's Tasks feature and Discord's webhook integration, you can have a fully functional Discord bot up and running in just a few minutes. In this guide, you'll walk through every step of building a bot that picks a random pun from a list and sends it to your Discord channel each day.

Setting Up Your Task in Xano

The foundation of this bot is Xano's Tasks feature, which lets you run business logic on a scheduled basis. Navigate to Tasks in your Xano instance and create a new task — this is where all your automation logic will live. Once inside the task, you'll have access to a function stack where you can chain together variables, filters, and external API requests.

Storing and Selecting Messages

Start by creating a variable to hold your messages. In this example, the messages are structured as a JSON object — think of it as a dictionary — where the keys represent days of the week (1 through 5) and the values are arrays of puns or jokes. This gives you multiple options per day, adding some variety to your bot's output.

Next, create a second variable to capture the current day of the week. Set its value to now (a timestamp) and use Xano's built-in timestamp formatter to convert it into a day number. Using PHP's N format gives you an ISO 8601 numeric day, where 1 is Monday and 7 is Sunday — perfect for a work-week bot.

From there, use a get filter on your messages object to retrieve the array that matches the current day key, storing that result in a message to send variable.

Picking a Random Message

To keep things interesting, use Xano's Random Number function to generate a number between 0 and 2 (representing the index positions in your array). Then use the Update Variable function combined with an expression to pull the item at that random index from your message to send array. You can verify this is working correctly using the Stop and Debug function, which lets you inspect variable values mid-stack.

Connecting to Discord via Webhook

Head over to Discord, select your target channel's settings, and navigate to Integrations to create a new webhook. Copy the webhook URL and return to Xano. Add an External API Request function, paste in your webhook URL, set the method to POST, and add a single parameter with the path content and the value set to your message to send variable. Save and run — your message should appear in Discord almost instantly.

Scheduling Your Bot

With the logic working, the last step is setting your timing. In the task's timing block, define a start time and set it to repeat every 24 hours. You can choose anything from every 5 seconds to every 4 weeks depending on your needs. Enable the task, publish your changes, and your Discord bot is live.

From here, the possibilities are wide open — pull data from a Xano database, call a third-party API like OpenAI for dynamic content, or react to real-time events. Xano gives you the tools to connect and automate across the web, all without writing a single line of code.

Sign up for Xano

Join 100,000+ people already building with Xano.
Start today and scale to millions.