A
A
Ayan Bai2019-08-02 19:21:44
JavaScript
Ayan Bai, 2019-08-02 19:21:44

How to register a user through Telegram bot?

Friends, I write in Google Apps Scrip telegram bot for my friends.
They fix and fix computers. They mainly work with legal entities.
so they need a ticket system for processing applications.
We decided that the telegram bot is perfect for processing applications.
The first thing to do is to register a company.
To do this, I brought up a button:

function doPost(e){
  var data = JSON.parse(e.postData.contents);
  var text = data.message.text;
  var id = data.message.chat.id;
  var name = data.message.chat.first_name + " " + data.message.chat.last_name;
  var answer = "Салам " + name + "! Спасибо за обращение "+ text;
  
  Logger.log(text + " command passed");
  
  if(text =="/start"){
    var options = [
          [{ text: 'Новый заказ', callback_data: 'order' }],
          [{ text: 'Регистрация', callback_data: 'registration' }],
          [{ text: 'Реквизиты', callback_data: 'data' }]
        ];
    sendKeyboard(id, "Приветствую дорогой друг! Чем могу быть полезен?", options, true);  
  }
  else if ( text == "Регистрация" ){
    sendMessage(id, "Введите ваше фио");
  }
  else{
    answer = "Text message passed";
    sendMessage(id, answer);
  }
  SpreadsheetApp.openById(ssId).getSheets()[0].appendRow([new Date(), id, name, answer]);
}

Now, how do I collect data from the user?
This is the full name, name of the office, contacts.
If in parallel to me several people will be hollowed out, how can I process their requests?
If, for example, the user entered a full name, how to understand what this full name is and offer him to enter the next value?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2019-08-02
@Zoominger

Maybe it's easier to hire a freelancer?
Full name is three words separated by spaces, starting with a capital letter. You just check the string against this rule and that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question