# Ask on WhatsApp and wait

> Asks a question with up to three buttons and waits for the tap, then goes on with the answer. Outside 24 hours it sends the approved template you name.

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

## At a glance

| Property | Value |
| --- | --- |
| **Step name** | `whatsapp-ask` |
| **Resource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palette group, category** | notify, messages |
| **Credits** | **1** credit each time it succeeds |
| **Side effects** | yes: It changes something outside Lumen, so a retry asks first and a test shows what it would do instead of doing it. |
| **Installation must provide** | nothing |

## Inputs

| Property | Value |
| --- | --- |
| **Needs** | nothing |
| **Produces** | `fields` |
| **Works on** | item: one document at a time |

Needs and Produces are data types (file, text, fields, email). The editor offers a step only where what it needs is already on the path. See [Documents and data](https://docs.go-lumen.ai/concepts/how-flows-run.md#documents-and-data).

## Outputs

A later node references an output as `{nodeId.field}` in text, or `nodeId.field` in a condition.

| Output | Type |
| --- | --- |
| `answer` | string |
| `answerTitle` | string |
| `answeredBy` | string |
| `answeredAt` | date |
| `reason` | string |
| `reasonQuoted` | string |

## Settings

Set under `config:` on the flow node. Text settings may contain `{nodeId.field}` placeholders.

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `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` (required) | string |  | Question (minLength 1; maxLength 1024) |
| `buttons` (required) | list of object |  | Answers (minItems 1; maxItems 3) |
| `buttons[].id` (required) | string |  | ID is what comes back in the run the tap starts (its buttonId). (minLength 1; maxLength 256) |
| `buttons[].title` (required) | 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) |

The full JSON Schema of these settings: [whatsapp-ask.schema.json](https://docs.go-lumen.ai/schemas/steps/whatsapp-ask.schema.json).

## Example

Approve a receipt

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

## Use it in a flow

A node that runs `whatsapp-ask` goes under `spec.nodes` of a [Flow](https://docs.go-lumen.ai/concepts/how-flows-run.md#the-flow-as-yaml). Give it any id, and list the next node ids in 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
```
