Send notification messages with dismiss and navigate buttons.
Notifications are messages sent to a chat that are separate from the main screen flow. They support two modes:
Overlay mode (default)
Sends a message without replacing the current screen. Adds a dismiss button so the user can remove the notification:
Sexy.Bot.notify(chat_id, %{text: "Action completed!"})Replace mode
Replaces the current active screen. The notification becomes the new screen (mid is updated via Session):
Sexy.Bot.notify(chat_id, %{text: "Payment received!"}, replace: true)Navigation buttons
Add a button that deletes the notification and navigates to a command.
Sexy wraps this into the built-in /_transit route:
Sexy.Bot.notify(chat_id, %{text: "New order #42"},
navigate: {"View Order", "/order id=42"}
)You can also pass a function for custom callback data:
Sexy.Bot.notify(chat_id, %{text: "Alert"},
navigate: {"Details", fn mid -> "/show mid=#{mid}" end}
)Options
:replace—false(default) for overlay,trueto replace screen:navigate—{button_text, path}or{button_text, fn mid -> callback end}:dismiss_text— custom dismiss button text (default:"OK"):extra_buttons— additional button rows as[[%{text: ..., callback_data: ...}]]:after— auto-delete the notification after N seconds (integer or float)
Summary
Functions
Send a notification to a chat.
Types
@type notify_opt() :: {:replace, boolean()} | {:navigate, navigate_opt()} | {:dismiss_text, String.t()} | {:extra_buttons, [[map()]]} | {:after, number()}
Functions
@spec notify(integer(), map(), [notify_opt()]) :: map()
Send a notification to a chat.
message is a map like %{text: "..."} or %{upload_type: :document, file: "...", filename: "..."}
(also supports :photo, :video, :animation).
Options:
navigate: {"Button Text", "/command query"}— transit button (auto-wraps to /_transit)navigate: {"Button Text", fn mid -> "..." end}— custom callback with mid injectionreplace: false(default) — overlay mode, dismissablereplace: true— replaces current screen, no dismissextra_buttons: [[%{text: ..., ...}]]— extra button rows appended after navigate/dismissdismiss_text: "text"— custom dismiss button textafter: seconds— auto-delete the notification after delay