# לשלוח תבנית וואטסאפ

> שולח תבנית ש-Meta אישרה, עם הערכים והכפתורים שלה. אפשר להתחיל בה שיחה בכל זמן.

Source: https://docs.go-lumen.ai/he/reference/steps/whatsapp-send-template

## במבט אחד

| מאפיין | ערך |
| --- | --- |
| **שם השלב** | `whatsapp-send-template` |
| **משאב** | ClusterStep (`lumen.ai/v1alpha1`) |
| **קבוצה וקטגוריה** | notify, messages |
| **קרדיטים** | **1** קרדיט בכל פעם שהוא מצליח |
| **השפעה חיצונית** | כן: הוא משנה משהו מחוץ ל-Lumen, ולכן ניסיון חוזר שואל קודם, ובדיקה מראה מה הוא היה עושה במקום לעשות את זה. |
| **ההתקנה צריכה לספק** | כלום |

## קלט

| מאפיין | ערך |
| --- | --- |
| **צריך** | כלום |
| **מפיק** | `fields` |
| **עובד על** | item: מסמך אחד בכל פעם |

״צריך״ ו״מפיק״ הם סוגי נתונים (file, text, fields, email). העורך מציע שלב רק במקום שבו מה שהוא צריך כבר נמצא במסלול. ראו [מסמכים ונתונים](https://docs.go-lumen.ai/he/concepts/how-flows-run.md#documents-and-data).

## פלט

צומת מאוחר יותר מפנה לפלט כ-`{nodeId.field}` בטקסט, או כ-`nodeId.field` בתנאי.

| פלט | סוג |
| --- | --- |
| `whatsappMessageId` | string |
| `whatsappStatus` | string |

## הגדרות

מגדירים תחת `config:` בצומת של התהליך. הגדרות טקסט יכולות להכיל מצייני מקום כמו `{nodeId.field}`.

| הגדרה | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `connectorRef` | string |  | Send from (minLength 1) |
| `to` | string |  | To (maxLength 200) |
| `toMember` | string |  | Their email. They must have joined this number with their phone (Profile, WhatsApp). (maxLength 320) |
| `template` (חובה) | string |  | Template is the approved template's name, as Meta has it. (minLength 1; maxLength 512) |
| `language` (חובה) | string |  | Language is the template's language code, he or en\_US. (minLength 2; maxLength 15) |
| `params` | list of string |  | Params fill the template's {`{1}`}, {`{2}`}, ... in order; each may hold placeholders. (maxItems 20) |
| `buttonPayloads` | list of string |  | ButtonPayloads are what the template's quick reply buttons send back when tapped, by position; each may hold placeholders. (maxItems 10) |

ה-JSON Schema המלא של ההגדרות: [whatsapp-send-template.schema.json](https://docs.go-lumen.ai/schemas/steps/whatsapp-send-template.schema.json).

## דוגמה

```yaml title="config"
buttonPayloads:
- approve:{number}
- reject:{number}
connectorRef: whatsapp-main
language: he
params:
- '{number}'
- '{amount}'
template: receipt_ready
to: '{phone}'
```

## שימוש בתהליך

צומת שמריץ את `whatsapp-send-template` נכנס תחת `spec.nodes` של [Flow](https://docs.go-lumen.ai/he/concepts/how-flows-run.md#the-flow-as-yaml). תנו לו כל מזהה, ורשמו ב-next את מזהי הצמתים הבאים.

```yaml title="flow.yaml (spec.nodes)"
- id: whatsapp-send-template
  stepRef: {name: whatsapp-send-template}
  config:
    buttonPayloads:
    - approve:{number}
    - reject:{number}
    connectorRef: whatsapp-main
    language: he
    params:
    - '{number}'
    - '{amount}'
    template: receipt_ready
    to: '{phone}'
```
