Adding routes to asterisk through the REST ARI - rest

I have an asterisk/freepbx server set up and working well.
I now need my external application to be able to add routes to the asterisk server, (it takes in a load of new phone numbers and is responsible for adding them to the asterisk server). Is this possible to do through the REST API?
The calls need to be set up to an IVR, an mp3 playback or a conference...which is decided by the external application (the user isn't able to login to freepbx)

No. You currently cannot manipulate the dialplan through ARI.
While there is an asterisk resource that provides some limited information about the running Asterisk process, the primary purpose of ARI is to let your write your own dialplan applications by handing control of the resources in Asterisk over to a third party application. It is not meant to replace AMI or AGI.
More information on the REST API in Asterisk can be found on the Asterisk wiki here: Asterisk REST Interface (ARI).

Related

IFTTT Applet Creation with maker

Can IFTTT applets be configured to perform multiple actions. for example can it be configured to have multiple presets. If i have Alexa linked and the IFTTT applet set to send stings to a server is there a way to say "Alexa trigger preset{presetnumber}"? or do i have to make multiple applets?
Unfortunately, the short answer (as far as I know) is no. It is possible to create an applet where you can say "alexa, trigger preset abc" and then, using the Maker applet, have that send a web request to a server/REST API, which you could have configured to connect to multiple different services through your own code.

OAuth redirect URI alternatives for non-web applications?

What would be the best way to handle redirect URIs for OAuth authentication?
In a few projects, I used to boot up a web server that would wait for the authentication to be sent back. Is there any way to trigger any type of code without a local web server, or is it the recommended way?
I'm not asking for help about any specific languages, this is more like a language agnostic question.
Side note: nice avatar... :)
Deciding on the best approach will depend on the exact scenario and any additional requirements your application might have, however, we can look at a few options and possible implication of choosing them.
The OAuth 2.0 specification suggests a few options to solve this issue, either using an embedded user-agent or relying on an external one.
The embedded user-agent may allow you better control on the UI aspects, however, by leveraging an external user-agent your users might benefit from an already established session and avoid having to input credentials one more time.
For an external user-agent we have a few options:
External user-agent - the native application can capture the response from the authorization server using a (1) redirection URI with a scheme registered with the operating system to invoke the client as the handler, (2) manual copy-and-paste of the credentials, (3) running a local web server, (4) installing a user-agent extension, or by (5) providing a redirection URI identifying a server-hosted resource under the client's control, which in turn makes the response available to the native application.
Option 1:
You configure a redirect using a custom scheme that your application registered in the operationg system, this way your application gets called when an external user-agent receives a response indicating a redirect to your scheme.
Option 2:
You redirect somewhere that just shows a pretty page with the code and ask the user to input it manually in your application.
Option 3:
You already used this one, basically the application starts a local web server and you configure the redirect to be something along the lines of http://localhost:[port]/.
Option 4:
By installing a user-agent extension you would have code running with the browser that could communicate the code automatically to your applications.
Option 5:
You configure a redirection URI that points to some server-side code you host and that your client Android application is aware of so that it can grab the code from that URL.
For much more information on this topic, check: OAuth 2.0 for Native Apps
As an additional not, if you don't want to go full server-side on the options that require some logic on the server, you can accomplish the same using much less lines of code by writing your server-side logic as a Webtask (be sure to use a custom domain).
Disclosure: I'm an Auth0 engineer.

How to implement integration using REGISTER SIP?

I have a question about integrating with a phone company (the Provider) using SIP.
I have a situation:
1. A call is made to a PSTN number
2. The Provider forwards the call to a SIP Gateway
3. Twilio is the SIP Gateway, so I receive an HTTP request for every new call
4. I execute my application logic
As I understand the SIP integration between the Provider and Twilio is done using SIP INVITE.
Now a have the challenge is to implement the integration using SIP REGISTER.
As I imagine, the scenario should look like this:
1. I register against the Provider using SIP REGISTER
2. A call is made to a PSTN number
3. The Provider gives me the call
4. I execute my application logic
I need to figure out what is needed in order to accomplish this:
Firstly, does this scenario make sense?
Do I need to use a PBX solution (like Asterisk, FreeSwitch) to implement SIP REGISTER and build my application on top of it?
If so, which PBX solution do you recommend and which features/modules are needed? And do I have to host it on my server?
Perhaps I don't need a PBX solution, and a library is enough as described here?
It is the Provider pushing for this way of integration and I have too little knowledge about it.
What I have figured out is that Twilio can't help me with this. So it looks like I have to take a part of solution in-house.
REGISTER is required if your terminal or terminals belong to the domain of a VoIP provider.
REGISTER records the mapping between the identity the VoIP provider gave you and the actual address and port where you will be listening for requests.
This way, calls addressed to you (sip:myuserid#voip.domain.com) will be sent by the VoIP provider to the address of record it has for you.
If you are a VoIP provider yourself (i.e. you have a sip:myuserid#myowndomain.com), then your peer voip providers will route requests to you based on DNS records or internal domain-based routing decisions. Once the call reaches you, then you can decide on how to handle it. If you are a real SIP provider, then you will have a registrar where you store the result of the REGISTER of your different users.
If you want to implement some application logic on your end, you have different options:
Easiest way is to implement a UAC/UAS, basically a terminal. Your application is the terminal, it registers with the VoIP provider and receives all your calls. You will just need the SIP stack, and you can do whatever you want with the call.
Using a PBX software. Basically it will handle normal calls for you, and the REGISTER when needed. Typically they will have APIs to perform some degree of automation/modification of the call handling.
Difference between the approaches, in the first case, you just have the protocol, so you must do everything else. In the second case, the objective is to process normal calls and they will offer you some window (smaller or greater) to see into those calls and do things with it.

Easiest way to make automated SIP phone calls from a web app?

I have a client company with a simple web application (Python Flask) and I need to add a phone notification functionality to it.
The main requirement is that the app should call users, play a certain sound file and accept some tone input ("Hello! This is an automated message from your WebApp account. You have a meeting with $John today at $5pm. Please press 1 to confirm").
The other requirement is that the solution should be relatively cheap and fast to market.
I have done some research already and it seems that there are a few consequent steps to achieve that:
Set up an Asterisk or a FreeSwitch server;
Set up a SIP account;
Write some business logic for the Asterisk server which allows to make calls and play sounds via a SIP account;
Write an API at the Asterisk server and expose it to the Python Flask web app.
Do I miss something here? Can any of the steps be omitted anyhow? Can I do it simpler?
the fastest way to get it working is to use one of the cloud voice services with speech synthesiser. Here's a short list to check out:
Twilio
Tropo
Plivo
Here I listed some details.
Those services charge you per minute, plus you may have to pay some monthly fee.
If you want to run an independent and standalone service, I would recommend FreeSWITCH instead of Asterisk. It's got reach integration possibilities and API. You will need to read the FreeSWITCH book in order to understand how it works and how to build your service.
I agree with Stanislav Sinyagin on the cloud based solutions, but I would add one more, Voxeo Prophecy. Tropo is from Voxeo, but they have offered Prophecy as a solution for a lot longer and it supports the open standards CCXML and VoiceXML. The advantage of CCXML for outbound notification applications is you have a lot more control of the notification process.
The Prophecy platform has excellent call progress analysis (CPA) which will allow you to determine whether a machine or a human answered and handle the call accordingly. For example, it does not make sense to ask a machine to "...press one to confirm". Instead you may want to leave a message that provides a call back number for the user to confirm with after they have listened to the voice message. The CPA can be used to leave a message on a machine at the correct time (when the greeting message has stopped) so that you do not get clipped messages in the voice mail. CPA will also allow you to provide detailed reports on who was notified and for those that did not it can tell you whether it was a bad number (received a SIT tone), a modem or fax answered, or ring-no-answer (pretty rare these days). These type of details can factor into your retry process for failed notifications.
The other advantage to using Prophecy and open standards is your application will be portable to other IVR systems that are VoiceXML/CCXML compatible if you ever want to migrate. Tropo, Twilio, and Plivo all use proprietary API's which does not allow you to move your applications to other services. Prophecy is also available as a software solution so that if you want to take it out of the cloud you can run it on premise. You can get a two port version for free to try it out.
There is excellent documentation on developing outbound notification systems on Voxeo's developer site. Take a look at the CCXML documentation in section F on Outbound Dialing.
Not sure which development languages you are familiar with, but if you are used to ASP.NET MVC there is an open source project called VoiceModel that makes it easier to develop VoiceXML applications. The other advantage of VoiceModel is that you develop your application once and it will run on any VoiceXML compatible platform and Tropo. They are currently working on adding outbound notification support in this project that will work for both Tropo and VoiceXML.
Third party solutions listed are your easy choice. Running your own asterisk is also suitable for what you want to do, but i think for only this much it would be overkill, from an operational perspective.
In asterisk, you can originate a call that has the 2 variables you need with an (basic-authenticated) HTTP request. You will also need some settings and a tiny dialplan. Setting up the SIP account is easier or more difficult, depending on the documentation from the provider. Most of them have detailed documentation for configuring asterisk (not so much so for freeswitch). Keeping the damn thing alive is what's gonna get to you :)

Peer 2 Peer call using PJSIP and PJSUA

I am still learning about SIP and all its protocols, specifically trying to integrate PJSIP into an iPhone application to make p2p calls.
I have a question about a peer 2 peer connection using PJSUA. I am able to
make calls perfectly to other clients on my local network by calling directly using the URI:
sip:192...*:5060
I am curious if this will work for
making direct calls to other SIP URIs that are not on the local
network without using server configuration - if not this way, is there another way of making p2p calls without server configuration?
thanks in advance,
You can make calls without server configuration, as a general principle, but something needs configuring. As mattjgalloway points out in the comments below your question, the most robust solution is a can of worms involving ICE which provides a kind of "umbrella" protocol for things like STUN.
Last time I touched this issue, I had the requirement that I couldn't use internet-based SIP servers to help. I came up with the idea of a registry of sorts: your client can define a bunch of "address spaces" with particular routing requirements. For SIP URIs in your LAN, you define no routing; for URIs in your company's VPN-accessed network, you define a route passing through your VPN connection; for everything else you define a route through your internet router.
By "define a route", I mean that when you place a call to a URI in some particular address space, you store what IP will go into a Contact header, what Route headers you might need, and so on.
Thus, the process of making a call becomes:
Look up in the set of address spaces for a match.
Ask that address space for the suitable bits needed to make a workable INVITE (appropriate Contact header details, Route headers, etc.)
Construct a normal INVITE, mutating as necessary for the previous step.
Send the INVITE as normal.
This essentially reproduces half of what ICE would give you, in a manually administrated form. "Half", because this ensures that one SIP agent can make calls such that the SIP routing all works. The missing half is you still need some kind of registrar somewhere, and each agent in your contact list needs to have the necessary setup to receive incoming calls. (If an agent's behind a NATting internet router, the router would need to either run a SIP proxy, or forward ports 5060, 5061 to a particular machine (which might be an agent, or a proxy serving the LAN's agents).
It is, indeed, a large can of worms.
The basic issue is to solve the problem of getting transport ports anywhere on the internet for multimedia traffic.
Many companies/experts have tried to solve this situation. A possible way out of is to buy a domain and setup a basic registrar using YATE or Asterisk on an address accessible from the internet and configure it to also use ICE as needed. Your iphone application at both ends could register automatically to it upon start. Then make P2P calls.