Skip to content

Docs / All tools / Loop III: Assistant

mail.read_attachment

Download an attachment from an email.

2 credits. Per call.

Example prompt

Send this to your AI app when Heelo is connected:

Get the PDF attached to that invoice email

Input fields

FieldTypeDescription
message_idRequiredstringMessage id, as returned by mail.read_list.
attachment_idRequiredstringAttachment id, as returned by mail.read_get.
account_handlestringWhich configured mailbox to read.
folderstringFolder that holds the message.
end_user_idstringOptional end-user scope.

Output fields

The fields in data when status is success.

FieldType
message_idstring
attachment_idstring
filenamestring
content_typestring
size_bytesinteger
bytes_readinteger
streamedboolean
content_encodingstring
content_base64string
notestring
accountobject

Code

The call with the input fields that the tool needs. Replace each word in capitals, such as MESSAGE_ID. Set HEELO_API_KEY to your API key.

import os
import requests

response = requests.post(
    "https://toolsprimitives.uk/v1/tools/mail.read_attachment/invoke",
    headers={"Authorization": f"Bearer {os.environ['HEELO_API_KEY']}"},
    json={"input": {
        "message_id": "MESSAGE_ID",
        "attachment_id": "ATTACHMENT_ID",
    }},
    timeout=120,
)
response.raise_for_status()
print(response.json())