It is possible to use Odysseus together with Telegram (https://telegram.org/). You need to install the Telegram Wrapper Feature.
The communication is done via a Telegram Bot (https://core.telegram.org/bots).
So you first need to create a new telegram bot and get the token.See https://core.telegram.org/bots#6-botfather
Now you can create a source in Odysseus:
#PARSER PQL
#RUNQUERY
telegram := RECEIVE({
transport = 'Telegram',
source = 'Telegram',
datahandler = 'KeyValueObject',
OPTIONS = [['telegram.api.token','PLACE YOUR TOKEN HERE']]
}
)
You can now process the data. In the following simple example a response is send to the sender.
Remark: The SENDER currently only supports KeyValueObjects with the attributes: "chart.id" as long and "text" as String.
#PARSER PQL
#ADDQUERY
message = KEYVALUETOTUPLE({
schema = [
['message.message_id','long'],
['message.from.id','long'],
['message.from.first_name','String'],
['message.from.last_name','String'],
['message.from.username','String'],
['message.chat.id','long'],
['message.chat.first_name','String'],
['message.chat.last_name','String'],
['message.chat.username','String'],
['message.chat.type','String'],
['message.date','long'],
['message.text','String']
],
keepinput = false,
type = 'Message'
},
telegram
)
reply = MAP({
expressions = [
['message.chat.id','chat.id'],
['"Hallo " + message.from.first_name','text']
]
},
message
)
replyKV = TUPLETOKEYVALUE(reply)
out = SENDER({
transport = 'Telegram',
protocol = 'None',
sink = "OdysseusTelegram",
wrapper = "GenericPush",
options = [
['telegram.api.token','PLACE YOUR TOKEN HERE']
]
},
replyKV
)