# Discord Message Preparer — Split Long Text and Code (`creatieve_naald/discord-message-preparer`) Actor

Split long text and supported code blocks into ordered Discord JSON payloads under 2000 characters, with mentions disabled. No bot token, no message sending. $0.01 per prepared text.

- **URL**: https://apify.com/creatieve_naald/discord-message-preparer.md
- **Developed by:** [Stefan Schellen](https://apify.com/creatieve_naald) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 prepared texts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Discord Message Preparer

Prepare long release notes or AI responses as ordered Discord JSON payloads. Call this utility from an HTTP workflow, then send each returned `payload` yourself in order. This Actor does **not** send Discord messages or need a Discord token.

### Why use it?

Discord webhook content is limited to 2,000 characters. Cutting at that limit can leave a code fence open, while truncation loses the end of your report. This utility splits text and closes/reopens supported code fences. Every payload disables mentions by default.

Free copy/paste splitters and local libraries are good alternatives. Use this hosted step when you want an API from n8n, Make or an agent without maintaining the parser. It is not a full Markdown renderer.

### Input

````json
{"text":"Release notes\n\n```python\nprint('Hello')\n```"}
````

The single `text` field accepts up to 65,536 UTF-8 bytes. Output is limited to 50 messages. If the whole input cannot be prepared within these limits, the run fails instead of returning a truncated partial result.

### Output and sending

One dataset item contains `messages`, `messageCount`, `normalizedSource`, `segments`, `omittedWhitespaceRanges` and `warnings`. Each message includes zero-based `index`, `sourceStart`, `sourceEnd` and:

```json
{"payload":{"content":"Release notes\n\n","allowed_mentions":{"parse":[],"replied_user":false}}}
```

Send **the entire `payload` object**, not just `content`, to your Discord webhook. Otherwise the mention policy is lost. Use sequential requests, respect Discord rate-limit responses and handle retries in your workflow. This utility provides no delivery or deduplication guarantee.

In n8n: obtain the dataset item, split out its `messages` array, loop with batch size 1, and POST `payload` as JSON to your own webhook. Keep the webhook URL in credentials; do not send it to this Actor. This recipe has not yet been imported and tested end to end.

### Supported text and explicit limits

- Plain text and column-zero triple-backtick code fences, with an optional language label up to 24 ASCII letters/digits or `_+.-`.
- Code blocks may produce separate messages from adjacent prose. Each code fragment gets its own opening and closing fence.
- Unclosed, indented, longer, inline or tilde fences are rejected. Embedded triple backticks inside code are rejected.
- Other inline Markdown is passed through, but **not rebalanced** at split boundaries. Links, bold, spoilers and quotes can therefore render differently across messages. Do not use this for guaranteed preservation of arbitrary Markdown.
- Each payload is capped at 2,000 UTF-16 code units conservatively. Unicode code points are not split, but combining characters and multi-code-point emoji can cross a boundary.
- CRLF/CR line endings become LF. Whitespace-only chunks are omitted from sendable messages and recorded explicitly. The entire normalized source remains in the output.
- Source offsets are Python/Unicode code-point offsets into `normalizedSource`, not UTF-16 or byte offsets. Segment ranges include original fences; message ranges refer to body text without generated wrappers.

### Trial price

$0.01 per successfully prepared text input, regardless of how many parts it produces; platform usage included. Invalid inputs have no successful-processing event.

### Data handling and verification

Input and output use Apify storage and its retention settings. Source text appears in the dataset and output record. Do not treat it as ephemeral or send secrets. The parser makes no network requests and receives no Apify credentials; the service saves output before charging and avoids recharging uncertain restarts.

Local tests cover payload limits, source coverage, Unicode, fences, mention fields, bounded worker execution and billing/restart behavior. Actual Discord acceptance and client rendering have not been tested. The Actor never posts messages on your behalf.

References: [Discord webhook fields](https://docs.discord.com/developers/resources/webhook#execute-webhook), [n8n release-note limit report](https://community.n8n.io/t/discord-node-failing-to-send-multiple-messages-using-webhook/128801/2).

# Actor input Schema

## `text` (type: `string`):

Text up to64KiB. Supports column-zero triple-backtick code fences; inline formatting is not rebalanced.

## Actor input object example

````json
{
  "text": "Release notes\n\n```python\nprint(\"Hello\")\n```"
}
````

# Actor output Schema

## `result` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

````javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "text": `Release notes

```python
print("Hello")
````

};

// Run the Actor and wait for it to finish
const run = await client.actor("creatieve_naald/discord-message-preparer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

````

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "text": """Release notes

```python
print(\"Hello\")
```""" }

# Run the Actor and wait for it to finish
run = client.actor("creatieve_naald/discord-message-preparer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

````

## CLI example

````bash
echo '{
  "text": "Release notes\\n\\n```python\\nprint(\\"Hello\\")\\n```"
}' |
apify call creatieve_naald/discord-message-preparer --silent --output-dataset

````

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,creatieve_naald/discord-message-preparer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/i04c7beNE7hjc5UvW/builds/gr2s0wQcaHmZ7fBWo/openapi.json
