Make a Registration Bot with Telegram Bot API - php

I'm trying to make a bot that register an user on my website.
This bot should ask some key informations about the user like:
First Name
Last Name
Username
Email Address
Profile Link
In your opinion what is the best method to implement this feature?
I've seen somebody suggesting to use database in order to find out what message you've sent to user, and what information you have for the user and ask the missing one accordingly!
This particular way to solve this problem, could be effective but not so much efficient imho! Is there any way at all to use like a callback query or maybe give a message an specific id, so I can check whether the last message id is the "username_request" and respond accordingly?
Let me know
Oh by the way, I'm using PHP and the Webhook method!

For such tasks - there are solution. You need to install shapoapps/multibot_driver (composer require shapoapps/multibot_driver) for Laravel.
In this packet there are session manager. Its like sessions for web browser users. But only for messenger users (telegram, ...). After each user message received, you can record user input into the session on server side. When each new request(message) received, you read the data from the session and build the application logic.
Here's the documentation - https://github.com/shapoapps/multibot_driver

I'm working on a similar project at the moment.
I was thinking about some kind of syntax wherein you place the things you want to save, for example:
John,,,Hawk,,,JHawk,,,jhawk#gmail.com,,,https://www.url.com/
After saying
/adduser
John,,,Hawk,,,JHawk,,,jhawk#gmail.com,,,https://www.url.com/
inside the chat: you can split the message at the three commas (,,,) with PHP.
Otherwise you could:
Make some kind of transaction protocol to let the bot ask values per item after saying
/adduser
inside the Telegram chat.
Let me know how you think about these ways! Typing the three commas (,,,) once is not so much effort, but if you have to add multiple users a day... It could become very annoying..

Related

How do you handle multiple user in queuing system?

please click this link to show picture Im having a hard time analyzing on how I will create a queuing system where there is multiple user. Let us say that there is 2 user that is using a system how will i implement it? i dont get the logic on how it will be implemented. Like if the first user will tap the next button how will I update it as well that the queue number is update with the other user
Sounds like you need to use a database such as MySQL or MariaDB.
You would store the activity of each user's session in database tables. Of course, I could give you a more specific answer if your question were more specific.

Quickbooks PHP API Generating Invoices On Order Submission

I have a client that wants to take orders via an online form, with the idea being that an order can be submitted and stored in a database via my application while simultaneously generating an invoice on submission in QuickBooks.
How do I do this in PHP when the person entering in the order is not the client but a client of the client? It seems like Quickbooks uses Oauth tokens and a javascript library to generate them to connect a company to an app, but I'm simply writing a backend for one company and want that backend to create invoices when saving an order. How do I think about this?
I'm not interested in anyone having to hit a button that says "connect to quickbooks" especially not the person filling the order because again, that person is a customer and doesn't need to know about the internals of the customer's invoicing system.
I just really want to use the Accounting API to generate invoices. Is there no way to simply link my backend to my one company directly in the Quickbooks SDK configuration and achieve this, or do they need to use a javascript library to get tokens. I'm unclear about what direction I should be going in and don't want to waste time with a client-side library if I don't need it to do backend logic.
Here's some example code that does exactly what you're looking for:
https://github.com/consolibyte/quickbooks-php
Along with a quick-start guide:
http://www.consolibyte.com/docs/index.php/PHP_DevKit_for_QuickBooks_-_Intuit_Partner_Platform_Quick-Start
Also see notes about your comments below -- you're on the right track, you're just misunderstanding how OAuth works:
It seems like Quickbooks uses Oauth tokens and a javascript library to generate them to connect a company to an app, but I'm simply writing a backend for one company and want that backend to create invoices when saving an order.
Correct, Intuit uses OAuth, and a little Javascript thing to kick off the OAuth process.
I'm not interested in anyone having to hit a button that says "connect to quickbooks"
Someone needs to hit this button... BUT only ONE PERSON needs to hit the button ONCE, EVER, and then NEVER again.
The owner of the company (e.g. your boss) needs to click the button ONCE, which gives the OAuth creds (and the realm ID) to you. Once your boss has done this ONCE, then you have the creds to use forever, for all of the actual customers.
Your customers (e.g. the people actually checking out/placing orders) DO NOT click any buttons, nor do they see or have any idea at all that you're even using QuickBooks.
just really want to use the Accounting API to generate invoices.
Cool, you can totally do that!
Is there no way to simply link my backend to my one company directly in > the Quickbooks SDK configuration and achieve this, or do they need to use a javascript library to get tokens.
Follow the quick-start above. It should take you about 15 minutes to get a working OAuth connection, and then you never need to use the client-side stuff ever again.
You only need to authenticate every 180 days btw.
If you use the reconnect script, you only need to authenticate ONCE, and can automatically renew the tokens every 180 days, no user-interaction required.
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/reconnect.php
Well with the realm_id for example, I don't understand how that relates to ouath.
The realm ID is just a unique identifier for the particular QuickBooks Online company you're trying to connect to. Yes, you need to store it. If you use our libs, this is done for you automatically.
I guess I don't understand if I'm developing for one client why can't I just get their realm_id from them and then keep using it rather than making them do some form of authentication?
Again, they only have to authenticate ONCE. That's Intuit's way of giving you the realm ID and credentials you need to connect. Once you've done it ONCE, you never need to do it again. It takes all of about 30 seconds.
If they were to just give you OAuth creds without any authentication, it would be a gigantic security hole. If you read the Wikipedia article on OAuth it talks in depth about this, and the goals of OAuth.
Okay I think I get it, so they have to authenticate once every 180 days?
Once every 180 days, UNLESS you use a reconnect script, in which case they just authenticate once and then never ever have to worry about it again.
So I can store the token and the realm_id in a database before it expires and just use that?
Yes.
In this way my client can authenticate and then my scripts can generate invoices for them when their customers visit our website?
Yes!

Need advanced help, Wordpress & mailchimp

Heyhou!
I have tried to figure this out long time already, but no luck so far.
I have Wordpress site with mailchimp email form, so users are able to join my email list. The problem is:
-When user join the list, Mailchimp send automatically the confirmation email. I have edited it already to meet my requirements, but I need one more thing. I need to place URL where the joined user can download my free file, that URL needs to be one time url and it would redirect to my site where s/he can download the file.
Soooo, which way would be a best way to do that ? The main point is here that nobody can't start share the download link or page so users could download the file without to join my list. Poor English, hope you got the picture.
I'm web developer / PHP programmer, so plug in is not a must, (of course if you know one, let me know) I can make this by myself, but I need your help to solve the logic, how this would be done.
If I just place my website's download link in the Mailchimp confirmation email, there isn't anything which protect file. I need to somehow to crush the link after user is downloaded the file. BUT no manual changes in Mailchimp confirmation email.
There might be some super easy solution for this or not, anyway I'm stuck.
Thank ya!
I have used mailchimp previously and found the only way to push some data into an email, for this example a dynamic URL with a special access code is to set it as an extra bit of data on the users profile via the API.
http://developer.mailchimp.com/documentation/mailchimp/guides/manage-subscribers-with-the-mailchimp-api/
From when I last used Mailchimp you get 30 fields of custom data you can set on each user.
Hope that helps.

Post on a users wall on behalf of my app (not the user)

For several years i have managed to sort things out without posting my own question, but by readings others instead. However, after reading over 200 useless posts, i've decided it's time i get some help.
I'm building a facebook app, and what i wan't to do is extremelly simple to explain. I wan't to notify a certain user about some event in real-time. For example, "the tv show you want to watch starts in an hour". Unfortunately, facebook doesn't allow apps to send private messages to users (which was my first choice). The standard way of publishing on a users wall on HIS BEHALF is not good either, because no notification is triggered. Therefore, my idea is to post on his wall on behalf of the app (or any similar action that will trigger a notification).
I know about app requests, but they are not what i'm looking for either, as you can see, they do not match what i want to do.
Also please note that the event may be particular for each user, so making a post or something for EVERYBODY to see is not an option ("Peter, you have dinner with stacy in an hour").
Firstly, i want to know if posting on the apps behalf (or facebook page, or any other idea) is possible.
If it isn't, i would like to see any other ideas to sort this out. Remember, it's extremelly important to trigger the notification.
Thanks for your time reading this, but i have one last request.
Although what i want to do is pretty simple, there are plenty of similar issues being disscused, which may lead to confusion, so please be SURE that you fully understood what i am asking before answering.
Thanks again
What about opening an event and auto inviting the specific user to the event?
Events invites trigger a notification and the only thing you need is the user's email address which you can easily get.
I am not 100% sure if an app posting on your wall initiates a notification*. Although posting to a users wall on behalf of an app is certainly possible.
You can follow the instructions on this link, under the "App Login" title, and with that retrieve the correct access token you need to make calls as your app.
In order to have the functionality you specified, you'll have to request the offline_access permission from your users - this will allow you to post to your users wall even when he/she is not currently in or using your app. (or even logged into facebook)
*
Usually these posts on behalf of an app are user initiated - ie the user pressed "post to my wall."

Using OpenID to prove Stackoverflow membership

Here's the deal:
-Flair pretty much demands a Facebook app
-I'm working on learning the Facebook platform
Therefore, I've written a dinky little Facebook app to embed your Flair into a box on the side of your profile. If you're interested and on Facebook; beware that this is very much a work in progress, prone to change and has a whole bunch of rough edges.
However, I don't have an elegant way to say "this is MY Stackoverflow profile" from this dinky app. My current solution is best demonstrated this image. It is, frankly, idiotic; and there's nothing preventing impersonation.
Having no experience with OpenID, I'm wondering if there's some way (and some example of this way, please) to get a user to provide their Stackoverflow identify to a third party?
Behavior changed to that suggested by Noldorin's answer.
Request for a saner way to do this declined on UserVoice.
There's no way to get a StackOverflow ID from OpenID and to do the opposite would be possible but unnecessarily complicated (compared to your suggested method). Copying and pasting the user ID/profile URL isn't terribly inconvenient, in my mind.
However, I can suggest some sort of solution to the issue of impersonation. This may seem like a slightly silly method, but it's the simplest way of which I can think to insure that only the user themself can display the badge. Again, I don't think it's too inconvenient. (The more traditional method of using an email confirmation isn't possible, given that emails aren't public.)
Have your Facebook app generate a random (alphanumeric?) code. Something in the form A8IO45QW6T should do.
Hold this code on the server side of your Facebook app for a short time period (say, 5 minutes).
Instruct the user to edit their About Me information by adding the given code to the last line, then to return to the Facebook and confirm. Simple inspection of HTML for the profile page of the specified user would verify ownership. The user can then remove the verification code from their About Me text.
Nice idea creating this Facebook app, by the way. I may just give it a try!
Another solution that would allow for instant verification is hashing the email address and checking to see if it matches the user's Gravatar. Granted, not every user has provided an email address, but you can always perform this check first and if it fails you can fall back to the About Me section editing (or simply require that the user have an email address). This idea is not mine, so I'll let null explain:
Do you still have the source available? As I've gotten a solution to prevent other users from messing up your results. You just need to hash the email address used by the viewer and check for the gravatar image link on the page as outlined on the gravatar site. If the user id and image hash match, then record the change to the database, otherwise... just show results. I can make that change, but the source seems lost... :(

Categories