Twilio Integration With Laravel - php

I am facing a problem in my project for several days. I want To integrate Twilio for voice conversation in my laravel App. I want That When a User Want to call the twilio account he need a token that is generated from my site.
For Example :
User A Appoints User B for meeting conversation.
User A gets a token after accepting his meeting By User B.
User B also gets a token. User A then call to the Twilio number.
When he call he needs to submit his token.
After submitting User B notified and needs to submit his token to initiate the phone meeting.
This is all I need to do. But dont know how to fix this. Can you guys please give me some advice of how can I achieve this. Sorry For my Bad English

So, if all your wanting is the logic, here is how I recommend this be implemented.
Meeting creator (John) invites a member of his team (Bob) to his newly created meeting.
The application creates a meeting password for John, saving it in the database. It wouldn't yet create one for Bob because he hasn't accepted the invitation. You can separate "hosts" and "invitees" if you'd like to give them a different experience.
Bob receives a notification (text message, email, etc..)
Bob approves the request, and is then generated a meeting password (which is saved to the database).
The meeting time is near, so Bob & John dial in to the Twilio phone number that you have provided them. Upon picking up (set your incoming call webhook to the logic in your Laravel application) the Laravel application uses TwiML to ask the user to enter their meeting number, and meeting password (or just password, up to you). At this point, the user enters a valid password.
The two calls are connected together using the Twilio API. You don't really need one to wait for the other. Throw them in a conference and let Twilio handle that logic using the Conference and Conference Participants REST API.
Let me know if I am missing something else you need in here.

Related

Invitation system (push) for web app

I am creating an web app and a user can start a game with multiple players (your friends). This game is played on 1 device. Is it possible that all invited players get a notification on their device where they can accept or decline the invitation ?
So in steps
Player 1 creates a game and invites player 2 and 3
Player 2 receives a notification on his mobile device and presses accept, he is added as player of that game
Player 3 doesn't have a device and enters his PIN to accept his participation.
The step that I want to have is step2.
I have read about OneSignal who can send push notifications to specific users, but I could not find if you can send a response back (accept or decline). Or is there an other way (without to have a native app).
your question is understood but at this moment a little too broad. But. I will try to answer in concept also :)
Now...you said you already know how to send target specific notification with OneSignal.
What you need to do from now one it cloud be like this:
Attach a link or click or action to that invite. Or when such invite
arrived open a particular view in the app/web/application that you are developing and revives the link.
Attach the session/game/user/object ID to that link and send the call
to you API (which is based on your server). If you have an API, if you don't you can have a very simple API build to handle only such requests with URL xxxx.com/path/to/api/call/var1/var2/var3/etc
From there you can catch the request and reply or adapt accordingly on your server side.
Maybe this Framework can help you to speed up the API dev in PHP. Lumen can do that trick.
You can follow this tutorial here for a fast API development with it.

Database structure for Web Messaging system (for both registered users and guests)

I'm trying to create a very simple messaging system using PHP and MySQL but I'm having some issues to decide how to structure things here.
A quick list of what I need to achieve.
The system needs to allow both registered users and guests send messages.
The messages will be received by the customer service department (this means that customers can't send messages to other customers).
The messages can come from 1) a contact form available in the Contact page of the website where are asked fist name, last name, email, mobile phone, subject and message; and 2) emails sent by users (then the system will receive the emails via webhook and store them properly).
The customer service department needs to able to reply to any message.
The customer service department can contact any user (registered or not) at any time. This means that they can reply to messages but also can "start" the conversation (example: A message asking to confirm/update details).
I started the design but I'm completely stuck at the moment. Everything is fine when there are only registered users and customer service members: I just need to relate each message to a user_id as sender or receiver. But, when we add guest users, the user_id is useless, because they are not registered (so no user id). This means I will need to store all first name, last name, email and mobile phone for them (creating redundant data in the case of registered users, because I already have that data for them)
The tables will contain a column created_at.
My problem is: guest users won't have a record in the users table, so I cannot just have a user_id field on the messages tables. Also, I need to tell who is sending the message (because our customer service department can send messages to registered/guest users).
Honestly I cannot find a way to achieve this without having columns that will be equal to null in most of the cases.
Any help on this will be appreciated.
Thanks in advance
You will need to have a record added for the guest, as a user account in the database. Set default values, and log his IP address so should he decide to sign up, you will update the guest record with the new user account.
Add an expiry and a cron job to delete any guest accounts which are inactive for x days.
You have encountered an example where the relational model doesn't neatly fit. It's a known issue, with several Stack Overflow posts.
The good news is - there's no "clean" solution in database design. There are a few common models, but they all have varying degrees of unpleasantness.
The bad news - you'll have to make the trade-offs, and live with the consequences.

Twilio sms reply feature

I've created a system based on cron job which generates new tasks for user. When new task is generated cron file sends a sms to user using twilio sms api. Now I want make something like when user reply to that sms with word "Done" that task associated with sms will be completed in my database.
I've set reply URL in twilio account. And everything is working fine. My point is how can I complete that task in database. Is there any feature exist in twilio that can help me to send extra parameter as task id, so that I can fetch that id from reply and update the status of task.
Twilio developer evangelist here.
There's no way in SMS to reply to a specific message (try it yourself in your SMS app on your phone), so there's no ID that you can pass around secretly within conversations.
There are a few ways you can work around this.
If the user is sent only one task at a time, then you can record what their current task is and when you receive the message saying "done" tick that one off and send them the next task.
You could send them a task ID within the message, and tell them to include that ID when they respond to say they are done. You could then parse the ID out of the message and mark it as done in your database.
Or, and this might be too far, you could use a pool of numbers to send tasks out such that each live task for a user has a unique number the user responds to. Then you can look up the task based on the user and the number they replied to. Then you can free up the number for a new task.
Let me know if this helps at all.

App request/Invite through Facebook API using PHP

I'm building an app and the client wants the following logic:
User logs in to the app.
User selects a Friend.
User selects a gift that the User will send to his Friend.
User writes a message to his Friend.
Friend receives a SECRET notification about the gift.
With "SECRET" I mean that Friend will not be able to see WHO is the User that sent the gift.
So the concrete question is how to send a notification to the FRIEND without a clue about the USER that sent it? I think is not possible but I want to be sure and check with the experts.
And if it's not possible, what do you recommend to accomplish something like this? Should I use the app request dialog and hope that the Friend will see it? Is there any other FB API tool I can use?
I really appreciate your help.
What you're trying to achieve is not possible with FB's API. As explained already by #CBroe.
You can send a request notification if the user uses your app. However, You can do one thing but that won't be completely anonymous.
You can send the friend a notification from the user and make it just an invite to try the application and after the friend uses your app (authenticates), your app can then send a notification and say someone left a SECRET message for them. This could be after few hours or instant, Whatever you/your client prefers. However as i said, this won't be completely anonymous nor it's hard to guess who left the message unless the friend isn't smart enough to know who that could be.
With the beta Notification API something similar would be possible, but only if the receiver has authenticated your app: https://developers.facebook.com/docs/games/notifications/#impl

How can I login as another user with Salesforce API?

I created an script to get some information users send via SMS then create a Contact in Salesforce using that information with the Salesforce API and works fine, but I hard-coded the user and password so every time a user creates a Contact from SMS i´ll be the creator. How can I access user´s credentials for creating the Contact? I want to do something like: select Id from User WHERE Phone = $_GET['mobile'] and then make createdById equal to user's id. Is that possible without having an array or file with user´s passwords?
Thanks in advance.
Answered on success community by David "wOOt!" Liu
You can edit the CreatedById field to anyone you want using Apex - no credentials needed!
Salesforce needs to turn on this permission for your org first - I believe it's called "Create Audit Fields". This lets you modify fields such as CreatedDate, CreatedById, etc etc. Many orgs use this so it's actually a fairly common request - I just wrote code recently that changed a record's creator as well.
Some more definitions on Audit Fields can be found here:
http://www.salesforce.com/us/developer/docs/api/Content/system_fields.htm

Categories