Why A2billing doesn't charge customer-to-customer calls? - asterisk

I have installed A2Billing+Asterisk13.18-cert3. Outgoing calls are configured and billed correctly.
Once a customer calls another, two CDR records stored, Calltype:DID_Voip and CallType:DID-ALEG, but none of them are charged and the charges are zero.
I googled to find out any workaround to fix the issue. All results were incomplete and outdated.
I created a LOCAL provider, then a TRUNK with Tech=local, Provider IP:a2billing. DIDa are also configured and I can receive calls.
When using simulator, it can find the correct Call Plan and rates. but it doesn't apply to the call.
I have two questions:
(1) How can I setup asterisk to pass the call through a local trunk so A2Billing can apply charges to calls?
(2) What should I do to make A2Billing charge the customer-to-customer calls?
Thanks

A2Billing designed to charge prefix.
So if you want it charge customer call, you have create prefix and charge it.
You need call go via Local provider, not just create it.

Related

How to implement outbox pattern in Cosmos DB

I'm looking to implement support for the outbox pattern in Cosmos DB.
However, Cosmos DB doesn't seem to support transactions across collections.
Then how do I do it?
I've been considering a few approaches to implement this:
Use Service bus transactions
Within a Service bus transaction scope, send the message (not committed just yet), do the Cosmos DB update and, if it works, then we commit the service bus transaction to have the message made available to subscribers.
Use triggers to insert rows in the outbox collection
As inserts/updates happen, we use Cosmos DB triggers to insert the respective messages into the outbox table and from then on, it's business as usual.
Use triggers to execute azure functions
Create Azure functions as Cosmos DB triggers. I almost like this but it would be so much better to get a message straight to service bus.
Use a data pump
Add two fields UpdateTimestamp and OutboxMessageTimestamp. When a recorded is updated so does the UpdateTimestamp.
Some process looks for records in which these two don't match and for each of those creates a notification message and relays it to the respective queues or topics.
Of course, then it updates the second timestamp so they match.
Other ideas on how to do this?
in general, you store things in your cosmos db collection. then you have change feed sending these changes to some observer (lets say azure function). then your azure function can do whatever: put it in queue for other consumers, save into another collection projected differently, etc... within your azure function you should implement your dead letter queue for failures that are not related to function runtime (for example, writing to another collection failed due to id conflict)
[UPDATE]
Let me add a bit more as a response to your comment.
From my experience, doing things atomically in distributed systems boils down to:
Always do things in same order
Make second step itempotent (ensuring you can repeat it any number of times getting same result)
Once first step succeeded - repeat second step until successful
So, in case you want to send email upon something saved into cosmos db, you could:
Save record in cosmos db
Have azure function listen to change feed
Once you receive inserted document > send email (more robust solution would actually put it in queue from which some dedicated consumer sends emails)
Alternative would be to have initial command (to save record) put in queue and then have 2 consumers (one for saving and one for sending emails) but then you have a problem of ordering (if thats important for you).

Is it possible to track a call backwards beyond the last PBX?

We receive international calls into an Asterisk server (13.20) where some of the calls are automated, meaning there is no person involved, sort of M2M.
It is important for us to know where those automated call are coming from. Since it is easy to generate a call with faked ID we want to strengthen the authentication by identifying the original network from where the call was made.
When looking at the Asterisk logs I can see that a call came from Twilio for example, but that's it, no more tracking information.
My question:
Is it possible to track a call backwards beyond the last PBX who transferred the call to my server?
Some operators send some tracking in sip headers
For see more info, check sip debug.
asterisk -r
sip set debug on
However most of operators not provide for clients info about path of calls, some even not store it for internal use.

Missed Call in Lync/Skype database?

In our company, we use Lync/Skype for Business. In the database, is there a way to know whether a call is missed?
For example, a customer called the support number, but for certain reason, the call is not pickup, is there a way to find this call info by query Lync/Sfb database?
Or, Lync/SfB will not log info in this case?
Thanks
It depends on the "Call" did you refer here to a PSTN call? If thats a simple VOIP call then a so called peer2peer call might happen here which didnĀ“t involved the Skype for Business (=SfB) / Lync server as this is done between both SfB clients without the server.
I think a good step might be to check whats currently possible with the build in Monitoring Reports in Skype for Business Server (see here as starting point).

Why is dynamic real time not recommended as per asterisk?

In extconfig.conf they have mentioned that
"However, note that using dynamic realtime extensions is not recommended anymore as a best practice; instead, you should consider writing a static dialplan with proper data abstraction via a tool like func_odbc."
1) Why asterisk is not recommending dynamic realtime extensions?
2) How to do static dialplan with data abstraction using tool liek func_odbc?
My requirement is having have more extensions (in this case mobile number) coming up, how can I dynamically add them to sip.conf and get it registered to the SIP server
There are some issues with dynamic realtime
Most important issue is dialplan.
When/if you use EXACT dialplan like full number match - it work ok. But when you use pattern, it search for pattern in context. To do that it request all records in this context from db EVERY time when you access dialplan. That is really bad, but no easy way fix it. For example you have dialplan of 10 lines for pattern _011. and enother patterns/numbers in same dialplan, overal number of lines 1000. You call 011123456788, it request priority 1 line(db do 1000 rows check), after that priority 2(db do 1000 rows check). So you got 10x1000=10000 db rows for EVERY new call.
If you want dynamic dialplan with hi-load, use db config storage (for dialplan change,reload it for example once every 10 minutes) and check in extension/dialplan for features using func_odbc. That way you have much more control over sql query. Sure that require you understand mysql and able build queries, but no other way for any dynamic pbx with more then 10-20 calls.
sippeers realtime is other thing. It have issues with db update with enabled peer update, or not update peer info if cache enabled. You just have live with that.

Asterisk Web API to calculate Wait Times

I would like to know if there is a web api for asterisk. I would also like to know if the average wait time to talk to a customer service agent is exposed through the api.
I have looked around online, but could not get an firm answer.
Any pointers are appreciated.
AFAIK, no, there is no such thing in Asterisk.
What does exist is the ability of parsing the queue_log file. You can get the moment the call started, the moment the call was answered by an agent, and subtract them - this will give you the wait time. Also, the first extra data value of the CONNECT event contains the time waited.
(If you are not in the mood for parsing a text file, you can register the queue logs in the database and use SQL to generate reports based on the logs. This is in fact my preferred approach.)
If you want to provide this information to other apps, you can write your own application which reads queue_log file/table and provides a webservice which returns wait times. In the case you decide to do it, we can try some more robust answers.

Resources