# לשאול בוואטסאפ ולחכות

> שואל שאלה עם עד שלושה כפתורים ומחכה ללחיצה, ואז ממשיך עם התשובה. אחרי 24 שעות נשלחת התבנית המאושרת שבחרתם.

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

## במבט אחד

| מאפיין | ערך |
| --- | --- |
| **שם השלב** | `whatsapp-ask` |
| **משאב** | 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` בתנאי.

| פלט | סוג |
| --- | --- |
| `answer` | string |
| `answerTitle` | string |
| `answeredBy` | string |
| `answeredAt` | date |
| `reason` | string |
| `reasonQuoted` | 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) |
| `text` (חובה) | string |  | Question (minLength 1; maxLength 1024) |
| `buttons` (חובה) | list of object |  | Answers (minItems 1; maxItems 3) |
| `buttons[].id` (חובה) | string |  | ID is what comes back in the run the tap starts (its buttonId). (minLength 1; maxLength 256) |
| `buttons[].title` (חובה) | string |  | Button (minLength 1; maxLength 20) |
| `template` | string |  | Template, Language and Params are the approved template sent when the person has not written in 24 hours. Its quick reply buttons must be in the same order as Buttons. (maxLength 512) |
| `language` | string |  | Template language (maxLength 15) |
| `params` | list of string |  | Template values (maxItems 20) |
| `timeoutHours` | integer | `72` | TimeoutHours is how long the run waits: 1 to 720, default 72. After it the step fails and the buttons answer nothing. (minimum 1; maximum 720) |
| `reasonOn` | list of string |  | Answer ids. After such a tap the person is asked why, and their next message is the reason. (maxItems 3) |
| `reasonPrompt` | string |  | ReasonPrompt is what they are asked; empty is "Why? One line is enough." (maxLength 200) |
| `reasonMinutes` | integer | `30` | ReasonMinutes is how long the reply is waited for: 1 to 120, default 30. Never past the step's own wait. (minimum 1; maximum 120) |

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

## דוגמה

```yaml title="config"
buttons:
- id: issue
  title: הפק
- id: later
  title: לא עכשיו
language: he
params:
- '{amount}'
template: receipt_approval
text: להפיק קבלה על {amount}?
timeoutHours: 48
```

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

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

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
  name: my-whatsapp-cloud
  namespace: tenant-acme
spec:
  classRef: {name: whatsapp-cloud}
  config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: whatsapp-ask-example
  namespace: tenant-acme
spec:
  displayName: "Ask on WhatsApp and wait"
  triggers:
    - id: start
      ref: {name: whatsapp-message-received}
      connectorRef: {name: my-whatsapp-cloud}
      next: [whatsapp-ask]
  nodes:
    - id: whatsapp-ask
      stepRef: {name: whatsapp-ask}
      config:
        buttons:
        - id: issue
          title: הפק
        - id: later
          title: לא עכשיו
        language: he
        params:
        - '{amount}'
        template: receipt_approval
        text: להפיק קבלה על {amount}?
        timeoutHours: 48
```
