# Buggy code
async def send_text_with_buttons(
    self,
    recipient_id: Text,
    text: Text,
    buttons: List[Dict[Text, Any]],
    **kwargs: Any,
) -> None:
    recipient = self.slack_channel or recipient_id

    text_block = {"type": "section", "text": {"type": "plain_text", "text": text}}

    if len(buttons) > 5:
        raise_warning(
            "Slack API currently allows only up to 5 buttons. "
            "Since you added more than 5, slack will ignore all of them."
        )
        return await self.send_text_message(recipient, text, **kwargs)

    button_block = {"type": "actions", "elements": []}
    for button in buttons:
        button_block["elements"].append(
            {
                "type": "button",
                "text": {"type": "plain_text", "text": button["title"]},
                "value": button["payload"],
            }
        )
    await self.client.chat_postMessage(
        channel=recipient,
        as_user=True,
        text=text,
        blocks=[text_block, button_block],
    )


# Traceback (ValueError)
File "c:\users\jitesh\appdata\local\programs\python\python37\lib\site-packages\sanic\request.py", line 173, in load_json
self.parsed_json = loads(self.body)
ValueError: Expected object or value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\jitesh\appdata\local\programs\python\python37\lib\site-packages\sanic\app.py", line 976, in handle_request
response = await response
File "c:\users\jitesh\appdata\local\programs\python\python37\lib\site-packages\rasa\core\channels\slack.py", line 356, in webhook
metadata = self.get_metadata(request)
File "c:\users\jitesh\appdata\local\programs\python\python37\lib\site-packages\rasa\core\channels\slack.py", line 329, in get_metadata
slack_event = request.json
File "c:\users\jitesh\appdata\local\programs\python\python37\lib\site-packages\sanic\request.py", line 167, in json
self.load_json()
File "c:\users\jitesh\appdata\local\programs\python\python37\lib\site-packages\sanic\request.py", line 177, in load_json
raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json

# Fixed code
async def send_text_with_buttons(
    self,
    recipient_id: Text,
    text: Text,
    buttons: List[Dict[Text, Any]],
    **kwargs: Any,
) -> None:
    recipient = self.slack_channel or recipient_id

    text_block = {"type": "section", "text": {"type": "plain_text", "text": text}}

    if len(buttons) > 5:
        raise_warning(
            "Slack API currently allows only up to 5 buttons. "
            "Since you added more than 5, slack will ignore all of them."
        )
        return await self.send_text_message(recipient, text, **kwargs)

    button_block = {"type": "actions", "elements": []}
    for button in buttons:
        button_block["elements"].append(
            {
                "type": "button",
                "text": {"type": "plain_text", "text": button["title"]},
                "value": button["payload"],
            }
        )

    await self._post_message(
        channel=recipient,
        as_user=True,
        text=text,
        blocks=[text_block, button_block],
    )