---
title: "ワークフローエージェントを作成する"
slug: "create-a-workflow-agent"
abstract: "SitecoreAIでwokkflowエージェントを作成する方法。"
---
# ワークフローエージェントを作成する

Agentic Studioには、一般的なマーケティングタスクを自動化する [既成エージェント](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/understanding-agents/understanding-agents.html#available-agents "Available agents") が含まれています。より専門的なニーズには、ユースケースに合わせたカスタムエージェントを作成できます。

*ワークフローエージェント*は、構造化され、繰り返し可能な多段階プロセス向けに設計されたカスタムエージェントの一種です。一貫した結果を持つあらかじめ定義されたワークフローに最適です。

明確なステップの順序、承認、構造化された出力を定義する必要がある場合はワークフローエージェントを使いましょう。チャットスタイルやタスク駆動型のユースケースには [、標準エージェント](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-standard-agent.html "Create a standard agent") を作成しましょう。

既存のエージェントにわずかな変更を加えるだけなら、新規エージェントを一から作成するのではなく、複製[したり設定](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/duplicate-an-agent.html "Duplicate an agent")[を調整し](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/edit-agent-configuration.html "Edit agent configuration")たり、[エクスポートしたJSON](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/export-or-import-an-agent.html "Export or import an agent")を再利用することを検討してください。

このウォークスルーでは、以下の方法を説明します:

1.  [カスタムエージェントを作成する](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#create-a-custom-agent "Create a custom agent")
2.  [概要を定義してください](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#define-the-overview "Define the overview")
3.  [パラメータの設定](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#configure-parameters "Configure parameters")
4.  [スキーマを定義する](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#define-a-schema "Define a schema")
5.  [HTMLテンプレートを定義する](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#define-an-html-template "Define an HTML template")
6.  [エージェントのワークフローを構築してテストする](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#build-and-test-the-agent-workflow "Build and test the agent workflow")

> !注**始める前に**
> 
> -   必ず [ビルダーライセンス](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/agentic-studio-settings/manage-users.html#builder-license "Builder license")を持っていることを確認してください。このライセンスはAgentic Studioでカスタムエージェントを作成するために必要です。
>     
> -   [エージェント設定タブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html "Overview of agent configuration tabs")や[プロンプト作成のベストプラクティス](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html#best-practices-for-writing-prompts "Best practices for writing prompts")を見直しましょう。
>     
> -   エージェントが何をすべきか、ユーザーが何を達成したいかを定義し、設定の意思決定を導きましょう。
>     

## カスタムエージェントを作成する

まずは **エージェント** のページでエージェントを作成しましょう。

1.  ナビゲーションメニューで**Agentic** をクリックし、左サイドバーで:mdiCreationOutline: **Agents**をクリックしてください。
2.  **エージェント**のページで「**作成**」をクリックします。
3.  「 **エージェント作成** 」ダイアログで「 **ワークフロー**」を選択してください。

ワークフローエディターは、以下のようなタブで開きます: **概要**、**パラメータ**、**スキーマ**、**HTMLテンプレート**、**ワークフロー**。 [各タブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html "Overview of agent configuration tabs") は、エージェントの動作、受け付ける入力、生成する内容の異なる部分を制御します。

## 概要を定義してください

[概要タブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html#overview "Overview")を使って、エージェントが何であるか、何をするのか、ユーザーが入力すべき入力を定義します。これらの設定が実行体験を形作り、エージェントが利用可能な情報を決定します。

1.  概要**タブの****基本情報**セクションで、以下の情報を入力してください:
    
    -   **名前** - 明確で記述的なエージェント名。
    -   **説明** - エージェントが行うことの簡単な要約。
    
    ![A screenshot of the Overview tab.](https://doc.sitecore.com/api/markdown-image/sai/ja/users/sitecoreai/images/AS_Agents_WE_Overview.png)
    
2.  **「はじめに**始める」セクションで、エージェントランページに表示されるコンテンツを提供します:
    
    -   **タイトル** - 短い見出し。
    -   **それは何のため** ですか?エージェントの目的です。
    -   **仕組み―入力の使い方やエージェントが何を生成するか。**
3.  **入力**セクションで「**入力を追加**」をクリックして、必要なユーザー入力を定義してください:
    
    -   **タイプ** - 入力タイプで、例えば *Prompt*。
    -   **ラベル** - ユーザーに表示されるフィールド名。
    -   **説明** - どの用途を入力すべきかの指針。
    -   **プレースホルダーテキスト** - フィールドに表示される例文コンテンツ。
    -   **必須** - 入力が必須かどうか。
    -   **最小ライン** - 入力ラインの最小数。
4.  変更を保存するには **「ワークフローを作成」** をクリックしてください。
    

## パラメータの設定

必要に応じて、[パラメータタブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html#parameters "Parameters") でカテゴリやオプションを定義し、エージェントのコンテンツ生成方法に影響を与えます。パラメータにより、言語、オーディエンス、地域などのオプションを選択でき、エージェントはそれらの選択に基づいて出力を調整できます。

パラメータの設定:

1.  カテゴリを追加するには、**パラメータ** タブで **「追加**」をクリックします。
    
    ![A screenshot of the Parameters tab.](https://doc.sitecore.com/api/markdown-image/sai/ja/users/sitecoreai/images/AS_Agents_WE_Parameters.png)
    
2.  **基本設定**のセクションで、次のように定義します:
    
    -   **キー** - 一意識別子(小文字でアンダースコア付き)。
    -   **ラベル** - カテゴリ 表示名。
    -   **説明** - このパラメータの目的を説明します。
    -   **タイプ** - 入力タイプで、例えば *Array*。
    -   **必要** - そのカテゴリがエージェントの実行に必須かどうか。
3.  カテゴリオプションを定義するには、「 **オプションを追加** 」をクリックして新しいパラメータのオプションを定義してください。
    
    例: *ターゲットオーディエン* スパラメータを追加した後、*Sales*、*Marketing*、*C-Suite*などのオプションを作成できます。
    
4.  各オプションを編集し、以下の内容を提供します。
    
    -   **基本設定**
        -   **ラベル** - カテゴリオプションの表示名。
        -   **値** - 一意識別子(小文字でハイフン付き)。
    -   **コンテンツメタデータ&ガイドライン**
        -   **コンテキスト** - いつそのオプションを使うべきかを説明してください。
        -   **声のトーン** - コミュニケーションスタイルの指針。
        -   **ベストプラクティス** - 生成に関する推奨事項。
        -   **やるべきこととやってはいけ** ないこと - ルールや制限を追加する。
        -   **スキーマ** - 選択したスキーマを使ってレスポンスをフォーマットします。利用可能なスキーマには [、設定](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/agentic-studio-settings/agentic-studio-settings.html "Agentic studio settings") で作成されたもの、 [スキーマ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#define-a-schema "Define a schema") タブで定義されたもの、またはSitecoreAIのサイトやコレクション用に定義されたCMSスキーマから得られるものが含まれます。
        -   **HTMLテンプレート** - 出力を表示するためのHTMLテンプレートを選択してください。利用可能なテンプレートには [、設定](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/agentic-studio-settings/agentic-studio-settings.html "Agentic studio settings") で作成されたものや [HTMLテンプレートタブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/create-a-workflow-agent.html#define-an-html-template "Define an HTML template")で定義されたものが含まれます。
5.  必要に応じて繰り返し、追加のカテゴリーや選択肢が見つかります。
    
6.  「 **ワークフローの更新** 」をクリックして変更を保存してください。
    

## スキーマを定義する

構造化出力を強制する必要がある場合は、「 [スキーマ」タブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html#schemas "Schemas") を使ってJSONスキーマを定義してください。スキーマはエージェントが一貫した構造化出力を生成し、それを検証・再利用できるようにします。

スキーマを定義するために:

1.  **スキーマ**タブで**「追加**」をクリックします。
    
2.  右側のペインに以下の内容を入力してください:
    
    -   **名前** - スキーマ名。
    -   **説明** (任意) - スキーマが何に使われるか。
    
    ![A screenshot of the Schemas tab.](https://doc.sitecore.com/api/markdown-image/sai/ja/users/sitecoreai/images/AS_Agents_WE_Schema.png)
    
3.  出力用のJSON構造を定義します。 **シンプル** モードまたは **アドバンスト** モードで、:mdiXml: **Code**または:mdiEyeOutline: **Visual**エディタを使って手動でスキーマを定義できます。
    
    構造は次のように定義できます:
    
    -   必須欄を指定し、常に重要な内容が含まれるようにします。
    -   データ型の定義(例: string、 array、または object)。
    -   エージェントがコンテンツを生成する際のガイドとなる説明を追加します。
    -   出力品質を制御するための検証ルールの設定。
4.  「 **ワークフローの更新** 」をクリックして変更を保存してください。
    

## HTMLテンプレートを定義する

スキーマを定義すれば、対応するテンプレートも定義することが多いです。 [HTMLテンプレートタブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html#html-templates "HTML templates") を使って、エージェントの出力の表示方法を定義してください。テンプレートはHandlebars構文を使って構造化されたデータをレイアウトにマッピングします。

HTMLテンプレートを定義するには:

1.  **HTMLテンプレート**タブで**「追加**」をクリックします。
    
2.  右側のペインに以下の内容を入力してください:
    
    -   **名前** - テンプレート名。
    -   **説明** (任意) - テンプレートが何に使われているか。
    
    ![A screenshot of the HTML templates tab.](https://doc.sitecore.com/api/markdown-image/sai/ja/users/sitecoreai/images/AS_Agents_WE_HTML.png)
    
3.  スキーマフィールドを使ってHTML構造を定義します。Handlebars構文を使って、スキーマの値をテンプレートにマッピングし、:mdiXml: **Code**エディターで行います。
    
    テンプレートの定義は以下の通りです:
    
    -   例えば、レイアウトにスキーマフィールドを挿入する {{subject\_line}} や {{body}})。
    -   HTML <div>、 <strong>、または <span>
    -   条件付き論理やループを適用し、必要に応じて {{#if}} {{#each}} も可能です。
4.  テンプレートをプレビューするには :mdiEyeOutline: **Visual**をクリックしてください。
    
5.  「 **ワークフローの更新** 」をクリックして変更を保存してください。
    

## エージェントのワークフローを構築してテストする

[ワークフロータブ](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/create-a-workflow-agent/overview-of-agent-configuration-tabs.html#workflow "Workflow")の*Workflow editor*を使って、エージェントが実行するアクションの順序を設計してください。

> !ヒントワークフローを設計する際:
> 
> -   ステップごとに構築し、アクション間のデータの流れを明確に保ちましょう。
>     
> -   まずは入力を収集または準備するアクションから始め、各ステップをつなげて出力を次のステップに繋げます
>     
> -   変数名やステップ名を明確にして、ワークフローを分かりやすくしましょう。
>     
> -   ビルドしながらテストし、各ステップが正しいデータを受け継ぎ、期待される結果を得られるか確認してください。
>     

エージェントのワークフローを構築するには:

1.  **ワークフロー**タブでは、キャンバスの開始点として**手動トリガー**アクションが含まれています。
    
    新しいアクションを追加するには **「ステップを追加** 」をクリックします。
    
    ![Screenshot of the Workflow tab. Click Add step to build the agent actions in the workflow.](https://doc.sitecore.com/api/markdown-image/sai/ja/users/sitecoreai/images/AS_Agents_WE_Workflow.png)
    
2.  右側の **「プロパティ** 」タブに、利用可能なアクションのリストが表示されます。アクションを選択してキャンバスに追加します。
    
    > !ヒントアクションについて詳しく知りたい方は、その説明をクリックしてください。 [ワークフローエディターで利用可能なアクション](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/available-actions-in-the-workflow-editor/available-actions-in-the-workflow-editor.html "Available actions in the workflow editor")も確認できます。
    
3.  あるアクションの点から別の点へドラッグして、それらをワークフローステップに繋げます。アクションは接続方法に基づいて順番に実行されます。
    
4.  アクションを設定するには、キャンバス上でアクションを選択し、**プロパティ** ペインで設定を調整してください。
    
    選択によっては、[アクションの](https://doc.sitecore.com/sai/ja/users/sitecoreai/working-with-agentic-studio/understanding-agents/available-actions-in-the-workflow-editor/available-actions-in-the-workflow-editor.html#configuring-actions "Configuring actions") 入力・出力変数、システムプロンプト、メッセージテンプレート、リンクされたHTMLテンプレートやスキーマ、アーティファクト保存オプションの設定が必要になるかもしれません。
    
5.  必要に応じてワークフローを構築していくために、このプロセスを繰り返しましょう。
    
6.  アクションやコネクタを削除するには、キャンバス上で選択し、バックスペースを押してください。
    
7.  キャンバスの **「実行** 」をクリックしてワークフローをテストしてください。問題があれば右側の **「実行** 」タブに表示され、デバッグの助けになります。
    
8.  終了したら「 **ワークフローの更新** 」をクリックして変更を保存してください。
    
    エージェントはエージェントページに追加され、そこで実行や調整が可能です。
    

## 例:X単一ツイートジェネレーター

これはワークフローエージェントの例であり、その設定とJSONも含まれます。

### エージェント構成

-   **Agent name** - X単一ツイートジェネレーター
    
-   **Description** - 営業チームやマーケティング専門家向けに簡潔でインパクトのあるTwitter/X投稿を1つ生成し、オプションでAPIエンドポイントに送信。
    
-   **Inputs** - コンテンツ要件(プロンプト、必須) - 生成したいツイートを説明してください
    
-   **Parameters** - この例では必須ではありません。
    
-   **Schemas** - テキストとハッシュタグを用いた構造化された出力を定義します。
    
-   **HTML template** - ツイート内容とハッシュタグをシンプルなフォーマットレイアウトで表示します。
    
-   **Workflow** - エージェントは以下の手順を実行します:
    
    -   Twitterのスキーマとテンプレートを取得する
    -   ユーザーの入力をもとにプロンプトを作成してください
    -   スキーマを使って構造化されたツイートを1つ生成します
    -   生成されたツイートをドキュメントとして保存してください
    -   ツイートの内容をHTTPエンドポイント(テスト用のモックAPIや、Twitter/X、Redditなどの実際のプラットフォームでAPI認証情報を使って)にSendします。
-   **Agent JSON** - 参照用のサンプルエージェントのJSONはこちらです。ワークフローエディターにインポートしてテストや探索が可能です:
    
    JSON
    
    {
     "schema\_version": "2.0",
     "id": "twitter-content-generator",
     "name": "X Single Tweet Generator",
     "description": "Generates one concise, high-impact Twitter/X post tailored for sales teams and marketing professionals.",
     "gettingStarted": {
     "title": "What is this agent?",
     "howItWorks": "Describe the tweet you want to create. The agent will generate one impactful Twitter/X post based on your prompt.",
     "whatIsItFor": "This agent creates a single short-form Twitter/X post for sales and marketing use cases."
     },
     "inputs": 
     {
     "type": "prompt",
     "label": "Content Requirements",
     "minLines": 3,
     "required": true,
     "description": "Describe the Twitter/X content you want to generate",
     "placeholder": "Tell us what tweet you want to create..."
     },
     {
     "type": "context",
     "label": "Ground with context",
     "required": false,
     "description": "Optionally select artifacts or knowledge to provide additional context"
     },
     {
     "type": "file-upload",
     "label": "Add more context",
     "required": false,
     "description": "Please add any documents you wish to reference"
     }
     ,
     "contextParameters": ,
     "schemas": 
     {
     "id": "twitter",
     "name": "Twitter/X Single Post Schema",
     "schema": {
     "type": "object",
     "required": 
     "text",
     "hashtags"
     ,
     "properties": {
     "text": {
     "type": "string",
     "maxLength": 280,
     "description": "One standalone tweet only, maximum 280 characters"
     },
     "hashtags": {
     "type": "array",
     "items": {
     "type": "string"
     },
     "maxItems": 2,
     "description": "1-2 relevant hashtags already reflected in or suitable for the tweet"
     }
     },
     "additionalProperties": false
     },
     "description": "Structured schema for generating a single Twitter/X post only"
     }
     ,
     "htmlTemplates": 
     {
     "id": "twitter-template",
     "name": "Twitter/X Template",
     "template": "<div class=\\"twitter-post\\">\\n <div class=\\"tweet-text\\">{{text}}</div>\\n {{#if hashtags}}<div class=\\"hashtags\\">{{#each hashtags}}<span class=\\"hashtag\\">#{{this}}</span> {{/each}}</div>{{/if}}\\n</div>"
     }
     ,
     "actions": 
     {
     "id": "initialize\_flow",
     "kind": "InitializeFlow",
     "displayName": "Initialize",
     "showToUser": false
     },
     {
     "id": "get\_schema",
     "kind": "GetStructuredSchema",
     "displayName": "Get Schema",
     "showToUser": false,
     "config": {
     "schemaType": "twitter",
     "outputVarName": "structuredSchema",
     "schemaHtmlTemplate": "twitter-template",
     "outputHtmlTemplateVarName": "htmlTemplate"
     }
     },
     {
     "id": "compose\_message",
     "kind": "ComposeMessage",
     "displayName": "Compose Message",
     "showToUser": false,
     "config": {
     "inputVarNames": ,
     "outputVarName": "generatePrompt",
     "messageTemplate": "{userMessage}",
     "includeUserMessage": true
     }
     },
     {
     "id": "generate\_content",
     "kind": "GenerateContent",
     "displayName": "Generate Content",
     "showToUser": true,
     "config": {
     "type": "content",
     "model": "workflow-fast-model",
     "temperature": 0.4,
     "artifactKind": "content\_item",
     "inputVarName": "vars.generatePrompt",
     "systemPrompt": "You are an expert Twitter/X content writer for sales teams and marketing professionals. Generate exactly one impactful standalone tweet. Do not create a thread, follow-up tweets, numbered options, or multiple alternatives. Keep it concise, clear, high-conviction, and under 280 characters.",
     "outputVarName": "generatedContent",
     "structuredSchemaVar": "vars.twitter"
     }
     },
     {
     "id": "generate\_content\_save",
     "kind": "SaveDocument",
     "displayName": "Save",
     "showToUser": false,
     "config": {
     "kind": "content\_item",
     "titlePrefix": "Generated Twitter Content",
     "contentVarName": "generatedContent",
     "documentIdVarName": "vars.documentId"
     }
     },
     {
     "id": "post\_to\_twitter",
     "kind": "http/request",
     "displayName": "Post to X",
     "showToUser": true,
     "config": {
     "endpoint": "https://webhook.site/<your-webhook-id>",
     "httpBody": "{\\n \\"text\\": \\"{{generate\_content.generatedContent.text}}\\"\\n}",
     "httpMethod": "POST",
     "httpHeaders": "{\\n \\"Content-Type\\": \\"application/json\\"\\n}",
     "outputVarName": "httpResponse"
     }
     },
     {
     "id": "workflow\_end",
     "kind": "WorkflowEnd",
     "displayName": "Complete",
     "showToUser": false
     }
     ,
     "version": 2,
     "is\_active": true
    }
    

### エージェントをテストする

エージェントを作成した後、サンプルプロンプトに従って実行します。

**Prompt** - *コールドアウトリーチの反応率向上についてツイート。*

ツイートが簡潔で影響力があり、実践的な洞察を明確に伝えているかを確認するために出力を見直しましょう。

結果が満足できない場合は、エージェントの指示、ツール、スキル、コンテキストを更新して洗練し、再度テストします。