How do I embed a link to a reply in a telegram message? - telegram

I am trying to build a bot that sends messages which embed a couple of standard replies which can be sent just by tapping on them.
Each link would contain a space - e.g. "/ack 20134" & "/pass 20134"
So tapping on the first link causes the text "/ack 20134" to be sent back to the bot.
How do I embed this into the message that I send from the bot to the client in text, HTML or Markup?

set that element (button text for example) text field to "/ack 20134" .Then when user hit the button this command will send to your bot. you can use inline keyboards and set its data incallback_data to this value. But you cannont use it a text message because space separates two fields(embeds just "/ack" i.e. command part. user can hit it but your bot just receives "/ack".)
For text messages there is another option: do not use space(e.g. "/ack20134" without space) and your bot's would receive "/ack20134", then you must parse commands part)

Related

Botium Box crawler test case failing on Watson Assistant buttons

I am using Botium Box crawler on a Watson Assistant skill.
The bot's initial statement includes a greeting and seven buttons.
Botium is generating test cases for each of the buttons, but the button-press does not generate the right response in Watson Assistant.
A generated case is below:
1.6.2.2.2.4_hello_Password
#bot
#me
hello
#bot
UTT_M1_HI-THERE!
#bot
BUTTONS Benefits|Badges, Explanation of Badges or Certificate of Completion|COVID-19|ID Cards - Order, View, Print, Return|Employment/Termination|Password|None of the above, enter search text
#me
BUTTON password|Password
#bot
(responds as if Watson Assistant received the word "BUTTON" rather than the "password" value in "Password"-labeled button)
The dialog node has child responses using conditions like:
input.text=="password" or input.text.contains("password")
The expected behavior in Watson Assistant for a button press is that the button text (not label) is passed to the button. In the Watson Assistant Try it Out panel I click "Password" and it sends the text "password".
The only way I can replicate the Botium behavior in Try it Out is to pass the literal text "BUTTON". Even if Botium sent input.text=="BUTTON password|Password" my condition should fire.
Am I using Botium Box crawler wrong, or is there a bug in the crawler?
Update: Other button-driven prompts work, such as "yes/no" button prompts. I wonder if there is a parsing problem because the buttons have very long labels with some special characters and punctuation.
The issue has to be fixed with the next release of the crawler package.
If you need this fix now, then we can update directly your trial instance.
You can get more detailed log by set the DEBUG=botium-* env variable. So in commandline it should look like this:
DEBUG=botium-* botium-cli crawler-run --entryPoints 'hello'
In this case you will get a log and very detailed log. You can reduce its size with using exitCriteria (e.g.: --exitCriteria 'Benefits' 'Badges') to exclude those path which work correctly.
We will investigate the detailed log, just send us please.

Simulate a click on start button (at bots)

Is it possible to simulate a click on the start button without saying /start ?
This button simply sends a message with "/start" as the text to the bot, which can be done with client.send_message:
client.send_message(bot, '/start')
If it has parameters add them after a space:
client.send_message(bot, '/start argument')
Raw API also has messages.startBot which offers some more flexibility and I believe hides the start message.

How can I open a specific telegram account with preloaded text message

Is it possible to open a specific account with a preloaded text like this:
tg://resolve?domain={USER_NAME}&text=Hi, default message
https://t.me/{USER_NAME}?text=Hi, default message
There isn't (yet) a option to open a chat for a specific user, however, you can open the Telegram app, with an preloaded text, the user get's the option to pick a recipient from there chat list;
Use the following url;
tg://msg_url?url=Hi%21%20I%27m%20an%20example%21
Where;
url is the preloaded message (or link) (url-encoded)
After pressing the link, Telegram will ask for a recipent (picture).
If the user selects a chat from the sidebar, the preloaded text will be filled in the chat box (picture)

How to refer to a user in chat with their UIDs?

I have an array of User IDs which I've set as admins and I would like to print them to clients when they call the /admins command.
The main issue is that I couldn't see or find a way to print a placeholder entity (it's mention in this case) which opens a chat window with the IDs I've specified.
Remember that when you post #username in a chat, Telegram simply binds it as a mention to the referenced user and it jumps on a chat window when you click on it. I wonder if there is an equivalent for #123456789, where the number represents the User ID.
if you create/send a message from a bot, you can set parse_mode to HTML, then send text/caption with HTML anchor tag same this:
for contact me, just click here
but if you want to send message as user, you can just use userName prefixed by #, and creating manual link to tg://user?id=123 or type plain text like tg://user?id=123, don't work in Telegram now. yes; just in iOS (less than 15% of Telegram user) that work since 2013!

How do I send a message to Telegram that includes a button that prompts the user to forward the message?

Many Telegram bots (e.g., #youtube) have a button you can click on to forward messages sent by the bot. When the user clicks on this button, Telegram opens a contact list that lets the user choose who to forward the message to.
How can I send a button like this? The closest thing I can find is forwardMessage but that expects chat_id target ID as a required parameter. But I won't have this target ID until the user selects who they want to forward to.
If you want to share your content to specific chats, you have 2 options:
Option 1
If your bot has inline_mode enabled you can share content via a button that opens a inline_query in the chat selected. Basically, this is how #youtube bot works. To use this method you need to send an inline button with switch_inline_query as a field (documentation).
Example in Javascript:
bot.sendMessage(msg.chat.id, 'Share:', {
reply_markup: {
inline_keyboard: [[{
text: 'Share with your friends',
switch_inline_query: 'share'
}]]
}
})
This is the same example I use in my bot #livecoinbot, set a bitcoin address and use the share button.
Option 2
You can create a normal inline button or just simply send a link in a normal message, that will prompt the telegram client to share the content. Here is how you do it:
https://t.me/share/url?url=[url-to-send-here]&text=[text]
Example: Click here

Resources