Manipulate some text
.jpg)
Manipulate some text Action Block
With the 'Manipulate some text' block you are able to provide a text and perform text operations like getting the length of the text, trimming text or checking if the text starts or ends with another string.
Text
The text to perform manipulations on. All Variables can be used in this field.

Text Parameter of the Manipulate some text block
Text Operation
The type of text manipulation to perform on the provided Text string. There are several operations to choose from. Below you can find detailed information about each operation and how it can be used.
You can see a list of string methods in the action, or view more detailed descriptions.
| Operation | Information |
|---|---|
| Get Length | Returns the number of characters in the string. |
| Character At | Returns the character at the position of the specified index in the string. |
| Index Of | Returns the index position of the first appearance of a specified query in the string. |
| Last Index Of | Returns the index position of the last appearance of a specified query in the string. |
Get Length
The Get Length operation allows you to return the number of characters of the text provided.
Examples
| Text | Result |
|---|---|
Hello World! |
12 |
BotGhost |
8 |
Character At
The Character At operation returns the character at the specified index.
Index
The position of the character in the string that you'd like to return. Indexes start at 0. All Variables can be used in this input.

Text Operation - Index of the Manipulate some text block
Examples
| Text | Index | Result |
|---|---|---|
Hello World! |
0 | H |
Hello World! |
1 | e |
Hello World! |
7 | o |
BotGhost |
4 | h |
Index Of
The Index Of operation returns the index of the first character of the given portion of text. If there are multiple matches, the first match is returned. If there are no matches, -1 is returned.
Search
The text to find the index of. This input is case sensitive. All Variables can be used in this input.
.png)
Examples
| Text | Search | Result |
|---|---|---|
Hello World! |
e |
1 |
Hello World! |
World |
6 |
Hello World! |
BotGhost |
-1 |
yes, goodbye |
ye |
0 |
Last Index Of
The Last Index Of operation returns the index of the first character of the given portion of text. If there are multiple matches, the last match is returned. If there are no matches, -1 is returned.
Search
The text to find the last index of. This input is case sensitive. All Variables can be used in this input.
.png)
Examples
| Text | Search | Result |
|---|---|---|
Hello World! |
o |
7 |
Hello World! |
Hello |
0 |
Hello World! |
BotGhost |
-1 |
BotGhost is cool, isn't it? |
is |
18 |
| Operation | Information |
|---|---|
| Substring | Returns an extracted portion of text. |
| Slice | Returns an extracted portion of text. |
Substring
The Substring operation allows you to extract text between the start and end indexes. It works similarly to the Slice operation. You can learn more about the differences between the Slice and Substring operations here.
Start Index and End Index
The character index to start extraction from and the character index to end extraction at. The end index represents the index of the first character that should not be included. Indexes start at 0. All variables can be used in this input.

Text Operation - Start Index and End Index of the Manipulate some text block
Examples
| Text | Start Index | End Index | Result |
|---|---|---|---|
Hello World |
0 | 7 | Hello W |
Hello World |
6 | 11 | World |
BotGhost |
4 | 8 | host |
Slice
The Slice operation allows you to extract text between the start and end indexes. It works similarly to the Substring operation. You can learn more about the differences between the Slice and Substring operations here.
Start Index and End Index
The character index to start extraction from and the character index to end extraction at. The end index represents the index of the first character that should not be included. Indexes start at 0. All variables can be used in this input.

Text Operation - Start Index and End Index of the Manipulate some text block
Examples
| Text | Start Index | End Index | Result |
|---|---|---|---|
Hello World! |
0 | 7 | Hello W |
Hello World! |
6 | 11 | World |
BotGhost |
4 | 8 | host |
| Operation | Information |
|---|---|
| To Uppercase | Returns the text with all letter characters displaying in uppercase. |
| To Lowercase | Returns the text with all letter characters displaying in lowercase. |
| Trim | Returns the text with no space characters ( ) at the start or end of the string. |
To Uppercase
The To Uppercase operation converts the provided text to uppercase.
Examples
| Text | Result |
|---|---|
Hello World |
HELLO WORLD |
HELLO WORLD! |
HELLO WORLD! |
botghost |
BOTGHOST |
To Lowercase
The To Lowercase operation converts the provided text to lowercase.
Examples
| Text | Result |
|---|---|
Hello World |
hello world |
HELLO WORLD! |
hello world! |
botghost |
botghost |
Trim
The trim operation allows you to remove whitespaces from the start and end of the provided text.
Examples
| Text | Result |
|---|---|
Hello World |
Hello World |
Hello World |
Hello World |
BotGhost |
BotGhost |
| Operation | Information |
|---|---|
| Includes | Returns true or false based on if the text includes a string. |
| Starts With | Returns true or false based on if the text starts with a string. |
| Ends With | Returns true or false based on if the text ends with a string. |
| Match | Returns matches based on regular expressions. |
| Search | Returns indexes based on regular expressions. |
Includes
The Includes operation checks if your string contains a specific portion of text. It returns true when it does, and false when it doesn't. You can alternatively use the contains comparison type in the Comparison Condition block.
Search
The text that is compared to the original string. This input is case sensitive. All Variables can be used in this input.
.png)
Examples
| Text | Search | Result |
|---|---|---|
Hello World |
World |
true |
Hello World |
lo Wor |
true |
Hello World |
o |
true |
Hello World |
BotGhost |
false |
Starts With
The Starts With operation checks if your string starts with a specific portion of text. It returns true when it does, and false when it doesn't. You can alternatively use the starts with comparison type in the Comparison Condition block.
Search
The text that is compared at the start of the original string. This input is case sensitive. All Variables can be used in this input.
.png)
Examples
| Text | Search | Result |
|---|---|---|
Hello World |
He |
true |
Hello World |
World |
false |
Hello World |
BotGhost |
false |
Ends With
The Ends With operation checks if your string ends with a specific portion of text. It returns true when it does, and false when it doesn't. You can alternatively use the ends with comparison type in the Comparison Condition block.
Search
The text that is compared at the end of the original string. This input is case sensitive. All Variables can be used in this input.
.png)
Examples
| Text | Search | Result |
|---|---|---|
Hello World |
World |
true |
Hello World |
He |
false |
Hello World |
BotGhost |
false |
Match
The Match operation will return the first match from a regular expression (regex) pattern. If there are any capturing groups, it will return them after the match, separated by commas. The variable can also be used as an array when surrounded with the [] brackets.
Regular expressions can be a tricky concept and take practice. Before using this operation, it's advised to check out other resources like Regex101 and MDN Web Documentation to learn more and experiment with regular expressions. You can also use the ChatGPT module or other AI websites to generate regex patterns for you, but they may not always be accurate.
Search
The regular expression pattern to search for. This input is case sensitive. All Variables can be used.
.png)
Examples
| Text | Search | Result |
|---|---|---|
API Requests are Good | [A-Z] | A,P,I,R,G |
This is a test, using regex to find the word test in a sentence. | \btest\b | test,test |
This is a test to find numbers in a sentence. Since there are no numbers here, it will not return any matches | \b\d+\b | null |
Search
The Search operation will return the index of the first match from a regular expression (regex) pattern.
Regular expressions can be a tricky concept and take practice. Before using this operation, it's advised to check out other resources like Regex101 and MDN Web Documentation to learn more and experiment with regular expressions. You can also use the ChatGPT module or other AI websites to generate regex patterns for you, but they may not always be accurate.
Search
The regular expression pattern to search for. This input is case sensitive. All Variables can be used.
.png)
Example
| Text | Search | Result |
|---|---|---|
API Requests are Good | [A-Z] | A,P,I,R,G |
This is a test, using regex to find the word test in a sentence. | \btest\b | test,test |
This is a test to find numbers in a sentence. Since there are no numbers here, it will not return any matches | \b\d+\b | null |
| Operation | Information |
|---|---|
| Replace | Returns the original text with a portion of it replaced. |
| Replace All | Returns the original text with portions of it replaced. |
| Split | Returns the original text divided into an array. |
| Repeat | Returns the original text a specified number of times. |
Replace
The Replace operation replaces the first occurrence of a substring from the original text with another string you've specified.
Search
The portion of text that must be replaced in the text. This input is case sensitive. All Variables can be used in this input.

Text Operation - Search of the Manipulate some text block
Replacement
The portion of text to replace with. This input is case sensitive. All Variables can be used in this input.

Text Operation - Replacement of the Manipulate some text block
Examples
| Text | Search | Replacement | |
|---|---|---|---|
Hello World! | World | everyone | Hello everyone! |
Hello World! | BotGhost | Hello BotGhost World! | |
Cats are cute | C | R | Rats are cute |
Replace All
The Replace All operation replaces all occurrences of a substring from the original text with another string you've specified.
Search
The portion of text that must be replaced in the text. This input is case sensitive. All Variables can be used in this input.

Text Operation - Search of the Manipulate some text block
Replacement
The portion of text to replace with. This input is case sensitive. All Variables can be used in this input.

Text Operation - Replacement of the Manipulate some text block
Examples
| Text | Search | Replacement | Result |
|---|---|---|---|
Hello World | World | everyone | Hello everyone! |
you are smart, aren't you? | you | we | we are smart, aren't we? |
Bitter | t | l | Biller |
Split
The Split operation separates your string with commas based on a delimeter. The variable can also be used as an array when surrounded with the [] brackets.
Search
The text that your string will be split around. This input is case sensitive. All Variables can be used.
.png)
Examples
| Text | Search | Result |
|---|---|---|
20/04/2024 |
/ |
20,4,2024 |
docs.botghost.com |
. |
docs,botghost,com |
Hello everyone! |
c |
Hello everyone! |
Repeat
The Repeat operation duplicates your string a specified number of times.
Count
The number of times your string will appear. All Variables can be used in this input.
.png)
Examples
| Text | Count | Result |
|---|---|---|
ah |
5 | ahahahahah |
Hello! |
2 | Hello! Hello! |
| Operation | Information |
|---|---|
| JSON Stringify | Returns the original text surrounded by quotes (") with escaped quotes and line breaks. |
| JSON Stringify (No Enclosing Quotes) | Returns the original text with escaped quotes and line breaks. |
| Sanitize | Returns the text with special characters escaped for safe use. |
| Unsanitize | Returns the original text with escaped characters restored. |
| Image URL to Base64 | Returns the image from a URL encoded as Base64, optionally including a data URI prefix. |
JSON Stringify
The JSON Stringify operation allows you to automatically manipulate and escape quotes and line breaks in the given text for it to work in the Send an API Request action. The result will include quotes (") around the text.
Examples
| Text | Result |
|---|---|
| Hello "World"! | "Hello \"World\"!" |
| Line Break | "Line\nBreak" |
| Not a line break \n | "Not a line break \\n" |
JSON Stringify (No Enclosing Quotes)
The JSON Stringify (No Enclosing Quotes) operation allows you to automatically manipulate and escape quotes and line breaks in the given text for it to work in the Send an API Request action. The result will not include quotes (") around the text.
Examples
| Text | Result |
|---|---|
| Hello "World"! | Hello \"World\"! |
| Line Break | Line\nBreak |
| Not a line break \n | Not a line break \\n |
Sanitize
The sanitize operation will return the exact same text provided without replacing vars. These will not be replaced also when used in replies.
Examples
| Text | Result |
|---|---|
| {myvariable} | {myvariable} |
| Hello {user_name} | Hello {user_name} |
Unsanitize
The unsanitize operation will return the exact same text and undo any sanitization previously made. Variables will be replaced.
Examples
| Text | Result |
|---|---|
| {myvariable} | That's the value of myvariable |
| Hello {user_name} | Hello tomtoise |
Image URL to Base64
Allows you to fetch an image from a given URL and convert it into Base64, with options to return either raw Base64 data or a full data URI for use in API requests, embeds, or external systems.
Output Format
Allows to pick the output format you prefer.
| Full Data URL (data:image/...;base64,...) | Returns the image as a complete data URL, including the MIME type and Base64 prefix. This is useful when embedding images directly or when a full image source is required. |
| Base64 Only | Returns only the raw Base64-encoded image data without any prefix. This is useful for API requests or systems that explicitly require Base64 input. |

Examples
| Text | Result | |
|---|---|---|
| https://botghost.com/assets/logo.png | Full Data URL | data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... |
| https://botghost.com/assets/logo.png | Base64 Only | iVBORw0KGgoAAAANSUhEUgAA... |
| https://botghost.com/assets/banner.jpg | Base64 Only | tLYMeRjPMCS1-1WNjQlaqQADn |
Variable
.png)
The Variable field allows you to name the variable that can be used in other Actions and Conditions that follow this action block in the same command or event. You can use the clipboard icon under Result Variable to copy this variable to your device's clipboard.
If the variable used in this field already has a value, the previous value will be overwritten and cannot be accessed again.