I created a chatbot to work with my fanpage on Facebook. This was done with a node.js base. When I do a 'firebase init', I get a /public folder and lots of other stuff. I do 'firebase deploy', but my bot is never called. Is there a way for work this out?
I have this as a reference:
Hosting nodeJS app with firebase
Still I got some faith this is a different case. Thanks in advance!
Well, I believe I got the answer now. Firebase only supports hosting for frontend stuff. For a chatbot I'd use something like NodeJS, PHP or other backend tecnologies. Thus, Heroku is a good call.
You should be able to Cloud Functions for Firebase to write a chat bot - I believe you might need to use a paid plan because the free tier does not allow Functions to make outbound calls.
I found a gist that appears to be an actual Facebook chat bot using functions:
https://gist.github.com/mikkipastel/37fa011e3aea7ebb9941fb3dab6f1186
Related
I have an Capacitor.js app and it uses the Firebase Cloud Messaging SDK for Push Notifications via the Push Notification Plugin. I also have a Discord bot (this is less relevant) and I want to, when a user sends a message, it will send that data to the Firebase and then that will create a notification so that the Capacitor.js app will have a notification with said data.
But I am new to Firebase and I have been reading their documentation and it is quite difficult to 1). Navigate and 2). they don't have any useful code snippets I can look at to learn how it works. Maybe that's just a problem I have, idk.
I'm wanting it for Node.js. And I really have no idea what I am doing. I have installed the Firebase Node.js package and that's about all.
I'm working on a school project using vanilla HTML, CSS, and JS. When compete, we're expected to have the repo working via GitHub Pages. It's above and beyond the scope of the assignment, but I wanted to connect to a Firebase Firestore database.
The question is, how do I hide the API key/information, using only vanilla HTML, CSS, and JS (no frameworks), and have a working GitHub Pages demo for the instructor to mark?
I've looked at a number of websites and YouTube videos, but every tutorial I've come across is either using a framework or some stack of packages that would go against the 'rules' of the assignment. I can use a .env file, but to my understanding, because the repo is public the key would be public.
Any advice would be greatly appreciated.
The answer is .env files (sort of).
If you're building a frontend project and you're connecting the front end directly to your database, your credentials will be visible.
The correct way to handle keys is to put them in your backend API. Of course, when I asked this question, I wasn't "there yet".
Your backend API can have a public endpoint that listens to incoming requests. You don't need to include your database credentials in the request coming from your frontend app. It hits your backend api at its public endoint where your backend code then handles the incoming request. On your backend you have the connection to your database with the necessary credentials. This is how you are supposed to build it.
For beginners, you might want to try Google Firebase. With Firebase you can create Firebase Functions. With these, you can create a simplified API endpoint to target with your front-end requests. It triggers the Firebase Function to run, and inside this function, you can store your private keys/credentials. Because your Firebase Functions run on your own secure backend, the client never sees the keys.
If you're learning or familiar with Vue3, here's a good article to check out: https://www.bezkoder.com/vue-3-firebase/#more-9260
I have built a webbshop in Vue js and everything is done but the payment method is missing. Do i need to have express to take charges to stripe? I do not have a server like express now. And if i need express to take charges from paypal sdk or stripe sdk how can i host it later so its not running on my localhost? Its running on localhost port 3000 so how can i make it work on a ftp later?
Anyone that can help me?
I have tried to implement stripe or paypal for a week know but it seems impossible.
PayPal Checkout will get that done for you: https://developer.paypal.com/docs/checkout/#
That doc guides you on setting this up directly in your JS app, or you can also use a server back-end with PHP or something else if you prefer.
This will give you PayPal, PayPal Credit, Venmo, and direct credit cards all in a single checkout integration.
I've built an iOS/firestore app. I'm now looking to create a web app to integrate with my database. I was going through the documentation and found a distinction between firebase for Node.js (https://firebase.google.com/docs/web/setup) and firebase firebase admin SDK (https://firebase.google.com/docs/admin/setup).
I believe that I will want admin privileges and control over the web app but since I'm learning this for the first time should I focus on the basics of getting user auth, access to the database, storage and cloud functions working? Or will be changing/adding the admin privileges down the line be such a hassle that it's better to struggle through it now?
I'm still new to the web side of firebase and I'm trying to get a feel for the approach I should take.
If you're building a web interface for your app, I'd encourage you to use the Firebase JS SDK and do most of the work client-side. It should be pretty similar to what you've already done in iOS.
You should only use the Admin SDK if you're specifically trying to create endpoints with custom trusted functionality that isn't available by using the normal SDKs.
I have a big problem.
My database and authentication runs over Firebase.
I want to update a user to premium by calling this:
function getPremium() {
firebase.database().ref('premium').child(user.uid).set({
premium: true,
})
Everything works great, user updated to premium.
Now a guy comes around who knows a little bit of javascript and Firebase
so he simply opened the dev tools and run this code:
firebase.database().ref('premium').set({
iRuinedYourSite: true,
})
What can I do about it?
Is it so unsecure or what am I doing wrong to prevent something like this?
If your client-side code can upgrade the user, then the user can upgrade themselves, full stop. There is nothing your code can do on the client that a sufficiently-motivated end user can't do from the client.
You need to have a server involved, gate-keeping the interaction.
You could use Firebase's NodeJS Admin SDK to run a simple NodeJS Server that handles all of the premium requests. The NodeJS Admin SDK overrides Firebase Security Rules so you don't need to worry about that. Here's a link: https://firebase.google.com/docs/admin/setup
Edit: You could also use Firebase Functions which is basically a NodeJS Server that uses a special package to interact with the database. Here a link: https://firebase.google.com/docs/functions/
Hope this helps!
For anyone who wants to accept PayPal payments with Firebase,
Connect your Firebase project with Zapier, then connect Zapier with your Paypal account and let Zapier handle everything. It will cost you 25$ / Month but will bring in the security you need.