Duplicating attachments with text in slack channel output

HI @ricwo @erohmensing

Am getting duplicate text output when i uses dispatcher.utter_attachment(final_msg) where

final_msg={'color': '#5bc0de', 'attachment_type': 'default', 'text': 'Hurray!! i got it for you. Please check the mail'}.

Any specific reason for having argument text when there is already a text key inside attachment in send_attachment function of slack.py?

async def send_attachment(
        self, recipient_id: Text, attachment: Dict[Text, Any], **kwargs: Any
        ) -> None:
        recipient = self.slack_channel or recipient_id
        text = attachment.get("text", "Attachment")
        return super(SlackBot, self).api_call(

I believe because of this change, am getting output like below.


Ah, this is a good point @vigneshp826. I think I added it because without the text=text field, the notification says “this content can’t be displayed” or something like that. However, I must have only been testing with attachments that didn’t have text, and you’re right that this looks weird :grinning_face_with_smiling_eyes:

I think it makes sense to remove the text = attachment.get("text", "Attachment") and text = text lines that I added. Would you be able to create a PR to do so? would be best to merge it into 1.2.x instead of master. Then perhaps re-add the **kwargs that used to be in the api_call so that if there is still text in the message, it will get through.

Thanks @erohmensing, i submitted the PR. Please review and let me know for any changes.

Is there another work around for this besides changing the source code in slack.py? I am using docker-compose and it becomes a lot more complicated to change the code.

I have found a solution

attachment = {
	'image_url': image_url,
	'text': ''