dify icon indicating copy to clipboard operation
dify copied to clipboard

Sending File attachment via webhook

Open asrguru20 opened this issue 9 months ago • 1 comments

Self Checks

  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.5

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I want to include file attachment like .jpg or .txt to n8n webhook via HTTP request in Dify ChatFlow I have only 3 node:

  • Start node
  • HTTP Request node: it sends wehbook to my n8n ai agent including body sys.query and
  • Answer node

the body of sending request: { "query": "{{#sys.query#}}", "name": "{{#1742844481787.name#}}", "files": "{{#sys.files#}}" }

But the n8n webhook received only query and my custom input field variable the files value is empty :

}, "query": { }, "body": { "query": "this is file", "name": "Dante", "files": "" }, "webhookUrl": "https://make.gptell.ir/webhook-test/bxxxxae-9354-xxxx-b81f-5xxxxxx838",

how we can send file

this is also my problem to create custom tool for example Stability diffusion image editor requires to send image file

✔️ Expected Behavior

to be able to send files via webhook

❌ Actual Behavior

the files value in received webhook is empty :

"body": { "query": "this is file", "name": "Dante", "files": "" },

asrguru20 avatar Mar 25 '25 18:03 asrguru20

I couldn't find specific documentation or examples in the Dify repository that demonstrate sending file attachments via webhook. However, there is a related open issue that might be helpful. The suggested solution for uploading a file in an HTTP request involves ensuring that your request is formatted to handle multipart form-data. Here's an example using cURL:

curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create_by_file' \
--header 'Authorization: Bearer {api_key}' \
--form 'data="{\"name\":\"Dify\",\"indexing_technique\":\"high_quality\",\"process_rule\":{\"rules\":{\"pre_processing_rules\":[{\"id\":\"remove_extra_spaces\",\"enabled\":true},{\"id\":\"remove_urls_emails\",\"enabled\":true}],\"segmentation\":{\"separator\":\"###\",\"max_tokens\":500}},\"mode\":\"custom\"}}";type=text/plain' \
--form 'file=@"/path/to/file"'

Replace '/path/to/file' with the actual path to your file and fill in the placeholders like ${props.apiBaseUrl}, {dataset_id}, and {api_key} with your specific values. This approach might help you configure your HTTP request node to include file attachments [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Mar 25 '25 18:03 dosubot[bot]