Messenger bot - timed responses - php

I've built a basic facebook messenger bot with PHP. How do I enable timed push notifications?
For example, here's an appointment booking scenario:
User schedules a meeting for 2pm on Friday
Bot remembers the timed information and at 1:45pm on Friday, the bot sends a message reminding the user of the appointment.
I understand that there's gotta be a database involved, but I'm wondering if someone could point me in the right direction to what functions to use or if there are any docs for this time related pushes with php.
*Note: I'm not looking for free code, but rather a point in the right direction for how to achieve the above.

This is a broad question and has little to do with bots themselves. Think of bot as only a communication protocol between your server and user. As you've mentioned, store user ids/meeting times in a database.
Then have a cron running, calling a link on your server which will check whether should a user be sent a notification now. Then send him a message and mark this action in a database, so it is not handled twice.

Related

Is there any way to send Fabric.io Purchase Event via PHP Server?

We made an mobile application and all purchases confirming after 10-45 minutes later via php server side logic.
Sample: if user clicks to buy button, getting request taken response message then server logic process some logic and confirming after this action.
So, we need to send log purchase event from php server to fabric.io server. Is there any way to do this? Or what is your opinions?
I made some searches about server to server communication and there isnt anything.
this is not how Answers works. you could in best case let the mobile client request the order status from the web-server and then report a successful purchase or a declined transaction to Answers from there... or even indicate to the mobile client, that the purchase is still being processed (without logging that as an event)... when a purchase takes that long, that's almost mandatory.
just see for yourself, Fabric for Web appears read-only.
there isnt any way to send it at this moment.

Track conversation chain from different server sessions to one number

I'm creating an app which will allow all users to initiate conversation with page owner using Chat-to-SMS service.
Problem is that I'm not sure how to track conversations since there would be one conversation chain from SMS Provider <-> page owner. When owner clicks reply, it needs to know which session user it needs to send the message to.
Basically, I need to do opposite what is being explained here: https://www.twilio.com/docs/quickstart/php/sms/tracking-conversations
How should I accomplish this? I can't quite wrap my head around this.
Twilio developer evangelist here.
If you are sending all the chat messages to just one SMS number then there is no easy way to tie replies back to the original message. (As a quick experiment, if you open an SMS conversation in your own phone and try to reply to any message that wasn't the latest one, you'll see it's not possible.)
There are workarounds though.
You could, when forwarding the message, generate an ID for it. Then get your page owner to include that ID when responding to that message, that way you can route the message back to the original sender and strip out the ID.
Alternatively, when replying you could always respond to the last message that came in. This relies on there not being much traffic, allowing the page owner to respond before the next message arrives. This is error prone though.
Another alternative is purchasing a new number for each new conversation. You could expire the number after a predetermined amount of time. This is made much easier with Twilio Proxy, which was announced recently and is currently in preview.
Let me know if that helps at all.

How to Automate SMS from PHP mysql at Particular point of Time

I have a website where people will book for Site visits.The Support Executive Confirms Site visit in the previous day. Once the Site visit is confirmed on the day on which site visit should happen the customer should receive SMS in morning telling that you have site visit today as requested.
I have Third party SMS Service
Now I Should Run a Code in PHP, MySQL which sends a SMS in the morning on which the site visit should happen
How can I Do that
Cron -> starts PHP-Script , PHP Script reads records from the SQL Table and checks if an SMS has to be sent, i assume its sms over mail, so you can use the integrated php function to send out mails to the sms gateway. For the guy confirming the visits, create another site with proper authentication where he can access the table and agree with the site-visits and anotherone for the customer to register for site visits
You need a cron job set to run in morning which will call your php file have code for looking in database for customers you need to send sms to.
Yo need to register to sum sms gateway provide 2 good one i know is clickatell and eztexting.
You can get there api for sending sms in there website.
Happy Smsing :D
Set a Cron Jobs in your Control panel.Try this link
http://www.devx.com/DevX/Article/39900/1954
If you would like to try an entirely different approach, check out:
Sent.ly - http://sent.ly
I am the founder of Sent.ly and thought maybe Sent.ly could help you out...
Sent.ly allows you to use an Android phone as an SMS gateway. So... you could just purchase a cheap Android phone ($150 or so) and set up Sent.ly on it and put a SIM in the phone.
By calling the Sent.ly API, the SMS would go out through the SIM in your Android phone. Sent.ly also has the option for scheduling an SMS for sending later which is your use case.
This also allows your PHP application to RECEIVE SMS in addition to just sending it out.
You can setup rules and if an incoming message matches a rule, it would be posted to a PHP page of your choice.
Since I am a great fan of stackoverflow, I would like to invite you to try Sent.ly. We would be happy to set you up with extra credits if you like. Just mail us at support#sent.ly
Cheers,
Varun
I have developed a system like this for use with some of my clients, and you can easily use it to integrate with your website or applications, through HTTP POST or WebServices (using PHP, C# or whatever).
If you are interested just leave an email or other contact information as a reply to this answer and I will gladly send you a sample code of how to send SMS, setting the desired time for sending messages, beyond other things, through our system.
You will not need to have any kind of cron knowledge and setup, it is all handled by our system, and the code is pretty simple and straight forward. You will only need to call our services upon site visit confirmation, setting the desired message sending time, and our system will do the rest.
Best regards.

How shall I setup user event notifications in my code?

I'm coding a team collaboration web app in PHP, and I have a few events that users get notified about through email and/or SMS. The current way I'm doing it is as follows:
Every user has his notification settings in the database as boolean variables.
Say users would be notified when someone comments on the team's page. When the function that posts a comment is called, the same function would contain extra code that checks "who wants to be notified about this?" and then sends notifications to them (which slows down the function a bit).
Is there a more efficient/faster/flexible way to setup notifications? maybe through a script that runs via a cron job? or shall I just keep doing it this way?
I appreciate your help.
I implemented a similar method to the one you're following on a website with a multi-table approach. The users table held the contact information along with opt-in, opt-out options while an event table held the instructions to notify. Several other events were hard coded because of their importance. The thing that set the site apart a bit was a "workflow" area on the user's dashboard that also showed the user what action items they had. We found that most users ignored the emails and dealt directly with that dashboard workflow area. You'd be surprised how many times people change emails or just ignore them altogether.
With 280,000 users and daily visits in the tens of thousands, there was no performance issue noticed. However, the process of queuing emails can be inefficient if you're not careful, so take particular time to benchmark your mail sending functions--its as easy as echoing out microtime before and after the mail send is accomplished--to evaluate its effectiveness. On my current company's site, such improvements yielded a 800% reduction of email queuing time (queuing being the process of generating the emails and submitting them via php mailer to the mail system for distribution)
I'd say have a table that is a queue of notifications. Let the function that post a comment still check "who wants to be notified about this?" but then just log entries containing the messages in this table. Then have a separate process work from the queue i.e. your cron job suggestion.
Depending on your database you may perhaps make use of database events or triggers instead of a cron job. This however have the requirement that your database allow you to put code in your database that will send the SMS or Email. This poses a security risk normally which you may or may not be concerned about in your setup.

How does Cell Minute Tracker work?

It's been a mystery how does Cell Minute Tracker manage to fetch AT&T users data.
Maybe someone here has the long waited answer.
I'm really curious rather they got a confirmation to scrape user’s cellular report
And how they can fire up multiple requests to AT&T site without being banned?
I'm waiting for someone who could shed some light on this mystery
Thanks
link: http://www.uquery.com/apps/311637771-cell-minute-tracker-for-att
From what I can tell the application is running locally on a iPhone, it is using the user created login account, so it is just like the user going to the site, thus no issues.
Internally it would be scraping the site to get the information to display to the user.
Now, given your question who knows if they got confirmation, but the second part of your question in regards to multiple requests is moot, since it is each device contacting, not their server.
It is impossible to know exactly how they're doing it, however my guess is they're requesting your balance and minute usage and just parsing the text message you receive back with that information.
// for at&t
*BAL# for balance on your account
*DATA# for data usage
The text message is free.
How do they do it for Rogers in Canada?
Does Rogers provide a text message with the current SMS and minutes balance?

Categories