This block library allows to interact with a Telegram bot though the offered Thing Actions.
You need the Telegram binding and a properly configured bot Thing.
Blocks
Individual messages
The first three blocks can send individual messages.
Queries/answers
The last two blocks allow to build conversations with the bot through queries and answers. The queries can display buttons and another rule will react to the user’s reply using those buttons.
You can use the Telegram: Process Answer rule template to set up such a rule (with Blockly too), offering a complete Blockly set of tools for Telegram.
Changelog
Version 0.1
- initial release
Resources
uid: telegram
tags: []
props:
parameters: []
parameterGroups: []
component: BlockLibrary
config:
name: Telegram
slots:
blocks:
- component: BlockType
config:
args0:
- name: MESSAGE
type: input_value
- name: BOT
type: input_value
colour: "#2ea5d8"
helpUrl: ""
inputsInline: true
lastDummyAlign0: right
message0: send on Telegram %1 from bot %2
nextStatement: ""
previousStatement: ""
tooltip: ""
type: message
slots:
code:
- component: BlockCodeTemplate
config:
template: >
{{utility:things}}.getActions('telegram', {{input:BOT}}).sendTelegram({{input:MESSAGE}});
toolbox:
- component: PresetInput
config:
fields:
TEXT: What's up?
name: MESSAGE
shadow: true
type: text
- component: PresetInput
config:
name: BOT
shadow: true
type: oh_thing
- component: BlockType
config:
args0:
- name: ATTACHMENT_TYPE
type: field_dropdown
align: right
options:
- - photo
- Photo
- - animation
- Animation
- - video
- Video
- name: URL
type: input_value
align: right
- name: CAPTION
type: input_value
align: right
- name: BOT
type: input_value
align: right
lastDummyAlignRight0: true
colour: "#2ea5d8"
helpUrl: ""
inputsInline: false
lastDummyAlign0: right
message0: send %1 on Telegram %2 with caption %3 from bot %4
nextStatement: ""
previousStatement: ""
tooltip: ""
type: message_attachment
slots:
code:
- component: BlockCodeTemplate
config:
template: >
{{utility:things}}.getActions('telegram', {{input:BOT}}).sendTelegram{{field:ATTACHMENT_TYPE}}({{input:URL}}, {{input:CAPTION}});
toolbox:
- component: PresetInput
config:
fields:
TEXT: URL or filename
name: URL
shadow: true
type: text
- component: PresetInput
config:
fields:
TEXT: caption
name: CAPTION
shadow: true
type: text
- component: PresetInput
config:
name: BOT
shadow: true
type: oh_thing
- component: BlockType
config:
args0:
- name: URL
type: input_value
align: right
- name: USERNAME
type: input_value
align: right
- name: PASSWORD
type: input_value
align: right
- name: CAPTION
type: input_value
align: right
- name: BOT
type: input_value
align: right
lastDummyAlignRight0: true
colour: "#2ea5d8"
helpUrl: ""
inputsInline: false
lastDummyAlign0: right
message0: send photo on Telegram %1 username %2 password %3 with caption %4 from bot %5
nextStatement: ""
previousStatement: ""
tooltip: ""
type: message_attachment_photo_with_creds
slots:
code:
- component: BlockCodeTemplate
config:
template: >
{{utility:things}}.getActions('telegram', {{input:BOT}}).sendTelegramPhoto({{input:URL}}, {{input:CAPTION}}, {{input:USERNAME}}, {{input:PASSWORD}});
toolbox:
- component: PresetInput
config:
fields:
TEXT: URL or filename
name: URL
shadow: true
type: text
- component: PresetInput
config:
fields:
TEXT: caption
name: CAPTION
shadow: true
type: text
- component: PresetInput
config:
fields:
TEXT: user
name: USERNAME
shadow: true
type: text
- component: PresetInput
config:
fields:
TEXT: pass
name: PASSWORD
shadow: true
type: text
- component: PresetInput
config:
name: BOT
shadow: true
type: oh_thing
- component: Separator
config:
gap: 48
- component: BlockType
config:
args0:
- name: MESSAGE
type: input_value
align: right
- name: BOT
type: input_value
align: right
- name: REPLY_ID
type: input_value
align: right
- name: BUTTONS
type: field_input
align: right
lastDummyAlignRight0: true
colour: "#2ea5d8"
helpUrl: ""
inputsInline: false
lastDummyAlign0: right
message0: ask on Telegram %1 from bot %2 use reply id %3 with buttons %4
nextStatement: ""
previousStatement: ""
tooltip: ""
type: query
slots:
code:
- component: BlockCodeTemplate
config:
template: >
{{utility:things}}.getActions('telegram', {{input:BOT}}).sendTelegramQuery({{input:MESSAGE}}, {{input:REPLY_ID}}, {{field:BUTTONS}});
toolbox:
- component: PresetInput
config:
fields:
TEXT: Turn off the lights?
name: MESSAGE
shadow: true
type: text
- component: PresetField
config:
name: BUTTONS
value: "'Yes', 'No'"
- component: PresetInput
config:
fields:
TEXT: replyId
name: REPLY_ID
shadow: true
type: text
- component: PresetInput
config:
name: BOT
shadow: true
type: oh_thing
- component: BlockType
config:
args0:
- name: MESSAGE
type: input_value
align: right
- name: REPLY_ID
type: input_value
align: right
- name: BOT
type: input_value
align: right
lastDummyAlignRight0: true
colour: "#2ea5d8"
helpUrl: ""
inputsInline: false
lastDummyAlign0: right
lastDummyAlign1: right
message0: reply on Telegram %1 to reply id %2 from bot %3
nextStatement: ""
previousStatement: ""
tooltip: ""
type: answer
slots:
code:
- component: BlockCodeTemplate
config:
template: >
{{utility:things}}.getActions('telegram', {{input:BOT}}).sendTelegramAnswer({{input:REPLY_ID}}, {{input:MESSAGE}});
toolbox:
- component: PresetInput
config:
fields:
TEXT: Ok!
name: MESSAGE
shadow: true
type: text
- component: PresetInput
config:
fields:
TEXT: replyId
name: REPLY_ID
shadow: true
type: text
- component: PresetInput
config:
name: BOT
shadow: true
type: oh_thing
utilities:
- component: UtilityJavaType
config:
javaClass: org.openhab.core.model.script.actions.Things
name: things