'Slack notification from lambda not breaking message in newline

I am using below code to send message to slack from aws lambda, need to have newline between first and second variable. Both of them are of string type. Message received on slack is on single line - first second I need output on slack as first second Can someone help!!

msg = {
        "text" : first+'\n'+second
        
    }
    encoded_msg = json.dumps(msg).encode('utf-8')
    resp = http.request('POST',hook_url, body=encoded_msg)

 


Solution 1:[1]

{
  "type": "mrkdwn",
  "text": first + '\n' + second
}

Refer to this: https://api.slack.com/reference/block-kit/composition-objects#text

Slack has introduced Block Kit, and now type is introduced as mrkdwn where you can modify the text as per the requirements.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akash Kumar Singhal