DEV Community

Ishan Rayeen
Ishan Rayeen

Posted on

4

Handling Inline Queries | Telegram Bot Development | Part 3

Telegram bot development using node.js and Telegraf API.

What you will learn:

  • Inline Query.
  • handling inline query using bot.on().
  • creating a bot that will search the dev.to API and the OMDB API
  • And a lot more.

Requirements:

  • Please watch Part 1 and 2.
  • Basic Programming (everything will be taught from basics).
  • Telegram Account.

Example Bot:
Search for @covid_19_india_bot on telegram or click here
https://t.me/covid_19_india_bot

Top comments (1)

Collapse
 
homeyramahmoudi profile image
Homeyra Mahmoudi

thanks for your tutorial, i have a question regarding the inline keyboard, I am building a Geodata collector bot and I want to use inline keyboard but I'm not able to use the request_location for acquiring the location of the user because I think it just works on the keyboard not inline keyboard. and since I want to use the callback in my buttons I'm kinda stuck and confused that how I could manage this. if you can help me I appreciate it.

//buttons for getting the location
bot.action("POS-PCdF", (ctx) => {
ctx.deleteMessage();
console.log(ctx.from);
bot.telegram.sendMessage(ctx.chat.id, "Can we access your location?", {
reply_markup: {
keyboard: [
[
{
text: "Access my location",
request_location: true,
callback_data: "Access_my_loc",
},
{ text: "Cancel", callback_data: "PCdF" },
],
],
},
});
});

//the main menu that I want to use in the callback
bot.action("PCdF", (ctx) => {
ctx.deleteMessage();
ctx.telegram.sendMessage(
ctx.chat.id,
"Share with us the problems about Parco Campo di Fiori!",
{
reply_markup: {
inline_keyboard: [
[
{ text: "Pictures", callback_data: "PIC-PCdF" },
{ text: "Location", callback_data: "POS-PCdF" },
],
[
{ text: "write to us", callback_data: "TEXT-PCdF" },
{ text: "Go back Home", callback_data: "go-back" },
],
],
},
}
);
});

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay