Skip to content

ルールに基づく項目のレコメンデーションの作成

カタログ内のアイテムからルールベースのレコメンドエンジンを作成する方法について説明します。

ルールベースの項目の推奨事項について

ルールベースのレコメンデーションエンジンは、ユーザーデータと商品情報を使って、メッセージング内でユーザーに関連アイテムを提案する。これは、Liquidを使用し、Braze catalogsまたはConnected Contentを使用して、ユーザーの動作と属性に基づいてコンテンツを動的にパーソナライズします。

推奨エンジンオプション

どの推奨エンジンが、利用可能なリソースやユースケースに適しているかを判断する際には、この検討事項表を参考にしてください。

推奨エンジンの作成

カタログまたは接続コンテンツのいずれかを使用して、推奨エンジンを作成します。

カタログを使用してレコメンドエンジンを作成するには

  1. 製品のカタログを作成します。
  2. 製品ごとに、推奨製品のリストを区切り記号 (パイプ | のようなもの) で区切った文字列として、「product_recommendations 」という名前の列に追加します。
  3. カタログにおすすめを探したい製品IDを渡す。
  4. そのカタログアイテムの product_recommendations 値を取得し、Liquid の分割フィルターを使用して区切り記号で区切ります。
  5. それらの 1 つ以上の ID をカタログに渡して、他の製品の詳細を収集します。

例えば、あなたが健康食品のアプリを持っていて、ユーザーがアプリに登録した期間に応じて異なるレシピを送るコンテンツカードキャンペーンを作りたいとしよう。まず、以下の情報を含むCSV ファイルを使用してカタログを作成してアップロードします。

カタログが Braze にアップロードされた後、カタログアイテムの一部のプレビューを確認して、情報が正確にインポートされたことを確認してください。プレビューでは項目がランダムになっているかもしれないが、レコメンデーションエンジンの出力には影響しない。

Braze のカタログの例。

コンテンツカードキャンペーンを作成する。作成画面で、キャンペーンの送信先のユーザー、および表示するレシピと画像を決定する Liquid ロジックを入力します。このユースケースで、Braze はユーザーの start_date (または登録日) を取得し、現在の日付と比較します。日数の違いによって、送信されるコンテンツカードが決まります。

1
2
3
4
5
6
{% assign start_date = {{custom_attribute.${start_date}}} | date: "%s" %}
{% assign current_date = "now" | date: "%s" %}
{% assign diff = {{current_date}} | minus: {{start_date}} | divided_by: 86400 %}
{% assign days = {{diff}} | round %}
{% catalog_items Healthy_Recipe_Catalog_SMB {{days}} %}
{{ items[0].title }}
1
2
3
4
5
6
7
8
9
10
{% assign start_date = {{custom_attribute.${start_date}}} | date: "%s" %}
{% assign current_date = "now" | date: "%s" %}
{% assign diff = {{current_date}} | minus: {{start_date}} | divided_by: 86400 %}
{% assign days = {{diff}} | round %}
{% catalog_items Healthy_Recipe_Catalog_SMB {{days}} %}
{% if items[0].title != blank %}
{{ items[0].body }}
{% else %}
{% abort_message('no card for today') %}
{% endif %}
1
2
3
4
5
6
{% assign start_date = {{custom_attribute.${start_date}}} | date: "%s" %}
{% assign current_date = "now" | date: "%s" %}
{% assign diff = {{current_date}} | minus: {{start_date}} | divided_by: 86400 %}
{% assign days = {{diff}} | round %}
{% catalog_items Healthy_Recipe_Catalog_SMB {{days}} %}
{{ items[0].image_url }}

以下に例を示します。

コンテンツカードキャンペーンのメッセージコンポーザーの例。

On click behaviorセクションで、iOS、Android、Webデバイスでユーザーがコンテンツカードをクリックしたときに、どこにリダイレクトされるべきかのLiquidロジックを入力する。

1
2
3
4
5
6
{% assign start_date = {{custom_attribute.${start_date}}} | date: "%s" %}
{% assign current_date = "now" | date: "%s" %}
{% assign diff = {{current_date}} | minus: {{start_date}} | divided_by: 86400 %}
{% assign days = {{diff}} | round %}
{% catalog_items Healthy_Recipe_Catalog_SMB {{days}} %}
{{ items[0].link }}

以下に例を示します。

作成画面でのクリック時動作ブロックの例。

テスト」タブに移動し、「ユーザーとしてメッセージをプレビュー」で「カスタムユーザー」を選択する。カスタム属性フィールドに日付を入力し、その日にサインアップしたユーザーに送信されるコンテンツカードをプレビューする。

'start_date'.という名前のカスタム属性の例

Connected Content を使用してレコメンドエンジンを作成するには、まず次のいずれかの方法を使用して新しいエンドポイントを作成します。

次に、エンドポイントを呼び出すメッセージで Liquid を使用して、カスタム属性値をユーザーのプロファイルに一致させ、対応する推奨事項をプルします。

1
2
3
4
5
6
7
8
{% connected_content YOUR_API_URL :save items %}

{% assign recommended_item_ids_from_user_profile = custom_attribute.${RECOMMENDED_ITEM_IDS} | split: ';' %}

{% for item_id in recommended_item_ids_from_user_profile %}
  {% assign recommended_item = items | where: "ITEM_ID", ITEM_ID | first %}
  recommended_item.item_name
{% endfor %}

以下を置き換えます。

例えば、Zomato Restaurantsデータベースからお勧めのレストランを取得し、その結果をrestaurants という内部変数として保存したいとしよう。次のコネクテッドコンテンツの呼び出しができます。

1
2
3
4
{% connected_content https://developers.zomato.com/api/v2.1/search?entity_id={{city_id}}&entity_type=city&count=20&cuisines={{food_type}}&sort=rating:headers{“user-key”:“USER_KEY”} :save restaurants %}

{{city_food.restaurants[0]}}

次に、ユーザーの市区町村と食べ物の種類に基づいて、お勧めのレストランを引き出したいとしよう。ユーザーの市区町村と料理の種類のカスタム属性を呼び出しの冒頭にダイナミックに挿入し、restaurants の値を変数 city_food.restaurants に代入することで、これを行うことができます。

コネクテッドコンテンツの呼び出しは次のようになります。

1
2
3
4
5
6
7
8
{% assign city_id = {{custom_attribute.${city_id} | default: ‘306’}} %}
{% assign food_type = {{custom_attribute.${food_type} | default: ‘471’}} %}

{%- connected_content https://developers.zomato.com/api/v2.1/search?entity_id={{city_id}}&entity_type=city&count=20&cuisines={{food_type}}&sort=rating:headers{“user-key”:“USER_KEY”} :save restaurants %}

{% assign restaurants = city_food.restaurants %}

{{city_food.restaurants[0]}}

レストラン名と評価だけを取得するようにレスポンスを調整したい場合は、次のようにフィルターを呼び出しの最後に追加することができる:

1
2
3
4
5
6
7
8
{% assign city_id = {{custom_attribute.${city_id} | default: ‘306’}} %}
{% assign food_type = {{custom_attribute.${food_type} | default: ‘471’}} %}

{%- connected_content https://developers.zomato.com/api/v2.1/search?entity_id={{city_id}}&entity_type=city&count=20&cuisines={{food_type}}&sort=rating:headers{“user-key”:”USER_KEY”} :save restaurants %}
{% assign restaurants = city_food.restaurants %}

{{city_food.restaurants[0].restaurant.name}}
{{city_food.restaurants[0].restaurant.user_rating.rating_text}}

最後に、お勧めのレストランを評価別にまとめたいとしよう。次の手順を実行します。

  1. assign 、「素晴らしい」、「非常に良い」、「良い」の評価カテゴリー用の空白の配列を作成する。
  2. リスト内の各レストランの評価を調べる for ループを追加します。
    • 評価が「優れている」場合は、レストラン名を excellent_restaurants 文字列の後に追加し、各レストラン名を区切る * 文字を最後に追加します。
    • 評価が “Very Good “の場合、very_good_restaurants の文字列にレストラン名を追加し、最後に*を追加する。
    • 評価が “Good “の場合、good_restaurants の文字列にレストラン名を追加し、最後に*を追加する。
  3. 返されるおすすめレストランの数を各カテゴリで 4 店に制限します。

最終的な呼び出しは次のようになります。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{% assign city_id = {{custom_attribute.${city_id} | default: ‘306’}} %}
{% assign food_type = {{custom_attribute.${food_type} | default: ‘471’}} %}
{%- connected_content https://developers.zomato.com/api/v2.1/search?entity_id={{city_id}}&entity_type=city&count=20&cuisines={{food_type}}&sort=rating:headers{“user-key”:”USER_KEY”} :save restaurants %}
{% assign restaurants = city_food.restaurants %}
{% assign excellent_restaurants = “” %}
{% assign very_good_resturants = “” %}
{% assign good_restaurants = “” %}
{% for list in restaurants %}
{% if {{list.restaurant.user_rating.rating_text}} == `Excellent` %}
{% assign excellent_restaurants = excellent_restaurants | append: list.restaurant.name | append: `*` %}
{% elseif {{list.restaurant.user_rating.rating_text}} == `Very Good` %}
{% assign very_good_restaurants = very_good_restaurants | append: list.restaurant.name | append: `*` %}
{% elseif {{list.restaurant.user_rating.rating_text}} == `Good` %}
{% assign good_restaurants = good_restaurants | append: list.restaurant.name | append: `*` %}
{% endif %}
{% endfor %}
{% assign excellent_array = excellent_restaurants | split: `*` %}
{% assign very_good_array = very_good_restaurants | split: `*` %}
{% assign good_array = good_restaurants | split: `*` %}

Excellent places
{% for list in excellent_array %}

{{list}}
{% assign total_count = total_count | plus:1 %}
{% if total_count >= 4 %}
{% break %}
{% endif %}
{% endfor %}

Very good places
{% for list in very_good_array %}

{{list}}
{% assign total_count = total_count | plus:1 %}
{% if total_count >= 4 %}
{% break %}
{% endif %}
{% endfor %}

Good places
{% for list in good_array %}

{{list}}
{% assign total_count = total_count | plus:1 %}
{% if total_count >= 4 %}
{% break %}
{% endif %}
{% endfor %}

ユーザー端末でのレスポンシブの表示例については、以下のスクリーンショットを参照のこと。

例の最終呼び出しで生成されたレストランリストのレンダリング。

「このページはどの程度役に立ちましたか?」
New Stuff!