Skip to content

Configuration

Roman Samoilov edited this page Aug 6, 2020 · 6 revisions

Configure the gem using the TelegramWorkflow.configure call. The two required parameters are start_action and api_token.

TelegramWorkflow.configure do |config|
  config.start_action = <Start Action Class>
  config.api_token = <Your Token>
end
Method Default Description
api_token This is the token you get from the @botfather to access the Telegram API.
start_action This is an entry-point action, which is called every time /start or /startgroup command is sent to the chat. You cannnot redirect to this action or call it manually. Use it to set the things up, e.g. create a user record or store current user's id in the session.
session_store Rails.cache This is the session store. Default implementation stores session in memory, which means it will be reset after server shutdown. Can be customized. Use TelegramWorkflow::Stores::File for persistent file store.
logger Rails.logger Logger object. Can be customized.
client TelegramWorkflow::Client The object which implements Telegram API. Can be customized.
webhook_url The webhook url. Set it only if you are using webhooks for getting updates. TelegramWorkflow will create a webhook subscription automatically.
webhook_params {} The parameters sent to setWebhook action.

telegram_workflow will automatically send a request to the Telegram API to create a webhook if webhook_url is set. Every time the webhook_url or webhook_params params are changed the gem will recreate the webhook.

Example:

TelegramWorkflow.configure do |config|
  config.webhook_url = "WEBHOOK_URL"
  config.webhook_params = { allowed_updates: %w(message edited_message) }
end

Previous: Public API Next: Getting Updates

Clone this wiki locally