Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to load dynamic voice to menu?

See original GitHub issue

I have this menu:

const project = new TelegrafInlineMenu(ctx => 

const projectsHandler = new TelegrafInlineMenu(ctx => ctx.i18n.t('hereYourProjs'));
    async ctx => projectController.GetProjects(await ctx.getChatMember(,     
        columns: 1

essentially when I type the command “/myprojects” the controller “projectController” load all the projects available from my database as menu voice.

Now I would like to know how can I click on a voice menu (loaded from the database) and display the details of that voice. Eg:

  1. /mycommands
  2. bot load all the projects as voice menu 3 I click on a voice menu eg: “test”, the bot need to display the details of that project as a submenu and in that submenu I need to have also the back button to display again all the projects.

Could you kindly show me a little example how to do this?

Note: this method projectController.DisplayProjectDetails just return the project object that must be displayed as submenu after clicking on it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

EdJoPaTocommented, May 23, 2019

In general I assume you have two methods depending on your storage setup:

function getAllProjectKeys() {
  return ['karl', 'bob', 'tim']

function getProjectDetails(key: string): {description: string, …} {
  return {title: 'Bob', description: 'Very foo bar'}

My approach to writing a menu is this way:

function detailsMenuText(ctx) {
  const projectDetails = getProjectDetails(ctx.match[0])
  let text = ''
  text += projectDetails.title + '\n'
  text += projectDetails.description
  return text

const detailsMenu = new TelegrafInlineMenu(detailsMenuText)

const projectOverviewMenu = new TelegrafInlineMenu('Select your project')

projectOverviewMenu.selectSubmenu('p', getAllProjectKeys, detailsMenu)

I hope it helps 😃

EdJoPaTocommented, May 21, 2019

Thanks. Now I got what you want to achieve. In this case you already have the project menu?

Your projectMenu has a selectSubmenu with all the projects of the user as buttons. When the user uses a button he gets into the project menu and ctx.match[1] contains the chosen project as you already implemented. But you should not use ctx.reply there. You have to return the text in that function so it should be like this:

const project = new TelegrafInlineMenu(ctx => projectController.DisplayProjectDetails(ctx.match[1]));

Also the back button is only there when you defined its text in menu.init like you defined the back to main menu button. See the its documentation.

  backButtonText: 'back…',
  mainMenuButtonText: 'to Main Menu…'

I hope it helps 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Open Dialog via dynamic menu - Stack Overflow
Use Android Intent with Intent.ACTION_SEND . Which will share the link of .apk file on available application on device which handle SHARE Intent ......
Read more >
Creating Dynamic Menus - Avaya Documentation
You must create Dynamic Menus in Control Manager after creating an IVR point from the type of Dynamic Menu . Navigate to Avaya...
Read more >
Use Voice Control on your iPhone, iPad, or iPod touch
To return to a previous screen or menu, say, “Go back.” How to customize Voice Control settings. You can customize several settings under...
Read more >
How to Create a Dynamic Voice and Add Personality to Your ...
Check out the tips in this post and learn how to add a dash of personality to your blogging. Make your writing voice...
Read more >
Push dynamic shortcuts to Assistant - Android Developers
Define the dynamic shortcut for a menu item ... it is eligible to appear as a Voice Shortcut suggestion in the Assistant Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found