How can I play the hold-music 1 time, then end conference? - twilio-twiml

I'm trying to find TwiML examples where user1 connects to the Conference w/ startOnEnter set to false, listens to hold recording, and if user2 has not connected by the end of the recording, the conference ends.
Any ideas?

Twilio developer evangelist here.
There's nothing built into Twilio that can handle that for you I'm afraid. So what I would recommend is that:
When your first user connects to the conference start a timer on your server for how long you want them to wait for. Also, with your <Conference> TwiML, register a statusCallback URL. When another participant joins the conference you will receive the webhook callback. At which point you can cancel the timer. If you receive no webhooks, then when the timer goes off you can use the REST API to end the call.

Related

Strategy for sending delayed pushes

I have application that should notify user based on some interval pattern like:
Event
> Pushes
Pattern: Immediately - 3 day - 7 day - 12 day
If user made action for event pushes should stops for this event. It is possible to have multiple same type events that should send push when event occurred.
Also I do not want to bother user for example when the one have 5 events to send x5 more pushes, but reduce by taking together pushes that should happens next day (or some other interval) by sending one push for example 'reminder: you have 5 events'.
So now I decide this kind of solution, when event occurred, insert into db all pushes for event that should be send later with datetime for send. If user take action, pushes marks as redundant for this event. And before sending analyze interval for example take all pushes for next 24hour, send one and mark all others as already sent.
Is it ok, or maybe exists better solutions?
I have experience building same application with you. What I'm I doing is :
CMS -> redis -> worker
CMS, are used for creating push notification content, including the time when that content should be sent
Redis, are used for storing the delayed jobs data
Worker, php application that pulling delayed jobs data from Redis. I use Laravel on here, I take advantage from Laravel queue delayed dispatching.
Previously I have try use database and message broker SQS as queue driver. Why I'm switch to redis ? First, when I using database, is too costly, due the traffic of my queue data is very huge. Then when I use SQS, it's better than database, but SQS cannot hold delayed data with weeks age. So my last choice is Redis. Of course we can use another serivce such as Rabbitmq.

Reading DTMF from called party after some time in call in asterisk

I am trying to make a system where user1 makes a call to user2 and after few minutes of conversation user1 asks user2 to press some key and user1 one should be able to read this DTMF sent by called party.
Read() command reads the DTMF from caller, hence is not an appropriate option.
D([called][:callin]) option in Dial() command can do this but it is used in Dial command and hence can only send/receive DTMF at the time of call is answered, Not after few minutes into the call, hence not again appropriate option.
Please help me by suggesting something which can be used to achieve above scenario. Let me know if more info is required.
You can check features.conf, that can suite your need
http://www.voip-info.org/wiki/view/Asterisk+config+features.conf
Also you can write c/c++ app to collect data
There are no other way collect dtmf in bridged call.

Twilio and queues

Is there a way with Twilio to:
have a customer call in and be placed in a hold queue
Twilio would then dial our CSR's telephone numbers sequentially (or all at once)
Connect whichever CSR answered to the customer
I can get the system to answer the phone, place the caller into a queue, but then dialing the CSR and then connecting the CSR to the caller is where I am stuck.
I can get the system to answer, play a message, and then dial a sequence of CSR numbers, but that is it.
BTW: I am using classic ASP, not that it really matters.
Twilio evangelist here.
To make Twilio dial out to your CSR's you're going to need to use the REST API, specifically POSTing to the Calls endpoint. Check out the docs for making calls.
In order to know if the CSR did not answer and you need to call another, you can use the StatusCallback parameter. This lets you specify a URL that Twilio will request when the call ends, letting you know why it ended. If the CSR does not answer then you can find that out in the StatusCallback request by checking the Status parameter and start a call to another CSR.
You could also start a bunch of outbound calls to a bunch of CSR's at the same time. If you do this you would need to track all of the calls (I'd just store each calls CallSid somewhere) and then when the call starts use the <Gather> verb to have the CSR indicate they want to accept the customers call. You would then just hangup on all of the other in-progress outbound calls and <Dial> that CSR into the Queue which would connect them to the customer.
Hope that helps.

Asterisk 3 way calling with IVR

I'm using asterisk 1.4
when my agent talks with customer , we need a option of putting their call in a IVR
in which agent and customer can listen those ivr menu at a same time , eventually customer should send some DTMF for IVR menus
Could any one pls tell me in what way we can achieve this
Consider dropping both calling and called parties (customer & agent, respective to how you're operating) into a conference call, and then!
...Go and originate another call (with AMI or a call file) that's operating from a new context/extension/proirity and also drop this originated call into the conference.
I haven't tested this with DTMF input into a call prompt -- But, I have played automated messages to both calling and called party in a conference using this technique.
The caveat may be that both calling and called parties will have control of the prompt. Which may or not be relevant to your use case.

ASP.NET MVC + SQL Server Application: Best Way to Send Out Event-Driven E-mail Notifications

I have an ASP.NET MVC application that utilizes NHiberante and SQL Server 2008 on the backend. There are requirements for sending out both event-driven notifications on a daily/weekly basis AND general notifications on a weekly basis.
Here is an example of how the event-driven workflow needs to work:
Employee(s) create a number of purchase orders.
An e-mail notification is sent daily to any supervisor with a subordinate employee that has made a purchase order with a list of all purchase orders created by subordinates that require his approval. The supervisor should only get this once (e.g. if Employee A creates a PO, his supervisor should not get an e-mail EVERY DAY until he approves). Also, the list of purchase orders should ONLY include those which the supervisor has NOT taken action against. If no purchase orders need approval by a given supervisor ... they should not get an e-mail.
An e-mail notification is sent daily to Dept. Managers with a list of all purchase orders APPROVED by subordinate supervisors in a similar fashion to #2 above.
Any time any action is taken with regards to approving a PO by a supervisor or dept. manager, the employee should get an e-mail notification daily listing ALL such changes. If there are none for a given employee, they should not get an e-mail at all.
So given such a workflow:
What is the best way to schedule such notifications to happen daily, weekly or even immediately after an event occurs?
How would you ensure that such event-driven notifications ONLY get delivered once?
How would you handle exceptions to ensure that failed attempts to send e-mail are logged and so that an attempt could be made to send the following day?
Thanks!
I would have all your emails, notifications, etc saved to a DB / table first and then have a service that polls for new entries in this database or table that handles the actual sending of the email / notification.
To address your specific situations you could have controllers write to the DB when a email / notification is required and a service that does you interval / event specific checks also write to the DB to create new email. This way your application and service don't really care about how or what is happening to these notifications, they are just saying, "Hey do something." and the emailer/notification service is actually doing the implementation.
The advantage to this is that if your email provider is down you don't lose any emails and you have a history of all emails sent with their details of when, who, etc... You can also rip out or change the emailer to do more, like send to Twitter or a phone text message etc. This effectively decouples your notifications from your application.
All applications I have made recently use this type of model and it has stopped emails from being lost due to service failures and other reasons. It has also made it possible to lookup all emails that have gone through the system and get metrics that allows me to optimize the need to send emails by storing extra information in the email record like reason sent, if it's to report an error, etc... Adding on additions such as routing notifications (eg go to text message instead if email) based on time of day or user has been possible with no changes to the primary applicaton.
Your customer might think all they need is email today but you should make sure your solution is flexible enough to allow for more than just email in the future with just minor tweeks.
You can add a normal action in a controller
Function SendEmails() As ActionResult
Dim result As String = ""
''//big timeout to handle the load
HttpContext.Server.ScriptTimeout = 60 * 10 ''//ten minutes
result = DoTheActualWork()
''//returns text/plain
Return Content(result)
End Function
And then call the page from a scheduled task. Can be a scheduled task on the server or in any machine. Use a .vbs for this:
SendEmails.vbs:
''//Force the script to finish on an error.
On Error Resume Next
''//Declare variables
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
''//Put together the URL link appending the Variables.
URL = "http://www.mysite.com/system/sendemails"
''//Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false
''//Send the HTML Request
objRequest.Send
''//Set the object to nothing
Set objRequest = Nothing
You can host a windows workflow or windows service. and setup a message queue to process these events. You might just use the database for your message queue or you could use ms message queue or use triggers in the database. But this kind of functionality really shouldn't be a responsibility of your front end web app. If push comes to shove you could spawn off another thread in you asp.net application to process this queue.
This can be done using SQL Server Agent read more about it here:
http://msdn.microsoft.com/en-us/library/ms189237.aspx
Sounds like a job for a service or a scheduled job.
You don't want to do it in ASP.NET because you'd have to configure IIS to keep your app alive all the time, which may not be the best idea.
A scheduled task is fine, but you'll have to program it with all the logic for parsing out your data. Not the best for a separation of concerns. Also you'll have to update two code bases if something changes.
A service isn't ideal as it would only truly be doing something once a day. But you could set up a wcf service and have the website queue up emails using the service.

Resources