> For the complete documentation index, see [llms.txt](https://docs.kogno.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kogno.io/replies-notifications/button.md).

# button

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

## **Platforms**&#x20;

<table><thead><tr><th width="164.01808162565487">Platform</th><th width="150" 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/"><code>buttons</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#replykeyboardmarkup"><code>ReplyKeyboardMarkup</code></a></td></tr></tbody></table>

## Usage

### Reply

```ruby
@reply.button(
  "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 })
    }
  ]
)
```

### On-Demand

```ruby
user.notification.button(
  "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 })
    }
  ]
)
user.notification.send()
```

{% hint style="info" %}
In either case, the click event will be captured by a [postback](/contexts/blocks/postback.md) 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](/getting-started/configuration.md), 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/)
* [WhatsApp](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages#interactive-messages)
* [Telegram](https://core.telegram.org/bots/api#replykeyboardmarkup)
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kogno.io/replies-notifications/button.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
