Re: [asterisk-users] Call Hold / Transfer via AMI

2021-07-21 Thread Dan Cropp
We found no way to do this from AMI.

Very tied up on other projects, but if another developer wanted to look into 
adding support for it, I believe it would be something along these lines….


int action_hold(struct mansession *s, const struct message *m)
{
const char *channelarg = astman_get_header(m, "Channel");
struct ast_channel *chan = NULL;
int res = -1;

if (ast_strlen_zero(channelarg))
{
astman_send_error(s, m, "No channel specified");
return 0;
}

chan = ast_channel_get_by_name(channelarg);
if (chan)
{
ast_log(LOG_DEBUG, "Putting channel %s on hold (0x%p)\n", 
ast_channel_name(chan), chan);
if ((res = ast_indicate(chan, AST_CONTROL_HOLD)))
{
astman_send_error(s, m, "Failed to put channel on hold");
}
ast_channel_unref(chan);
}
else astman_send_error(s, m, "No such channel");

if (!res) astman_send_ack(s, m, "Hold");

return 0;
}

int action_unhold(struct mansession *s, const struct message *m)
{
const char *channelarg = astman_get_header(m, "Channel");
struct ast_channel *chan = NULL;
int res = -1;

if (ast_strlen_zero(channelarg))
{
astman_send_error(s, m, "No channel specified");
return 0;
}

chan = ast_channel_get_by_name(channelarg);
if (chan)
{
if ((res = ast_indicate(chan, AST_CONTROL_UNHOLD)))
{
astman_send_error(s, m, "Failed to remove channel from hold");
}
ast_channel_unref(chan);
}
else astman_send_error(s, m, "No such channel");

if (!res) astman_send_ack(s, m, "Unhold");

return 0;
}

const char *hold_synopsis = "Place Channel on Hold";
const char *hold_desc = "Place the channel specified by the 'Channel' argument 
on Hold";
const char *unhold_synopsis = "Remove Channel from Hold";
const char *unhold_desc = "Remove the channel specified by the 'Channel' 
argument from Hold";

ast_manager_register2("Hold", EVENT_FLAG_CALL, action_hold, AST_MODULE_SELF, 
hold_synopsis, hold_desc);
ast_manager_register2("UnHold", EVENT_FLAG_CALL, action_unhold, 
AST_MODULE_SELF, unhold_synopsis, unhold_desc);


From: asterisk-users  On Behalf Of 
Joshua C. Colp
Sent: Wednesday, July 21, 2021 5:57 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion 

Subject: Re: [asterisk-users] Call Hold / Transfer via AMI

On Wed, Jul 21, 2021 at 7:39 AM Antony Stone 
mailto:antony.st...@asterisk.open.source.it>>
 wrote:
Hi.

From the lack of response to my question, I'm assuming that either:

a) putting a call on hold is not possible via AMI
or
b) everyone thinks it's so obvious that I should be able to see it for myself

Can anyone confirm one way or the other?

If it simply isn't possible, I'd like to put my efforts into exploring
alternative solutions instead of spending more time on AMI.

From a surface level I know of no way from AMI to control putting a call on and 
off hold.

--
Joshua C. Colp
Asterisk Technical Lead
Sangoma Technologies
Check us out at www.sangoma.com<http://www.sangoma.com> and 
www.asterisk.org<http://www.asterisk.org>

This email is intended only for the use of the party to which it is addressed 
and may contain information that is privileged, confidential, or protected by 
law. If you are not the intended recipient you are hereby notified that any 
dissemination, copying or distribution of this email or its contents is 
strictly prohibited. If you have received this message in error, please notify 
us immediately by replying to the message and deleting it from your computer.
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Call Hold / Transfer via AMI

2021-07-21 Thread Joshua C. Colp
On Wed, Jul 21, 2021 at 7:39 AM Antony Stone <
antony.st...@asterisk.open.source.it> wrote:

> Hi.
>
> From the lack of response to my question, I'm assuming that either:
>
> a) putting a call on hold is not possible via AMI
> or
> b) everyone thinks it's so obvious that I should be able to see it for
> myself
>
> Can anyone confirm one way or the other?
>
> If it simply isn't possible, I'd like to put my efforts into exploring
> alternative solutions instead of spending more time on AMI.
>

>From a surface level I know of no way from AMI to control putting a call on
and off hold.

-- 
Joshua C. Colp
Asterisk Technical Lead
Sangoma Technologies
Check us out at www.sangoma.com and www.asterisk.org
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Call Hold / Transfer via AMI

2021-07-21 Thread Antony Stone
Hi.

From the lack of response to my question, I'm assuming that either:

a) putting a call on hold is not possible via AMI
or
b) everyone thinks it's so obvious that I should be able to see it for myself

Can anyone confirm one way or the other?

If it simply isn't possible, I'd like to put my efforts into exploring 
alternative solutions instead of spending more time on AMI.

Thanks,


Antony.

On Monday 19 July 2021 at 11:02:19, Antony Stone wrote:

> Hi.
> 
> Nobody has any ideas?
> 
> I have an AMI login to a proprietary PBX (ie: I can't see or modify the
> dial plan).  I can subscribe to all events, get channel numbers when calls
> are set up, etc.  I can issue AMI commands, originate calls...
> 
> How can I use AMI to put a call on hold, and then either resume it, or
> perform a transfer?
> 
> On Thursday 15 July 2021 at 15:01:41, Antony Stone wrote:
> > Hi.
> > 
> > I have the following situation:
> > 
> > An Asterisk 16 server on which I have complete control of the dialplan,
> > and which has (a) a SIP trunk to a PSTN gateway provider, and (b)
> > several SIP credentials for accounts (extensions) on another Asterisk
> > server.  For this example I have SIP username and password for extension
> > 234 on that server.
> > 
> > That "other Asterisk server" is also Asterisk 16, but is a proprietary
> > PBX which I cannot even see the dialplan of, let alone modify it.  I do,
> > however, have full access to the AMI interface on that PBX, and I can
> > write scripts (eg: in Perl) on my own server and connect to the PBX's
> > AMI.
> > 
> > I get an inbound call on my SIP trunk, and I need to dial it on to
> > extension 456 on the PBX, from extension 234.  So far, so good, I can do
> > all this.  The incoming call arrives, I use the SIP credentials for
> > extension 234 to dial 456, and the call gets answered by 456, who sees
> > Caller ID 234.
> > 
> > Then I need to put 456 on hold, so that they get the hold music which is
> > configured on the (proprietary) PBX, and perhaps I then need to dial to a
> > different number from extension 234, and maybe ultimately transfer the
> > call. Alternatively, I might simply want to resume the call that was put
> > on hold.
> > 
> > Putting a call on hold and then having the option to transfer it to
> > another number is easy with a SIP phone, but I need to do it for the
> > call which my Asterisk server (acting as a SIP client to the PBX) has
> > initiated.
> > 
> > I can't do the hold function on my own Asterisk server because that would
> > not generate the correct hold music for the person on 456.
> > 
> > Also, if I transfer the call (so that 456 is now speaking to some other
> > number which I dialled whilst on hold) using my own Asterisk server, I
> > would end up with two calls in progress between my server and the PBX,
> > whereas I want the PBX to completely handle the transferred call, and
> > mine (which took the original incoming call on the SIP trunk) to have
> > nothing further to do with it.
> > 
> > I can find AMI commands such as Atxfer, BlindTransfer, and Redirect.  All
> > of these are fine if I want to actually transfer a call, but how do I
> > simply tell the proprietary PBX to put a call on hold and play the
> > configured music?
> > 
> > I hope this is clear - feel free to ask any questions if not.
> > 
> > Thanks,
> > 
> > 
> > Antony.

-- 
"this restriction will not apply in the event of the occurrence (certified by 
the United States Centers for Disease Control or successor body) of a 
widespread viral infection transmitted via bites or contact with bodily fluids 
that causes human corpses to reanimate and seek to consume living human flesh, 
blood, brain or nerve tissue and is likely to result in the fall of organized 
civilization."

 - https://aws.amazon.com/service-terms/ paragraph 42.10

   Please reply to the list;
 please *don't* CC me.

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Call Hold / Transfer via AMI

2021-07-19 Thread Antony Stone
On Monday 19 July 2021 at 11:59:34, Naveen Albert wrote:

> I'm not sure I fully understand the entire question.
> If you have full AMI access, why not send the ShowDialPlan AMI action to
> see the dial plan?

1. How would seeing the dial plan help me to put a call on hold?

2. The result is pretty much useless to me because it's all done via AGI.


Antony.

> On 7/19/2021 4:02 AM, Antony Stone wrote:
> > Hi.
> > 
> > Nobody has any ideas?
> > 
> > I have an AMI login to a proprietary PBX (ie: I can't see or modify the
> > dial plan).  I can subscribe to all events, get channel numbers when
> > calls are set up, etc.  I can issue AMI commands, originate calls...
> > 
> > How can I use AMI to put a call on hold, and then either resume it, or
> > perform a transfer?
> > 
> > On Thursday 15 July 2021 at 15:01:41, Antony Stone wrote:
> >> Hi.
> >> 
> >> I have the following situation:
> >> 
> >> An Asterisk 16 server on which I have complete control of the dialplan,
> >> and which has (a) a SIP trunk to a PSTN gateway provider, and (b)
> >> several SIP credentials for accounts (extensions) on another Asterisk
> >> server.  For this example I have SIP username and password for
> >> extension 234 on that server.
> >> 
> >> That "other Asterisk server" is also Asterisk 16, but is a proprietary
> >> PBX which I cannot even see the dialplan of, let alone modify it.  I
> >> do, however, have full access to the AMI interface on that PBX, and I
> >> can write scripts (eg: in Perl) on my own server and connect to the
> >> PBX's AMI.
> >> 
> >> I get an inbound call on my SIP trunk, and I need to dial it on to
> >> extension 456 on the PBX, from extension 234.  So far, so good, I can do
> >> all this.  The incoming call arrives, I use the SIP credentials for
> >> extension 234 to dial 456, and the call gets answered by 456, who sees
> >> Caller ID 234.
> >> 
> >> Then I need to put 456 on hold, so that they get the hold music which is
> >> configured on the (proprietary) PBX, and perhaps I then need to dial to
> >> a different number from extension 234, and maybe ultimately transfer
> >> the call. Alternatively, I might simply want to resume the call that
> >> was put on hold.
> >> 
> >> Putting a call on hold and then having the option to transfer it to
> >> another number is easy with a SIP phone, but I need to do it for the
> >> call which my Asterisk server (acting as a SIP client to the PBX) has
> >> initiated.
> >> 
> >> I can't do the hold function on my own Asterisk server because that
> >> would not generate the correct hold music for the person on 456.
> >> 
> >> Also, if I transfer the call (so that 456 is now speaking to some other
> >> number which I dialled whilst on hold) using my own Asterisk server, I
> >> would end up with two calls in progress between my server and the PBX,
> >> whereas I want the PBX to completely handle the transferred call, and
> >> mine (which took the original incoming call on the SIP trunk) to have
> >> nothing further to do with it.
> >> 
> >> I can find AMI commands such as Atxfer, BlindTransfer, and Redirect. 
> >> All of these are fine if I want to actually transfer a call, but how do
> >> I simply tell the proprietary PBX to put a call on hold and play the
> >> configured music?
> >> 
> >> I hope this is clear - feel free to ask any questions if not.
> >> 
> >> Thanks,
> >> 
> >> 
> >> Antony.

-- 
“If code doesn’t receive constant love, it turns to shit.”

 - Brad Fitzpatrick, Google engineer

   Please reply to the list;
 please *don't* CC me.

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Call Hold / Transfer via AMI

2021-07-19 Thread Antony Stone
Hi.

Nobody has any ideas?

I have an AMI login to a proprietary PBX (ie: I can't see or modify the dial 
plan).  I can subscribe to all events, get channel numbers when calls are set 
up, etc.  I can issue AMI commands, originate calls...

How can I use AMI to put a call on hold, and then either resume it, or perform 
a transfer?

On Thursday 15 July 2021 at 15:01:41, Antony Stone wrote:

> Hi.
> 
> I have the following situation:
> 
> An Asterisk 16 server on which I have complete control of the dialplan, and
> which has (a) a SIP trunk to a PSTN gateway provider, and (b) several SIP
> credentials for accounts (extensions) on another Asterisk server.  For this
> example I have SIP username and password for extension 234 on that server.
> 
> That "other Asterisk server" is also Asterisk 16, but is a proprietary PBX
> which I cannot even see the dialplan of, let alone modify it.  I do,
> however, have full access to the AMI interface on that PBX, and I can
> write scripts (eg: in Perl) on my own server and connect to the PBX's AMI.
> 
> I get an inbound call on my SIP trunk, and I need to dial it on to
> extension 456 on the PBX, from extension 234.  So far, so good, I can do
> all this.  The incoming call arrives, I use the SIP credentials for
> extension 234 to dial 456, and the call gets answered by 456, who sees
> Caller ID 234.
> 
> Then I need to put 456 on hold, so that they get the hold music which is
> configured on the (proprietary) PBX, and perhaps I then need to dial to a
> different number from extension 234, and maybe ultimately transfer the
> call. Alternatively, I might simply want to resume the call that was put
> on hold.
> 
> Putting a call on hold and then having the option to transfer it to another
> number is easy with a SIP phone, but I need to do it for the call which my
> Asterisk server (acting as a SIP client to the PBX) has initiated.
> 
> I can't do the hold function on my own Asterisk server because that would
> not generate the correct hold music for the person on 456.
> 
> Also, if I transfer the call (so that 456 is now speaking to some other
> number which I dialled whilst on hold) using my own Asterisk server, I
> would end up with two calls in progress between my server and the PBX,
> whereas I want the PBX to completely handle the transferred call, and mine
> (which took the original incoming call on the SIP trunk) to have nothing
> further to do with it.
> 
> I can find AMI commands such as Atxfer, BlindTransfer, and Redirect.  All
> of these are fine if I want to actually transfer a call, but how do I
> simply tell the proprietary PBX to put a call on hold and play the
> configured music?
> 
> I hope this is clear - feel free to ask any questions if not.
> 
> Thanks,
> 
> 
> Antony.

-- 
"Can you keep a secret?"
"Well, I shouldn't really tell you this, but... no."


   Please reply to the list;
 please *don't* CC me.

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

[asterisk-users] Call Hold / Transfer via AMI

2021-07-15 Thread Antony Stone
Hi.

I have the following situation:

An Asterisk 16 server on which I have complete control of the dialplan, and 
which has (a) a SIP trunk to a PSTN gateway provider, and (b) several SIP 
credentials for accounts (extensions) on another Asterisk server.  For this 
example I have SIP username and password for extension 234 on that server.

That "other Asterisk server" is also Asterisk 16, but is a proprietary PBX 
which I cannot even see the dialplan of, let alone modify it.  I do, however, 
have full access to the AMI interface on that PBX, and I can write scripts 
(eg: in Perl) on my own server and connect to the PBX's AMI.

I get an inbound call on my SIP trunk, and I need to dial it on to extension 
456 on the PBX, from extension 234.  So far, so good, I can do all this.  The 
incoming call arrives, I use the SIP credentials for extension 234 to dial 
456, and the call gets answered by 456, who sees Caller ID 234.

Then I need to put 456 on hold, so that they get the hold music which is 
configured on the (proprietary) PBX, and perhaps I then need to dial to a 
different number from extension 234, and maybe ultimately transfer the call.  
Alternatively, I might simply want to resume the call that was put on hold.

Putting a call on hold and then having the option to transfer it to another 
number is easy with a SIP phone, but I need to do it for the call which my 
Asterisk server (acting as a SIP client to the PBX) has initiated.

I can't do the hold function on my own Asterisk server because that would not 
generate the correct hold music for the person on 456.

Also, if I transfer the call (so that 456 is now speaking to some other number 
which I dialled whilst on hold) using my own Asterisk server, I would end up 
with two calls in progress between my server and the PBX, whereas I want the 
PBX to completely handle the transferred call, and mine (which took the 
original incoming call on the SIP trunk) to have nothing further to do with 
it.

I can find AMI commands such as Atxfer, BlindTransfer, and Redirect.  All of 
these are fine if I want to actually transfer a call, but how do I simply tell 
the proprietary PBX to put a call on hold and play the configured music?

I hope this is clear - feel free to ask any questions if not.

Thanks,


Antony.

-- 
I have an excellent memory.
I can't think of a single thing I've forgotten.

   Please reply to the list;
 please *don't* CC me.

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users