> For the complete documentation index, see [llms.txt](https://docs-embed.anyflow.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-embed.anyflow.jp/recipe/crm/hubspot-custom-deals.md).

# HubSpotの取引データを取得する

{% hint style="success" %}

### このレシピについて

このレシピは、[CRM API | 取引](https://developers.hubspot.jp/docs/api/crm/deals) を参考に記述されています。
{% endhint %}

## **HubSpotの「取引データ」とは**

HubSpot に登録された、コンタクトまたは会社との間で進めている商取引を表す情報です。\
（参考：[CRM API | 取引](https://developers.hubspot.jp/docs/api/crm/deals)）

HubSpot の CRM API を利用することで、HubSpot に登録された**取引データ**の一覧を取得できます。

### **HubSpotの「取引データ」の構造**

```json
{
  "paging": {
    "next": {
      "link": "?after=NTI1Cg%3D%3D",
      "after": "NTI1Cg%3D%3D"
    }
  },
  "results": [
    {
      "associations": {
        "additionalProp1": {
          "paging": {
            "next": null,
            "prev": {
              "before": "string",
              "link": "string"
            }
          },
          "results": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "additionalProp2": {
          "paging": {
            "next": null,
            "prev": {
              "before": "string",
              "link": "string"
            }
          },
          "results": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "additionalProp3": {
          "paging": {
            "next": null,
            "prev": {
              "before": "string",
              "link": "string"
            }
          },
          "results": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        }
      },
      "createdAt": "2024-04-15T01:21:49.107Z",
      "archived": true,
      "archivedAt": "2024-04-15T01:21:49.107Z",
      "propertiesWithHistory": {
        "additionalProp1": [
          {
            "sourceId": "string",
            "sourceType": "string",
            "sourceLabel": "string",
            "updatedByUserId": 0,
            "value": "string",
            "timestamp": "2024-04-15T01:21:49.107Z"
          }
        ],
        "additionalProp2": [
          {
            "sourceId": "string",
            "sourceType": "string",
            "sourceLabel": "string",
            "updatedByUserId": 0,
            "value": "string",
            "timestamp": "2024-04-15T01:21:49.107Z"
          }
        ],
        "additionalProp3": [
          {
            "sourceId": "string",
            "sourceType": "string",
            "sourceLabel": "string",
            "updatedByUserId": 0,
            "value": "string",
            "timestamp": "2024-04-15T01:21:49.107Z"
          }
        ]
      },
      "id": "string",
      "properties": {
        "additionalProp1": "string",
        "additionalProp2": "string",
        "additionalProp3": "string"
      },
      "updatedAt": "2024-04-15T01:21:49.107Z"
    }
  ]
}
```

## **Anyflow Embedで取得する**

Anyflow Embed で HubSpot の取引データを取得する手順を紹介します。

HubSpot の取引データを**スプレッドシートに一括追加する**というシンプルなソリューションを作成し、取引に含まれるデータを把握します。

<figure><img src="https://files.readme.io/9995be1-CleanShot_2024-04-13_at_11.33.052x.png" alt=""><figcaption></figcaption></figure>

### **1.Clickトリガーを設定する**

Clickトリガーを設定します。

<figure><img src="https://files.readme.io/b9650b7-image.png" alt=""><figcaption></figcaption></figure>

### **2.HubSpot コネクタを設定する**

HubSpot コネクタを追加します。

<figure><img src="https://files.readme.io/c1e1552-CleanShot_2024-04-13_at_11.12.372x.png" alt=""><figcaption></figcaption></figure>

### **3.HubSpot のカスタムアクションを設定する**

ソリューションエディタに戻り、freee人事労務コネクタを以下の通りに設定します。

| 設定項目名       | 設定値                   |
| ----------- | --------------------- |
| カスタムアクション名  | 取引データを取得する            |
| HTTPメソッド    | GET                   |
| リクエストパス     | /crm/v3/objects/deals |
| リクエストヘッダー   | ※ 設定不要                |
| リクエストタイプ    | ※ 設定不要                |
| レスポンスヘッダー定義 | ※ 設定不要                |
| レスポンスタイプ    | json                  |

また、「レスポンスボディ定義」には以下の設定を行います。

```json
{
  "results": [
    {
      "id": "string",
      "properties": {
        "dealname": "string",
        "amount": "string"
      },
      "createdAt": "2024-04-15T00:14:10.990Z",
      "updatedAt": "2024-04-15T00:14:10.990Z"
    }
  ]
}
```

「element」の名前は「deal」に変更しておきます。

<figure><img src="https://files.readme.io/ced85ad-image.png" alt="" width="563"><figcaption></figcaption></figure>

以下が設定後のイメージです。

<figure><img src="https://files.readme.io/8ba4cc1-CleanShot_2024-04-13_at_11.34.072x.png" alt="" width="563"><figcaption></figcaption></figure>

### **4. スプレッドシートの列名を設定する**

スプレッドシートコネクタを追加し、以下の通りに設定を行います。

| 設定項目名      | 設定値           |
| ---------- | ------------- |
| アクション      | 1行追加          |
| スプレッドシートID | 任意のスプレッドシートID |
| シートID      | 任意のシートID      |

<figure><img src="https://files.readme.io/677257c-_2024-02-26_17.45.08.png" alt=""><figcaption></figcaption></figure>

「ヘッダーの列名」は以下の通りに設定します。

```
id
dealname
amount
createdAt
updatedAt
```

「行データ」にも同じ様に設定します。

<figure><img src="https://files.readme.io/731f77d-CleanShot_2024-04-13_at_11.34.332x.png" alt="" width="563"><figcaption></figcaption></figure>

**スプレッドシートに一括追記する**

スプレッドシートコネクタを追加し、以下の通りに設定を行います。

| 設定項目名      | 設定値           |
| ---------- | ------------- |
| アクション      | 行を一括追加        |
| スプレッドシートID | 任意のスプレッドシートID |
| シートID      | 任意のシートID      |

「ヘッダーの列名」は以下の通りに設定します。

```
id
dealname
amount
createdAt
updatedAt
```

「リストソース」は以下の通りに設定します。

![](https://files.readme.io/e3725fe-CleanShot_2024-04-13_at_11.35.192x.png)

「要素フィールド」は以下の通りに設定します。（「i番目のdeals」から項目を選択します。）

![](https://files.readme.io/11f0f35-CleanShot_2024-04-13_at_11.36.152x.png)

必要な認証をウィザードに追加します。

テストを行うと、スプレッドシートにデータが追加されていることがわかります。

Updated 9 months ago

***

* [Table of Contents](broken://pages/U6ihqK3PT5EWJCP3NAP6)
* * [HubSpotの「取引データ」とは](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [HubSpotの「取引データ」の構造](broken://pages/U6ihqK3PT5EWJCP3NAP6)
  * [Anyflow Embedで取得する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [1. Clickトリガーを設定する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [2. HubSpot コネクタを設定する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [3. HubSpot のカスタムアクションを設定する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [4. スプレッドシートの列名を設定する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [5. スプレッドシートに一括追記する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [6. ウィザードを設定する](broken://pages/U6ihqK3PT5EWJCP3NAP6)
    * [7. テストを行う](broken://pages/U6ihqK3PT5EWJCP3NAP6)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs-embed.anyflow.jp/recipe/crm/hubspot-custom-deals.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
