# לשאול במייל ולחכות לתשובה

> שולח שאלות ממוספרות במייל ומחכה לתשובה. התשובה חוזרת לאותה הרצה, כולל קבצים מצורפים, ויכולה להחזיר אותה לשלב ששאל, שקורא את התשובות ושואל שוב או ממשיך. אם לא מגיעה תשובה בזמן, ההרצה ממשיכה והשאלות נשארות פתוחות.

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

## במבט אחד

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

## קלט

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

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

## פלט

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

| פלט | סוג |
| --- | --- |
| `reply` | string |
| `replyQuoted` | string |
| `replyFrom` | string |
| `repliedAt` | date |
| `round` | number |
| `timedOut` | boolean |
| `replyFiles` | number |
| `questions` | string |
| `asked` | boolean |
| `open` | number |
| `rulesProposed` | string |

## הגדרות

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

| הגדרה | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `to` (חובה) | text or list |  | Ask (maxLength 2000; maxItems 20) |
| `subject` | string |  | A custom subject starts a new conversation in Gmail, apart from the email that started the run. Leave it empty to reply in that conversation. (maxLength 200) |
| `intro` | string |  | Intro is a short paragraph above the questions, Markdown. (maxLength 2000) |
| `questions` (חובה) | string |  | Questions is a list field (an agent's questions, `{extract.reply.questions}`), each a text or `{"id","text"}`; or text, one question per line. (minLength 1; maxLength 4000) |
| `answersFrom` | string |  | AnswersFrom is the list field the flow's agent reads the reply into, \[`{"question_id","answer","applies"}`\], recorded on the round for the run's conversation, and the lasting ones proposed as rules. (maxLength 200) |
| `redo` | string |  | Redo is the node, upstream of this one, the run goes back to with the reply (the agent that asked): it reads {<this node>.replyQuoted} and asks again or goes on. Empty goes on to this node's next with the reply. (maxLength 63) |
| `maxRounds` | integer | `3` | MaxRounds is how many questions emails one run sends at most: 1 to 5, default 3. After the last round the run goes on with what is open. (minimum 1; maximum 5) |
| `timeoutHours` | integer | `72` | TimeoutHours is how long each round waits: 1 to 720, default 72. With no reply by then the run goes on with the questions open. (minimum 1; maximum 720) |
| `reminders` | object |  | Reminders are sent in the questions email's thread while nobody has replied; each is measured from when the email went out. |
| `reminders.after` | list of string |  | How long after the email went out, such as 24h. Each one sends a reminder if nobody answered by then; at most three, each shorter than the wait. (maxItems 3) |
| `reminders.message` | string |  | Empty is Lumen's own text, in the email's language. (maxLength 1000) |
| `onTimeout` | object |  | OnTimeout says who is told when the deadline passes with no reply and the run goes on with the questions open. |
| `onTimeout.notify` | list of string |  | Addresses told when nobody answered in time; `{email.from}` is the sender of the email that started the run. (maxItems 5) |
| `onTimeout.message` | string |  | Empty is Lumen's own text, in the email's language. (maxLength 1000) |
| `lang` | string |  | Lang is the email's language, he or en; empty follows the questions. (one of, he, en) |
| `replyConnector` | string |  | ReplyConnector is the email-forward connection replies come back to; empty is the one whose email started the run. (maxLength 253) |
| `acknowledge` | boolean |  | Acknowledge sends a short "got it" when a reply is taken. |
| `testColumn` | string |  | TestColumn starts the test case columns that answer the rounds in an evaluation: <column>\_1, <column>\_2; default reply. (maxLength 63) |

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

## דוגמה

```yaml title="config"
questions: '{questions}'
timeoutHours: 72
to: ops@yourcompany.co.il
```

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

צומת שמריץ את `ask-by-email` נכנס תחת `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: Flow
metadata:
  name: ask-by-email-example
  namespace: tenant-acme
spec:
  displayName: "Ask by email and wait for the reply"
  triggers:
    - id: start
      ref: {name: manual-run}
      next: [ask-by-email]
  nodes:
    - id: ask-by-email
      stepRef: {name: ask-by-email}
      config:
        questions: '{questions}'
        timeoutHours: 72
        to: ops@yourcompany.co.il
```
