# quick\_reply

### <mark style="color:orange;">`quick_reply(text=String, buttons=Array/Hash, params=Hash)`</mark>

## **Platforms**&#x20;

<table><thead><tr><th width="194.16239518483945">Platform</th><th width="150.18844850881004" data-type="checkbox">Supported</th><th>Native Name</th></tr></thead><tbody><tr><td>Messenger</td><td>true</td><td><a href="https://developers.facebook.com/docs/messenger-platform/reference/buttons/quick-replies"><code>quick_replies</code></a></td></tr><tr><td>WhatsApp</td><td>true</td><td><a href="https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages#interactive-messages"><code>InteractiveMessages / button</code></a></td></tr><tr><td>Telegram</td><td>true</td><td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup"><code>InlineKeyboardMarkup</code></a></td></tr></tbody></table>

## Usage

Can be called as reply or On-Demand, for this example we'll use <mark style="color:blue;">`@reply`</mark> inside the conversation.

```ruby
@reply.quick_reply(
  "Hello, how can I help today?",
  [
    {
      title: "Create an account",
      payload: "profile/create_account"
    },
    {
      title: "Read TOS",
      payload: "read_tos"
    },
    {
      title: "Feature Product",
      payload: set_payload("products/view", { product_id: 10 })
    }
  ]
)
```

{% hint style="info" %}
In either case, the click event will be captured by a [postback](https://docs.kogno.io/contexts/blocks/postback) block (if declared) in the context defined in the payload route.
{% endhint %}

## Payload formats

### To the same context

```ruby
"read_tos"
```

### To a different context

```ruby
"profile/create_account"
```

### With params

```ruby
set_payload("products/view", { product_id: 10 })
```

## Arguments

<table><thead><tr><th width="270.4654888486732">Name</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:orange;"><code>text</code></mark></td><td><p><strong>Required.</strong></p><p>The text displayed above the buttons.</p></td></tr><tr><td><mark style="color:orange;"><code>buttons</code></mark></td><td><strong>Required.</strong><br>One or several buttons that can be payloads or links in some platforms<strong>.</strong></td></tr><tr><td><mark style="color:orange;"><code>params</code></mark></td><td><strong>Optional.</strong><br>Extra parameters that may vary between platforms.</td></tr></tbody></table>

### Extra params

Below are some unified or built-in parameters from this framework.

#### <mark style="color:orange;">`typed_postbacks`</mark>

Regardless of the value of `config.typed_postbacks` in the [main configuration](https://docs.kogno.io/getting-started/configuration), this feature can be enabled/disabled independently passing this parameter with true or false.

```ruby
@reply.button(
  "Hello, how are you today?",
  [
    {
      title: "Good",
      payload: "good_mood"
    },
    {
      title: "Bad",
      payload: "bad_mood"
    }
  ],
  { typed_postbacks: true }
)
```

#### <mark style="color:orange;">**`slice_replies`**</mark>

Only available in Telegram, it allows displaying a defined amount of buttons in rows.

```ruby
@reply.button(
  "Choose a number from 1 to 10",
  (1..10).map{|number|
    {
      title: "Number: #{number}",
      payload: set_payload(:number_response,{ number: number})
    }
  },
  { slice_replies: 3  }
)  
```

{% hint style="success" %}
For more information, read more about the expected params for each platform:

* [Messenger](https://developers.facebook.com/docs/messenger-platform/reference/buttons/quick-replies)
* [WhatsApp](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages#interactive-messages)
* [Telegram](https://core.telegram.org/bots/api#inlinekeyboardmarkup)
  {% endhint %}
