Images


warning

Image support may be degraded on certain browsers. Browsers like Safari & Firefox tend to work best. Images should stay around 10KB.

Quickstart

Using Data URIs, you can send images through the Message API. You can do a quick proof of concept in your bot in a few seconds. Both of the examples below are covered in the tutorial video above.

From a static image

  1. Find an image you want to use
  2. Use this tool by ezgif to convert your image to a Data URI

Convert image to data URI

  1. Set the Include tags for option to Nothing , generate the data URI, and then choose Select All so you can copy paste

Get data URI

  1. Paste the URI into the Message Tester

Data URI in Message Tester

  1. Use the Message Tester to send yourself the image.
  2. Enjoy your new image support!

From an image file

  1. Base64 encode your image.
Copy
Copied
with open("my_awesome_image.jpeg", "rb") as img_file:
    b64_string = base64.b64encode(img_file.read()).decode('utf-8')
  1. Format your Data URI.
Copy
Copied
data_uri = f'data:image/jpeg;base64,{b64_string}'
  1. Use the Message Tester to pre-format a template message for your API call.
Copy
Copied
message = f"Looks like you forgot your badge. Here's <a href=\"{data_uri}\">a QR code badge</a> for the day."
  1. Send yourself a message using our code-generator tools ,
Copy
Copied
payload = {
  "message": message,
  "recipients": [
    "recipient1@moveworks.ai"
  ]
}

headers = {
  "Content-Type": "application/json",
  "Authorization": f"Bearer {API_KEY}"
}

response = requests.post(url, json=payload, headers=headers)
  1. Enjoy your new image support!