How to determine current PBX status (calls, ringing, etc. etc.) with asterisk-dotnet - asterisk

I am using asterisk-dotnet, and I am looking for a way to get the current PBX "status".
What I need is to determine:
which extensions are busy in a call
which extensions are ringing
which number is calling the extension
which number is called by the extension
and the extension number itself.
I know that I can obtain part of these data by using the Status Action, the ExtensionState Action and the NewChannel Action. However these work when an event happens. For example, if an extension is busy on a call, I'll have a new ExtensionState only when the call ends (when the channels are dropped and the peer is available again).
Any help will be much appreciated.
Thanks in advance,
Gianluca

I've just checked Asterisk changelog. It appears that a CoreShowChannel action has been introduced in Asterisk 1.6. I still have to do my homeworks, but I guess that's all I need to get info about what's going on the server at my app startup time.
After this initialization, event tracking is easier as there are already many events that one can subscribe to in order to be notified about new calls, hangs up, etc.
Hope this can help someone else.
Cheers,
Gianluca.

Related

variables in extensions_custom.conf

I am using Queues to handle incoming calls which works pretty well.
What I would like to do now is to get the info which extensions has answered a call in "sub-queue-answer" context of extensions_custom.conf to hand over this information via CURL to another - e.g. CRM-server via:
exten => s,n,Set(foo=${CURL(https://hostname/voipcr.php?device=pbx1.xxx\&agent=${???}...)})
anyone any idea which variable can be set in the spaceholder of the three ??? to hand over the extension number of the agent who has answered that call?
i usually use ${CUT(DIALEDPEERNUMBER,#,1)}
You can not do that using extensions. Queues are sending calls to users without passing through the dialplan (a queue will call a agent directly).
To access data about who answered the call (and also when that happened) you need to listen for the AgentConnect event on Asterisk Manager Interface. As you can see in the documentation, the AgentConnect event will pass a lot of properties that you can parse, to extract the information you need. Probably you want to check MemberName and Interface properties, but that is subject to your particular setup.
Queue logs / CDR will help you only if you want to send the data after the call has been completed, but, to do that, you probably need to create a pooling system (an undesirable solution, from my point of view).

How to execute code before making a call on Asterisk

I have an asterisk pbx server. I’m new to asterisk, I know there are dial plans extensions groups etc.
My goal is to handle a dial event do some checks then decide whether to let the call go through or not.
I read about ARI AGI AMI and dial plan but I got confused and don’t know how to proceed.
I just want to execute code (call an API for example) when any number is dialed, and drop the call or let it through according to that.
I know if I do more research I can get something working, but honestly I don’t have time. I just need to know where to look.
So I solved it. In case anyone needs this, here's what I did.
I used AsterNET fastAGI and created my service script, which does whatever checks I need and calls HangUp() when needed, else just returns and lets the call go through.
Then I called the fastAGI script in the dial plan and it's working perfectly.

Not receiving AppMessage callbacks when sending message inside a bluetooth connection event

Title sums it up. Same question is here. Posting on SO to see if I can get any help. I also made an almost minimal project to demonstrate the problem I'm facing, so links that follow point to the piece of code being mentioned.
Nothing fancy on what I'm currently doing:
My watchface is notified that the bluetooth connection with the phone is up, using .pebble_app_connection_handler.
In that bluetooth callback I set up, I send a message to the phone using app_message_outbox_send(). When BT connection is up, of course.
My Android app has a BroadcastReceiver that listens to these messages and calls an IntentService.
This IntentService calculates the data, pushes it to the watch and sets itself to run again after some time.
What I expect:
When the BT connection is up, the connection handler to be called.
app_message_outbox_send() return a value telling if the message initiation had any errors. Normally, this is APP_MSG_OK, but it can be APP_MSG_BUSY, and I'm perfectly aware of that.
The app message callbacks (app_message_register_inbox_received and friends) be called to indicate if the asynchronous process of sending message to phone really worked. This is stated in the docs.
What I'm seeing:
The expected steps happen when the watchface is loaded, because I trigger the update manually. However, when the update is triggered by a BT connection event, expected steps 1 and 2 happen, but not the step 3.
This is particularly aggravating when I get APP_MSG_OK in step 2, because I should reasonably expect that everything on the watch went OK, and I should prepare myself to receive something inside the app message callbacks. Basically, I'm told by the docs to wait for a call that never arrives.
This happens 100% of the time.
Thank you for any help. I have another solution that works, using the watch to keep track of the update interval, but I believe this one allows me to save more battery by making use of recent Android features.
From documentation :
To also be notified of connection events relating to any PebbleKit
companion apps associated with this watchapp, also assign a handler to
the pebblekit_connection_handler field. This will be called when the
status of the connection to the PebbleKit app changes.
Maybe it is what you need

asterisk get credit card info

I`m trying to build a script that will capture the credit card info like card number,cvc and expiration date using asterisk 11.x and asterisk-java library for AMI/AGI integration.
Right now I am able to build a script that will acquire that info if it is called via dialplan but i have a different scenario:
1. A call enters a queue.
2. An agent from the specific queue answer the call
3. The caller wants to input the card details
4. After the caller has entered the card details is redirected back to agent to continue the call.
My specific problem is related to step 3 as I do not know how to route the caller to my AGI and then back to the same agent. (eventually the agents has to be still involved in (some) call to guarantee that when the caller returns from agi it is still available)
Any idea how can I achieve that ? I know that this is a common practice so I think that there has to be a way.
When the call is delivered to the agent, use a macro to set a custom channel variable with the agent ID or extension in it.
Then, when your credit-card authentication function is done, read the variable and use an AGI command to transfer the call back to the agent.
Further Reading
http://www.voip-info.org/wiki/view/Asterisk+variables
http://www.voip-info.org/wiki/view/Asterisk+manager+Example:+Transfer
Note if this solution solves your problem, please 'accept' it to make it easier for others with the same issue to find it. thanks!
There are no any common practice for business process like you have. That depend of you and your client only.
You can use features conf or transfer. Can transfer to special extension or to conference room.
No way say what suite you better.
For sure you need understand how asterisk work before write any AGI/AMI or dialplan application. I can recommend ORelly's "Asterisk the future of telephony" book as start point.

SignalR - storing client information

I've started experimenting with SignalR. I've been trying to come up with a flexible way of storing information about each connected client. For example, storing the name in a chat app rather than passing it with each message.
At the moment, I have a static dictionary which matches the connectionId to an object which contains these properties. I add to this dictionary on connection, and remove on disconnection.
The issue I'm having is that I don't seem to get all disconnect events. If I close a tab in Chrome, the disconnect seems to go through. However, if I rapidly reload a tab, the disconnect doesn't seem to occur (at least not 'cleanly'). For example, if I reload the same tab over and over, it'll tell me my dictionary has multiple items when it should - in theory still be one.
Is there a standard way of storing this kind of per-connection information? Otherwise, what might be causing the issue I'm having?
You are actually handling connection id data correctly. Ensure that you are only instantiating your user data in OnConnected and uninstantiating it in OnDisconnected.
When spamming refresh on your page there are situations which result in the OnDisconnected event not being triggered immediately. However you should not worry about this because SignalR will actually time-out the connection and trigger the OnDisconnected event after a designated timeout (DisconnectTimeout).
If you do come across scenarios where there is not a 1-to-1 correlation for OnConnected and OnDisconnected events (after a significant amount of time) make sure to file a bug at https://github.com/SignalR/SignalR/issues.
Lastly if you're looking at doing some advanced chat mechanics and looking for some inspiration check out JabbR, it's open source!
https://github.com/davidfowl/JabbR
Hope this helps!

Resources