人間の入力フォームを送信
対象アプリ:Chatflow、Workflow。
一時停止中の人間の入力フォームに、受信者の応答を送信します。受理されるとワークフローが再開されます。再開後の実行は ワークフローイベントをストリーム で追跡してください。Web アプリ配信が必要です。
1 min read
post/form/human_input/{form_token}
Request example
curl --request POST \
--url https://api.dify.ai/v1/form/human_input/{form_token} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"action": "approve",
"inputs": {
"attachment": {
"transfer_method": "local_file",
"type": "image",
"upload_file_id": "3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7"
},
"attachments": [
{
"transfer_method": "local_file",
"type": "document",
"upload_file_id": "1a77f0df-c0e6-461c-987c-e72526f341ee"
},
{
"transfer_method": "remote_url",
"type": "document",
"url": "https://example.com/report.pdf"
}
],
"feedback": "公開して問題ありません",
"priority": "high"
},
"user": "abc-123"
}'import requests
url = "https://api.dify.ai/v1/form/human_input/{form_token}"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
}
payload = {
"action": "approve",
"inputs": {
"attachment": {
"transfer_method": "local_file",
"type": "image",
"upload_file_id": "3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7"
},
"attachments": [
{
"transfer_method": "local_file",
"type": "document",
"upload_file_id": "1a77f0df-c0e6-461c-987c-e72526f341ee"
},
{
"transfer_method": "remote_url",
"type": "document",
"url": "https://example.com/report.pdf"
}
],
"feedback": "公開して問題ありません",
"priority": "high"
},
"user": "abc-123"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)const response = await fetch('https://api.dify.ai/v1/form/human_input/{form_token}', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"action": "approve",
"inputs": {
"attachment": {
"transfer_method": "local_file",
"type": "image",
"upload_file_id": "3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7"
},
"attachments": [
{
"transfer_method": "local_file",
"type": "document",
"upload_file_id": "1a77f0df-c0e6-461c-987c-e72526f341ee"
},
{
"transfer_method": "remote_url",
"type": "document",
"url": "https://example.com/report.pdf"
}
],
"feedback": "公開して問題ありません",
"priority": "high"
},
"user": "abc-123"
})
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/form/human_input/{form_token}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"action": "approve",
"inputs": {
"attachment": {
"transfer_method": "local_file",
"type": "image",
"upload_file_id": "3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7"
},
"attachments": [
{
"transfer_method": "local_file",
"type": "document",
"upload_file_id": "1a77f0df-c0e6-461c-987c-e72526f341ee"
},
{
"transfer_method": "remote_url",
"type": "document",
"url": "https://example.com/report.pdf"
}
],
"feedback": "公開して問題ありません",
"priority": "high"
},
"user": "abc-123"
}',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "https://api.dify.ai/v1/form/human_input/{form_token}"
payload := strings.NewReader("{\n \"action\": \"approve\",\n \"inputs\": {\n \"attachment\": {\n \"transfer_method\": \"local_file\",\n \"type\": \"image\",\n \"upload_file_id\": \"3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7\"\n },\n \"attachments\": [\n {\n \"transfer_method\": \"local_file\",\n \"type\": \"document\",\n \"upload_file_id\": \"1a77f0df-c0e6-461c-987c-e72526f341ee\"\n },\n {\n \"transfer_method\": \"remote_url\",\n \"type\": \"document\",\n \"url\": \"https://example.com/report.pdf\"\n }\n ],\n \"feedback\": \"公開して問題ありません\",\n \"priority\": \"high\"\n },\n \"user\": \"abc-123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/form/human_input/{form_token}"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"action\": \"approve\",\n \"inputs\": {\n \"attachment\": {\n \"transfer_method\": \"local_file\",\n \"type\": \"image\",\n \"upload_file_id\": \"3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7\"\n },\n \"attachments\": [\n {\n \"transfer_method\": \"local_file\",\n \"type\": \"document\",\n \"upload_file_id\": \"1a77f0df-c0e6-461c-987c-e72526f341ee\"\n },\n {\n \"transfer_method\": \"remote_url\",\n \"type\": \"document\",\n \"url\": \"https://example.com/report.pdf\"\n }\n ],\n \"feedback\": \"公開して問題ありません\",\n \"priority\": \"high\"\n },\n \"user\": \"abc-123\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/form/human_input/{form_token}')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Post.new(url)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = '{
"action": "approve",
"inputs": {
"attachment": {
"transfer_method": "local_file",
"type": "image",
"upload_file_id": "3c8fa1b2-7d4e-4f9a-b0c1-d2e3f4a5b6c7"
},
"attachments": [
{
"transfer_method": "local_file",
"type": "document",
"upload_file_id": "1a77f0df-c0e6-461c-987c-e72526f341ee"
},
{
"transfer_method": "remote_url",
"type": "document",
"url": "https://example.com/report.pdf"
}
],
"feedback": "公開して問題ありません",
"priority": "high"
},
"user": "abc-123"
}'
response = http.request(request)
puts response.read_bodyResponse
{}{
"code": "bad_request",
"message": "Form recipient type is invalid",
"status": 400
}{
"code": "invalid_form_data",
"message": "Missing required inputs: feedback",
"status": 400
}{
"code": "not_found",
"message": "Form not found",
"status": 404
}{
"code": "human_input_form_expired",
"message": "This form has expired, form_id=a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": 412
}{
"code": "human_input_form_submitted",
"message": "This form has already been submitted by another user, form_id=a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": 412
}post/form/human_input/{form_token}
Authorization
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
Path parameters
一時停止中のフォームへのアクセストークン。ストリーミングモードのワークフローを実行エンドポイントまたはチャットメッセージを送信エンドポイントが返す
human_input_required イベントから取得します。Body
application/json各入力の output_variable_name をキーとして送信する値。段落と選択の入力は文字列、file 入力は単一のファイルマッピング、file-list 入力はファイルマッピングの配列です。
ファイルマッピングは {transfer_method: local_file, upload_file_id, type} または {transfer_method: remote_url, url, type} で、type はそのフィールドの allowed_file_types のいずれかです。local_file の場合、upload_file_id は ファイルをアップロード が返す id です。
実行、アップロード、送信の各呼び出しで一貫した user を使用してください。
エンドユーザーの識別子。アプリ側で定義し、アプリ内で一意にします。サービス API と Web アプリのユーザー ID は、たとえ同じでも別物として扱われます。エンドユーザーの識別 を参照してください。
Responses
application/json
フォームの送信に成功しました。レスポンスボディは空のオブジェクトです。