Send media files (images, documents, audio, video) directly to Feishu users or chats using the message tool.
Use the message tool with action: send and path parameter:
json
{
"action": "send",
"target": "ou_xxx", // user open_id or chat_id
"path": "/path/to/file.pdf"
}
Supported types:
.png, .jpg, .jpeg, .gif, .webp.doc, .docx, .pdf, .txt, .rtf.mp3, .wav, .m4a.mp4, .movParameters:
target: User open_id (e.g., ou_3ac66d1ad7b8c1xxxxxxxxxxxxxxs) or chat IDpath: Absolute path to local filefilename: Override display nameUse chat_id as target:
json
{
"action": "send",
"target": "oc_xxx", // group chat ID
"path": "/path/to/file.pdf"
}
For images to display inline in the message (not as attachments), use the image parameter with base64:
json
{
"action": "send",
"target": "ou_xxx",
"image": "data:image/png;base64,..."
}
Follow these steps exactly for maximum success rate:
bash
# Extract filename from source path
filename=$(basename "/source/path/to/file.png")
# Copy to workspace (overwrite if exists)
cp -f "/source/path/to/file.png" "~/.openclaw/workspace/${filename}"
# Verify copy succeeded
if [ ! -f "~/.openclaw/workspace/${filename}" ]; then
echo "ERROR: File copy failed"
exit 1
fi
Why overwrite (-f): Ensures fresh copy every time, avoids stale file issues.
bash
# Get absolute path
abs_path=$(cd ~/.openclaw/workspace && pwd)/${filename}
# Validate file exists and is readable
if [ ! -r "$abs_path" ]; then
echo "ERROR: File not readable: $abs_path"
exit 1
fi
# Log for debugging
echo "Sending: $abs_path"
json
{
"action": "send",
"target": "ou_xxx",
"path": "/Users/casia/.openclaw/workspace/filename.png"
}
Check tool response:
"messageId" field present"error" field presentIf Step 4 fails, automatically attempt fallbacks in order:
bash
# Sometimes transient failure, retry
cp -f "/source/path/to/file.png" "~/.openclaw/workspace/${filename}"
# Resend
bash
# Convert to base64
base64_string=$(base64 -i "$abs_path")
# Send as inline image
{
"action": "send",
"target": "ou_xxx",
"image": "data:image/png;base64,${base64_string}"
}
When to use: Path method fails, small images (<3MB), .png/.gif files
json
{
"action": "upload_file",
"doc_token": "xxx",
"file_path": "$abs_path"
}
Then send the returned file URL.
When to use: Files >20MB, persistent path failures
ErrorCauseSolutionFile not foundWrong pathVerify source path existsPermission deniedFile permission issuechmod 644 on fileTool errorFeishu API issueRetry → base64 → driveEmpty fileZero-byte fileCheck source before copyingFile too large>20MBUse Feishu drive
ScenarioPrimary MethodFallback 1Fallback 2Small image (<3MB)pathbase64-Large image (3-20MB)pathbase64driveDocumentpathdrive-Audio/Videopathdrive-Very large (>20MB)drive--