4

I was wondering if anybody has tried to implement a Telegram chatbot that requires the user to login.

I have an intent in dialogflow that requests the user's login ID (their email) and password, but I have no idea how to code that in the fulfillment.

If anybody has some sample codes to show me, that will be awesome.

Cadell Teng
  • 224
  • 3
  • 23

1 Answers1

1

I have attempted this and succeeded. However, it is quite a headache to set up. Basically, you need to use Dialogflow fulfillment to call a firebase function. There, you need to use Firebase Auth's ability to sign in with a custom token. (You might want to consider some form of encryption at this point). Then you send the token back to dialogflow. Now you have to store that token in one of many ways. Once again, you will definitely want to encrypt the token. Each time you send a message then, you send along the token to your function, which will (using Promises) either accept it if the token is correct or reject it if it is not.

See this code which shows how to use custom token auth with dialogflow. Hope this helps.

Mr. Arbitrary
  • 932
  • 11
  • 25
  • Hey A.S.H thanks so much for the information. You were using Firebase Admin SDK right? For the real-time database, you may only use the Admin SDK? – Cadell Teng Nov 27 '19 at 02:34
  • Yes, I was using the admin sdk in my Firebase functions. Note that my Firebase functions weren't the ones right there in Dialogflow, but a full node.js project linked to my Firebase app – Mr. Arbitrary Nov 27 '19 at 02:53