Make call and play sound from external system

We upgraded our old freepbx platform to a newer version. Now I have a question about a use case we have. In the current situation our external system sends a message to the pbx server. On that server a .call file is created and stored in the outbound folder. Then asterisk picks up this message and makes a call. When the client picks up the phone a message is played. Now in the new world there are rest api’s etc and I was wondering is FreePBX providing a service so we can do this or do we need to do this trough the ARI from Asterisk or would you advice something else?

You could, but why mess with success. If you switch to AMI or RESTAPI, you’re going to end up going through exactly the same steps to make the call. If the Callfile system works for you, then I wouldn’t try to get fancy.

Perfect!! but how :open_mouth: I would prefer to use RESTAPI.

The procedure you are using to create the call file needs to be modified to interact with the RESTAPI instead of writing a callfile. I don’t have your code and I don’t have access to the RESTAPI on your server, so it’s going to be a “do the research, write the code” situation. The good news is that they aren’t mutually exclusive. Your callfile solution is working, so use that until you get done troubleshooting the REST code.

@cynjut thanks again for your reply.
So sorry for the confusion I don’t want you to build me anything I can code my self.
I have a fresh install of PBX so on this moment there is no custom code yet. I was wondering if there is a default RestAPI endpoint that I can use for this. I have seen that there is a ARI Asterisk Restfull interface would it be possible with that? The les we have to custom build on the PBX server the better.

The REST API is a work in progress. The Wiki has some information about it, but if you aren’t using Asterisk 15, you’ll need to stick with AMI or the Callfile interface.

What I thought to understand from the wiki is that it’s for configuring the FreePBX trough a rest service instead of by the interface. I did not see anything about making a call by the API. I’m running Asterisk on version 13.9.1 and FreePBX on 14.

The REST API is available, but it isn’t going to solve every problem, at least not in the short term.

So I’m lost now what should we do?

You answered your question in the original question. If this works in your corporate process, you should keep doing this. There may be some adjustments from the old FreePBX to the new FreePBX (some options may have changed) but if this worked for you in the past, I recommend you keep doing this.

Well adding a custom file to the outgoing folder works but is not really great in my opinion. I would like to use a default service for this. But if I understand you correctly there is no service from FreePBX or Asterisk that we could use to do this?

No - quite the opposite. There are at least six ways to do this, not counting the way that is working for you right now. The thing that isn’t available is a way to do this from the FreePBX GUI.

No matter how you do it (CallFile, AMI, ARI, REST, SangomaCRM, Originate() scripts, etc.) you are going to have to write it yourself. There is no single way to do this. All of them have their advantages and disadvantages. None of them is a “service”.

So if you must choose would you go for AMI or ARI to do this?

I’d probably go AMI, but I’m old-school. You’re not going to go wrong either way.

Look around for code APIs for whatever language you are using and see which of them you want to use. There are several language support packages for either interface. Some are a little easier to use than others, so look for one that makes it easy for you in the language you are using.

On the server I see in the html folder a restapi folder.
When I go to /restapi/rest.php/ in my browser I get:
“status”: “error”,
“msg”: “Route not found”

Is there some documentation on how to use this restapi and what it can do?

Oke so I moved back to the .call file to do the work. I got the PBX now set up to make the call for extension 123 and context from-internal-custom. Then I created a example.conf and put it in the /etc/asterisk/ folder. In the extensions_custom.conf I added:
include => example

But now I’m getting the error: sent to invalid extension but no invalid handler: context,exten,priority=from-internal-custom,123,1

If possible I would like to do this from the PBX GUI not by adding some code to Asterisk would that also be possible by for example creating a custom outbound route?

You need to read the examples.

Your code will include an example context called “example” that is added to one of the config files. Instead of doing this, make your change from example.conf directly in extensions_custom.conf. At the end of the code segment in your custom context, you will need to reconnect to the from-internal context. This is commonly done by going back to the from-internal context at the “s,1” step.

There is no extension 123 in the from-internal-custom context, which is consistent with the code segment you included. There’s no way to pull your example.conf file into the context, so you get the error.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.