Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack API not accepting \n for new line when using slash commands

I've built a simple slack integration (slash command) to return names from my table. The result should look like

Name1

Name2

Name3

For this i simply generate a text string like this:

foreach($names as $name) {
    $text .= $name . ' \n';
}

The integration itself is working fine, however the result looks like this

Name1 \nName2\n

like image 225
Frnak Avatar asked Nov 30 '25 03:11

Frnak


1 Answers

Looks like this is an issue in slack.

Apparently it can be solved by using double quotes as such: "\n".

Your code will become:

foreach($names as $name) {
    $text .= $name . "\n";
}
like image 101
Shubham Vasaikar Avatar answered Dec 02 '25 04:12

Shubham Vasaikar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!