Sending a Slack Message via Xano - How to escape \n markdown in Xano?
Options
![Stephen Smith](https://us.v-cdn.net/6037124/user_avatars/2826800.jpg)
Stephen Smith
Member ✭
I am trying to send a slack chat notification via Xano.
I can successfully send a slack message using the external API request function in Xano using a POST.
As part of the POST you need to send through a JSON body with a value of...
{
"text": "This is my text to send\nmy second line"
}No matter what I do the newline markdown \n, is formatted as \n in the request sent from Xano and not interpreted correctly by Slack.
[image.png]
How would I go about escaping \n?
Any help as always is greatly appreciated. 😀
I can successfully send a slack message using the external API request function in Xano using a POST.
As part of the POST you need to send through a JSON body with a value of...
{
"text": "This is my text to send\nmy second line"
}No matter what I do the newline markdown \n, is formatted as \n in the request sent from Xano and not interpreted correctly by Slack.
[image.png]
How would I go about escaping \n?
Any help as always is greatly appreciated. 😀
Comments
-
- I might need some more info. I just ran various tests using \n and it correctly created a newline in the messages sent to slack.
-
Hey ,
I have created a slack app via - https://api.slack.com/
For my app, I then created an incoming webhook, which is installed to a specific channel.
Within Xano I have a simple function which consists of...
• A text variable which contains "This is my text to send\nmy second line"
• An external API request to post to my slack apps webhook (which sends the text to my slack channel)
[image.png][image.png]
[image.png]No matter which way I try the line break in the text variable \n \n "\n" slack does not seem to interpret it correctly.
The Xano output will always escape the character.
[image.png]Output in Slack:[image.png]
I am not sure if this is a Xano issue or a Slack issue, but I am starting to lean more towards this being a slack issue? What do you think? -
- ah you are passing the text in a variable...
So passing the text through as an input, you have it as part of the JSON input which lets you enter in data in escaped form. So as an input:
this is my text to send\n my second line
works perfectly fine.
However, a regular variable is post-escaped. So you would need to say:
this is my text to send"\n"my second line
|json_encode|
[CleanShot 2022-01-21 at 11.55.25.png] -
, sorry for the late reply. Just wanted to say this worked. Thank you.
-
Same problem but been unable to get this working.
[image.png]Adding "\n" as concatenation, then using json_encode on the variable after
[image.png]
Result on slack:
[image.png]Any ideas? -
Solved:
Use shift+enter instead of \n as the separator -
Just wondering, how do you send Slack messages from Xano? Do you have to use Slack's API?
Is there a simpler way? (an integration)
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback