--- title: "Ruleの作成" url: https://docs.catalyst.zoho.com/ja/tutorials/invoice-notifier/python/create-rule/ description: "Event FunctionsとCatalyst Signalsを使用して、Zoho BooksからZoho Cliqへの請求書更新を自動化するイベント駆動アーキテクチャを構築します。" last_updated: 2026-08-17T12:16:04Z service: All Services type: tutorial related_links: - name: "Publishers" url: /ja/signals/help/publishers/key-aspects/ - name: "Targets" url: /ja/signals/help/targets/key-aspects/ - name: "Rules" url: /ja/signals/help/rules/key-aspects/ - name: "Events" url: /ja/signals/help/events/key-aspects/ - name: "Event Functions" url: /ja/serverless/help/functions/event-functions/ --- # Ruleの作成 PublisherとEvent Functionの設定が完了したので、Ruleを設定してイベントの処理と配信方法を定義しましょう。 Ruleを作成するには、以下の手順に従ってください: 1. Developer Consoleで、プロジェクト*InvoiceNotifier*を選択します。 2. **Catalyst Signals**に移動し、左側のナビゲーションで**Rules**をクリックします。 ![Add Rule](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/rule.webp) 3. **Add Rule**をクリックし、Ruleの名前と説明を入力します。 ![Provide name and description for the Rule](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/create-rule.webp) ### イベントソースの定義 4. Sourceの下で**Choose Event**をクリックし、先ほど追加したZoho Books Publisherを選択します。 5. 利用可能なイベントの一覧から*Customer Payment Created*を選択し、**Done**をクリックします。 ![Configure the publisher and event for the rule](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/source.webp) ### イベントフィルターの定義 6. Filterセクションで**編集アイコン**をクリックし、**Events matching certain conditions**を選択します。 ![Select Events matching certain conditions](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/filter.webp) 7. 請求書ステータスが**Paid**のイベントのみを含むフィルター条件を作成します: - Pathドロップダウンで、**payment_status**フィールドに対応するJSONパスを選択します。 - Paidに一致する条件を定義します。 8. **Save**をクリックしてフィルターを適用します。 ![Configure filter for the rule](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/filter-criteria.webp) ### ターゲット設定の構成 9. **Choose Target**をクリックし、ターゲットに名前を付けます。 10. **Consumer Type**で、CLIで先ほど作成したEvent Functionを選択します。 11. **Dispatch Policy**を**Batch by Interval**に設定します: - インターバルを*1時間*に設定します。 - Retry Countを*5*に設定します。 ![Configure target settings](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/target-settings.webp) ### ペイロードの変換 12. **Target Input**セクションで**Transform**を選択します。 13. *Customer Payment Created*イベントのデフォルトイベントペイロードから、必要なデータのみを選択し、以下のように構造化します。 **Expected Event Payload** ```json { "data" : [ [ { "Customer" : "test", "Invoice Number" : "Customer opening balance", "Amount" : "₹3,24,244.00", "Paid On" : "31/10/2023", "Invoice Id" : "275557000000158181" } ] ] } ``` **Data Mapping for Template Compiler** ```text { "data" : $.events.forEach((event)-> event.data.payment.invoices.forEach((invoice)-> { "Customer" : event.data.payment.customer_name, "Invoice Number" : invoice.invoice_number, "Amount" : invoice.total_formatted, "Paid On" : event.data.payment.date_formatted, "Invoice Id" : invoice.invoice_id } ) ) } ``` この構造をテンプレートコンパイラに貼り付けて、必要なフィールドを抽出し、**Generate Output**をクリックします。 ![Event Body Transformation](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/transformation.webp) イベントペイロードのカスタマイズ方法の詳細については、[イベントボディ変換ヘルプガイド](https://docs.catalyst.zoho.com/ja/signals/help/targets/event-body-setup/event-transformation/)を参照してください。 14. ターゲット設定を保存し、**Save**をクリックしてRuleを確定します。 これで、顧客が支払いを完了するたびに、Zoho Booksの対応する請求書が更新されます。この更新によりイベントがトリガーされ、Catalyst Signalsで毎時処理され、Zoho Cliqチャンネルにサマリーメッセージが自動的に送信されます。 ![Invoice Notifier](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/demo.webp)