This is my code below … it rings the number when i answer (via softphone X-Lite ) the call just hangs up , id have thought it would put me into conference room . Even if i change the application name to something else it does the same. So i don’t think i am doing things right at all. I was using the below as a basis for my code
As you can see i am just at the testing stage yet
<?php
// Replace with your port if not using the default.
// If unsure check /etc/asterisk/manager.conf under [general];
$port = 5038;
// Replace with your username. You can find it in /etc/asterisk/manager.conf.
// If unsure look for a user with "originate" permissions, or create one as
// shown at http://www.voip-info.org/wiki/view/Asterisk+config+manager.conf.
$username = "cxpanel";
// Replace with your password (refered to as "secret" in /etc/asterisk/manager.conf)
$password = "cxmanager*con";
// Internal phone line to call from
$internalPhoneline = "126";
// Context for outbound calls. See /etc/asterisk/extensions.conf if unsure.
$context = "from-internal";
$target = "700";
$socket = stream_socket_client("tcp://192.168.0.16:$port");
if($socket)
{
echo "Connected to socket, sending authentication request.\n";
// Prepare authentication request
$authenticationRequest = "Action: Login\r\n";
$authenticationRequest .= "Username: $username\r\n";
$authenticationRequest .= "Secret: $password\r\n";
$authenticationRequest .= "Events: off\r\n\r\n";
// Send authentication request
$authenticate = stream_socket_sendto($socket, $authenticationRequest);
if($authenticate > 0)
{
// Wait for server response
usleep(200000);
// Read server response
$authenticateResponse = fread($socket, 4096);
// Check if authentication was successful
if(strpos($authenticateResponse, 'Success') !== false)
{
echo "Authenticated to Asterisk Manager Inteface. Initiating call.\n";
// Prepare originate request
$originateRequest = "Action: Originate\r\n";
$originateRequest .= "Channel: PJSIP/$internalPhoneline\r\n";
$originateRequest .= "Application: ConfBridge\r\n";
$originateRequest .= "Callerid: Click 2 Call\r\n";
$originateRequest .= "ChannelId: 12333\r\n\r\n";
// $originateRequest .= "Exten: $target\r\n";
// $originateRequest .= "Context: $context\r\n";
// $originateRequest .= "Priority: 1\r\n";
// $originateRequest .= "Async: yes\r\n\r\n";
// Send originate request
$originate = stream_socket_sendto($socket, $originateRequest);
if($originate > 0)
{
// Wait for server response
usleep(200000);
// Read server response
$originateResponse = fread($socket, 4096);
// Check if originate was successful
if(strpos($originateResponse, 'Success') !== false)
{
echo "Call initiated, dialing.";
} else {
echo "Could not initiate call.\n";
}
} else {
echo "Could not write call initiation request to socket.\n";
}
} else {
echo "Could not authenticate to Asterisk Manager Interface.\n";
}
} else {
echo "Could not write authentication request to socket.\n";
}
} else {
echo "Unable to connect to socket.";
}
You can use the asterisk cli to get the sintax of each command, in this case you can use core show application confbridge to see all the options and parameters that you can pass to it.
I am now using the PAMI library for php and i have two parties in the conference but not sure how to add Caller A to the conference … it rings the two numbers who can join the same conference .
If i have Caller A on hold how do i automatically add him to the same conference , i have tried the bridge command but not sure … This is just test code… the output from the CLI is
[2017-05-30 15:50:46] WARNING[26025][C-00000037]: chan_sip.c:22814 func_header_read: This function can only be used on SIP channels.
$call = new OriginateAction('PJSIP/786');
$call->setApplication('ConfBridge');
$call->setActionID('newaction');
$call->setData('MYAPP.php');
[quote=“neowaseem, post:1, topic:70873”]
Caller A calls the call centre
Agent B picks up the call , puts Caller A on hold
[/quote] Maybe its better to transfer Caller A to the bridge in the step above, Caller A will listen MOH until anyone join the call.
[quote=“neowaseem, post:1, topic:70873”]
Agent B calls - Person C - asks if he is available to take this call (there is authorisation via a web interface Agent B has to do )
Agent B , links up Caller A and Person C onto a call .
[/quote]Here if Person C accept the call, then Agent B make another transfer to the bridge previously created, if not hangup, and Agent B join the bridge to tell Caller A.
[quote=“neowaseem, post:1, topic:70873”]
If Agent B hangs up the call between A and C continues.
If possible others can join the call between A and C
[/quote]Since the begginig everyone is in the bridge so anyone can join and left the call.
If you are doing all of this with AMI:
– create the bridge dynamically
– Insert AgentB on it by default
– when Caller A make into the CC join the bridge.
– Agent B do his stuff and call C
– If C accept the call use AMI REDIRECT to put C&B sip channels into the bridge.
– Hangup the call of Agent B.
All of this can be handle by simple dialplan, not sure why you need to use AMI but thats an idea on how to redirect calls and bridge channels