Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

TelegramBot

Guides

  • TelegramBot Guide

Symbols

  • CreateBotSession
  • DeployBotWebhook
  • getMe
  • getUpdates
  • HandleBotUpdates
  • ImportTelegramFile
  • Object
  • sendMessage
  • sendPhoto
  • TelegramBot
LongPolling
About how to create a bot that will work in the current session and respond to messages
TelegramBot
bot object
getUpdates
check incoming messages
sendMessage
send reply
XXXX.
Import the package:
In[49]:=
<<KirillBelov`TelegramBot`
Let's create a bot first:
In[50]:=
bot=
TelegramBot
["1247031088:AAGW73yzggrm4Tr7bldGCCaIrrwISNsdDzg"]
Out[50]=
TelegramBot
Name: WolframKernelBot
History Length: 4
Mode: Webhook
Task: None
Webhook: https://www.wolframcloud.com/obj/kirillbelovtest/webhook

Let's create an event handler that will respond to all "Hello" messages:
In[51]:=
handlerHi[bot_TelegramBot,update_?AssociationQ]:=​​Module{chat},​​chat=update["message","chat","id"];​​
sendMessage
[bot,chat,"Hello"]​​
Delete webhook if exists:
In[52]:=
deleteWebhook
[bot]
Out[52]=
okTrue,resultTrue,descriptionWebhook was deleted
Add this handler as a bot property:
In[53]:=
bot["UpdateHandler"]=handlerHi
Out[53]=
handlerHi
And run the bot in the current session:
In[54]:=
bot["Task"]=SessionSubmitScheduledTask
HandleBotUpdates
[bot],{Quantity[1,"Seconds"],300}
Out[54]=
Go to the chat and let;s send to the bot "Hi"
RelatedGuides
▪
TelegramBot Guide
RelatedTechNotes
▪
Webhooks
""

Powered by the Wolfram Cloud More about Wolfram Technology

© 2022 Wolfram Research, Inc. All rights reserved. Terms of Use Privacy Contact Us