question-mark
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.

Add fanciness: forms

See original GitHub issue

Forms can allow a more complex chain of queries between the bot and the user, without requiring the programmer to define explicitly the interactions between them.

The original inspiration for this feature was from https://dev.albertocoscia.me/nodeogram/quickstart.html#forms.

While it is possible to implement this entirely in tgfancy, I believe it will be better to have a more generic solution, i.e. a form engine, that can be used across multiple platforms, other than just Telegram, using "adapters’.

A favorable API can be adapted from Inquirer.js.

The expected code would look something like: (this is hypothetical!)

// npm-installed module
const FormSet = require('forms');
const TgformAdapter = require('forms-telegram');
const ConsoleformAdapter = require('forms-console');


// module variables
const formset = new FormSet();
const tgformAdapter = new TgformAdapter(bot);
const consoleformAdapter = new ConsoleformAdapter();


// adding the adapters
formset.addAdapter('telegram', tgformAdapter);
formset.addAdapter('console', consoleformAdapter);


// adding a form, used for building a user's profile i.e name, age, etc.
formset.addForm('profile', [
    // name
    {
        name: "name",
        message: "What is your name?",
        validate(answer) { /* ... validate ... */ },
        when(answers) { /* ... do we ask ... */ },
    },
    // ... more questions ...
]);


// let's ask for the details from the user, on the command '/start'
bot.onText(/^\/start$/, function(msg, match) {
    formset.send('profile', 'telegram', function(error, answers) {
        // ... handle error ...
        // 'answers' is an object with the user's answers
        console.log(answers);
    });
});

tgfancy would offer a formset by default, for more implicit solutions!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kamikazechasercommented, Mar 1, 2017

Possibly use async await.

1reaction
kamikazechasercommented, Mar 1, 2017

@FaRzad-845 It’s just at theory. Work is in progress to make it a reality! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Increasing overall fanciness - Dragon Quest Builders 2
Making all the walls and floors out of gold brick/tile is the easiest way to get max fanciness. This. Just make a bunch...
Read more >
Fanciness - definition of fanciness by The Free Dictionary
1. The power of the mind to form images: fantasy, imagination, imaginativeness. · 2. An illusory mental image: · 3. An impulsive, often...
Read more >
Mini Guide Dragon Quest Builders 2: Scarlet Sands Red ...
Optional Increase overall Fanciness: To increase the overall fanciness of a room the wall and floor are taken into account so using Silver...
Read more >
What is another word for fanciness? - WordHippo
Find 437 synonyms for fanciness and other similar words that you can use instead based on 2 separate contexts from our thesaurus.
Read more >
Button Switches with Checkboxes and CSS3 Fanciness
Then, the label, which is where we'll add all the styling to. First of all, we set it to block and make it...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found