os / slacker

Full-featured Python interface for the Slack API
Apache License 2.0
1.6k stars 245 forks source link

Attachments don't work? #10

Closed brainsik closed 10 years ago

brainsik commented 10 years ago

Hello. I'm trying to post a message with an attachment, but it doesn't seem to work. OR, I'm not using it correctly, in which case, could you please add an example to the README.

This is what I'm trying:

print slack.chat.post_message('#sandbox', 'text', attachments={'fallback':'fallback', 'fields':[{'title':'title','value':'value'}]}).body

All I end up seeing is the message "text" without anything else.

Thanks!

brainsik commented 10 years ago

Figured it out. The attachments field needs to be a string with JSON in it:

print slack.chat.post_message('#sandbox', 'text', attachments=json.dumps([{'fallback':'fallback', 'fields':[{'title':'title','value':'value'}]}])).body
os commented 10 years ago

Great, thanks.