from slackclient import SlackClient


def send_to_slack(app_token, userid, message):
    client = SlackClient(token=app_token)
    client.api_call(
        "chat.postMessage", channel="@%s" % userid, text=message, as_user=True
    )
    return True

from slackclient import SlackClient


def send_to_slack(app_token, userid, message):
    client = SlackClient(token=app_token)
    blocks = [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text":  message,
            }
        },
    ]
    client.api_call(
        "chat.postMessage", channel="@%s" % userid, blocks=blocks, as_user=True
    )
    return True

Allow to format messages sent to Slack
Allow to format messages sent to Slack

  from slackclient import SlackClient
  
  
  def send_to_slack(app_token, userid, message):
      client = SlackClient(token=app_token)
+     blocks = [
+         {
+             "type": "section",
+             "text": {
+                 "type": "mrkdwn",
+                 "text":  message,
+             }
+         },
+     ]
      client.api_call(
-         "chat.postMessage", channel="@%s" % userid, text=message, as_user=True
+         "chat.postMessage", channel="@%s" % userid, blocks=blocks, as_user=True
      )
      return True
  
Allow to format messages sent to Slack
## Code Before:
from slackclient import SlackClient


def send_to_slack(app_token, userid, message):
    client = SlackClient(token=app_token)
    client.api_call(
        "chat.postMessage", channel="@%s" % userid, text=message, as_user=True
    )
    return True

## Instruction:
Allow to format messages sent to Slack
## Code After:
from slackclient import SlackClient


def send_to_slack(app_token, userid, message):
    client = SlackClient(token=app_token)
    blocks = [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text":  message,
            }
        },
    ]
    client.api_call(
        "chat.postMessage", channel="@%s" % userid, blocks=blocks, as_user=True
    )
    return True
