Facebook messenger - no longer able to send local images

I have been using the facebook notify integration for a long time to receive camera snapshots. However, a while ago, the images simply stopped arriving.

Strangely enough, I can still send some random image from the web by using a call like this:

service: notify.messenger
data: 
  message: Test message
  data:
    attachment: 
      type: image
      payload: 
        url: https://i.imgur.com/hm54HiQ.jpeg
  target: 
  - my_user_id

The image shows up in my Messenger instantly.

But if I try to use this with an image from the local system (like this), the message never arrives:

service: notify.messenger
data: 
  message: Test message
  data:
    attachment: 
      type: image
      payload: 
        url: https://external.hass.url/local/snap-image.png
  target: 
  - my_user_id

What I have checked:

  • the image does exist in HAss/config/www
  • the external URL is valid, and reachable from the outside (I open the URL with a browser, I see the image)
  • the HTTPS certificate for the external URL is valid and trusted

In the logs, all I see are messages like this:

Logger: homeassistant.components.facebook.notify
Source: components/facebook/notify.py:98
integration: facebook (documentation, issues)
First occurred: April 17, 2024 at 11:06:14 AM (40 occurrences)
Last logged: 8:04:36 PM

Error 400 : (#100) Upload attachment failure. (Code 100)

[ Editing to add additional info: when sending the same request directly to the FB API (via curl), I get a somewhat more detailed error message:

{"error":{"message":"(#100) Upload attachment failure.","type":"OAuthException","code":100,"error_subcode":2018047,"fbtrace_id":"A7yf..."}}

According to the documentation, “a common way to trigger this error is that the provided media type does not match type of file provided int the URL”. However, if I access the external URL from my browser, the response header of “Content-Type: image/png” seems correct. ]

[ One more update: if I upload the .png file to another web server, I can send it using the exact same request just fine. The problem seems to be with the way the internal web server in Home Assistant is serving the files - somehow it is serving them in a way that the Facebook servers will not accept… ]

Also, I can send text messages without any issues.

Anyone who could point me in the right direction for troubleshooting this?

Thank you!

I have been able to work around this by simply calling the API manually, and uploading the local files directly. But it sure would be nice to know why this is happening, and how I could get the URL-based version to work again…

If anyone else is interested, here is my workaround:

  • the service that does the upload
  messenger_upload_photo: >
    curl -X POST "https://graph.facebook.com/v19.0/{{page_id}}/messages?access_token={{access_token}}" 
    -F recipient='{"id":"{{recipient}}"}' 
    -F message='{"attachment":{"type":"image", "payload":{}}}'  
    -F filedata=@/config/www/{{filename}}
  • the actual service call:
service: shell_command.messenger_upload_photo
data:
  page_id: 1234
  access_token: ABCD
  recipient: 11234441   # Using IDs for recipients - to switch to phone numbers, you need to change to "recipient.phone_number" in the service def
  filename: name_of_file.png # should exist in /config/www