Slack API - Attatchments from custom bot post as plain text
As it turns out, the call to
slack_client.api_call("chat.postMessage", channel=self.channel, attachments=self.msg, as_user=True)
apears to add the top layer { "attachments": ... }
for you. So by changing my self.msg
to simply be:
self.format = [{
"fallback": "%s, %s" % (self.jiraIssueObj.fields.summary, self.link),
"pretext": "Detail summary for %s" % self.jiraIssueObj,
"title": self.jiraIssueObj.fields.summary,
"title_link": self.link,
"text": self.jiraIssueObj.fields.description[0:self.maxSummary],
#"color": "#7CD197",
"mrkdwn_in": ["text", "pretext", "fields"]
}]
without this outer { "attachments": ... }
wrapper, the api was able to post the message attachment as expected.