Kogno
  • Introduction
  • Getting Started
    • Configuration
    • Starting the Server
    • Messenger Configuration
    • Telegram Configuration
    • WhatsApp Configuration
    • NLP Configuration
  • Conversation Class
  • Contexts
    • Blocks
      • before_anything
      • postback
      • deep_link
      • command
      • any_attachment
      • regular_expression
      • keyword
      • any_number
      • any_text
      • intent
      • entity
      • membership
      • recurring_notification
      • everything_else
      • after_all
    • Sub Contexts
    • Routing
    • Sequences
    • Conversational Forms
  • Replies / Notifications
    • text
    • button
    • quick_reply
    • raw
    • list
    • carousel
    • url
    • typing
    • image
    • video
    • html
    • markdown
    • contact
    • location
    • recurring_notification_request
    • messenger_generic_template
    • whatsapp_template
  • Templates
  • Models
    • User model
  • Scheduled Messages
  • Telegram Inline Query
  • Command Line
  • Global Methods
  • Internationalization
Powered by GitBook
On this page
  • command(name=String|Symbol, &block)
  • Platforms
  • Usage
  • Configuration
  • Command Line

Was this helpful?

  1. Contexts
  2. Blocks

command

Catches a Telegram command, which has been specified as an argument.

Previousdeep_linkNextany_attachment

Last updated 2 years ago

Was this helpful?

Read more about Telegram commands in the .

command(name=String|Symbol, &block)

Platforms

Platform
Supported

Messenger

WhatsApp

Telegram

Usage

class MainContext < Conversation

  def blocks
    
    command :start do
      @reply.text "Hello and welcome!"
    end
    
end

Configuration

 config.telegram.commands = [
    {
      scope: :default,
      commands:{
        start: "Start chat",
        featured_products: "List featured products."
      }
    },
    {
      scope: :all_chat_administrators,
      commands:{
        update_products: "Update products from server.",
        purchase_count: "Sales today."
      }
    }

  ]

Command Line

Once configured, these changes must be sent to Telegram by running the following command in terminal.

Update all scopes

kogno telegram set_commands all

Update the scopes individually

kogno telegram set_commands all_chat_administrators

Routing to Context

In order to be implemented in Kogno, the commands must be created first in Telegram through the or well, by defining them in the configuration file by modifying config.telegram.commands field.

Available scopes are: :default, :all_private_chats, :all_group_chats and :all_chat_administrators. .

Each command can be routed to a specific context, learn how in .

official documentation
BotFather
config/platforms/telegram.rb
Read more about Commands Scopes on Telegram
Routing Chapter