📜 ⬆️ ⬇️

AMI. Versatile Originate. CTI application

Originate can be translated from English as "give rise to." The possibilities of the team are very broad and not all are obvious. Originate, among CTI application developers, is one of the most popular AMI teams. More often it is used to initiate outgoing calls and organize call backs. In this article, we will consider advanced features.

AMI setup and telnet connection example
Set up an account in the /etc/asterisk/manager.conf file:

[general] enabled = yes port = 5038 bindaddr = 0.0.0.0 [1cami] ; secret=PASSWORD1cami deny=0.0.0.0/0.0.0.0 permit=0.0.0.0/0.0.0.0 ;    . read=call write=originate 

Next, in the Asterisk CLI, execute the command:

 module reload manager 

For connection we will use the telnet tools:
')
 ~ # telnet 127.0.0.1 5038 Asterisk Call Manager/1.2 

As soon as the “ Asterisk Call Manager ” prompt appears, you can enter commands. The first command should be authorization.

 Action: Login Username: 1cami Secret: PASSWORD1cami 

The end of the command is an empty line. If successful, we get the answer:

 Response: Success Message: Authentication accepted 


Baseline Originate Example


AMI command parameter description
  • Channel - The name of the channel. The format is type / identifier. Type - channel type, depending on the used SIP / IAX2 / DAHDI driver
  • Context - The name of the context to make the call. Should be used with Exten and Priority parameters.
  • Exten - phone number defined in the context context
  • Priority - Priority, position in Context, from which call processing will begin
  • Timeout - Timeout in milliseconds. If the originator of the outgoing call did not answer, the call will be terminated.
  • CallerID - the callerid value for the outgoing call. The format "EmployeeName <Telephone Number>"
  • Variable - setting variables for originated channels
  • Account - Accauntcode field value for outgoing calls
  • Application - dialplan command to be executed, used in conjunction with the “Data” parameter
  • Async - a sign of asynchronous command execution. If set to “1”, the result will be returned in an “Event” type package with the name “OriginateResponse” Data - Dialplan command parameters
  • ActionID is a request identifier, it is useful to use with several simultaneous asynchronous requests. Allows you to match the result with the original request


"Event" response codes with the name "OriginateResponse"
  • 0 = Number not found in Context
  • 1 = No answer
  • 4 = Successful (answered)
  • 8 = Overload or subscriber not available (congested or not available)


Consider initiating a call from SIP channel 104 to the number 74952293042 in the context of from-internal:

 Action: Originate Channel: SIP/104 Context: from-internal Exten: 74952293042 Priority: 1 Callerid: 104 Variable: SIPADDHEADER="Call-Info:\;answer-after=0" 

As a result of this command, the internal telephone associated with the SIP / 104 channel will ring. After lifting the handset, the call will go to the number 74952293042 in the from-internal context, priority 1.

In some cases, it is convenient to combine an outgoing call with an intercom , to do this, use the Variable parameter.
For Cisco, Linksys, Yealink and some softphones, setting the variable “ SIPADDHEADER ” to the value: " Call-Info: \; answer-after = 0 "

Suppose a Linksys telephone is used at the workplace. As a result, Originate will trigger an automatic call answer on the phone connected to the SIP / 104 channel.

Call Pickup


Everyone has heard about the function of intercepting a call received by a nearby telephone.
Usually the function is implemented by the "old code" * 8 .

To implement interception, the dialplan application can use PickUp or PickupChan , the network has quite a few examples of use.

How to organize this function using AMI?


To capture the call, you can use the Origin command. She has two interesting parameters:

Let us describe an example of intercepting a call received on sip account 104:

 Action: Originate Channel: SIP/104 Application: PickupChan Data: SIP/104-0000003c Priority: 1 Callerid: 104 Variable: SIPADDHEADER="Call-Info:\;answer-after=0" 

The peculiarity of this Originate is that there is no need to describe the “context” parameter.

But there is a need to track the channels that we can intercept. In this example, the channel is described as “SIP / 104-0000003b”.

You can track the appearance of new channels in the event " Newstate ", where " ChannelState " is set to "5" (Ringing) . Below is an example event:

 Event: Newstate Privilege: call,all Channel: SIP/104-0000003c ChannelState: 5 ChannelStateDesc: Ringing CallerIDNum: 104 CallerIDName: Default Extension ConnectedLineNum: 104 ConnectedLineName: Uniqueid: askozia-1438348824.146 

As soon as the event " Newstate " arrives , where " ChannelState " is set to "6" (Up) , the call has already been answered:

 Event: Newstate Privilege: call,all Channel: SIP/104-0000003c ChannelState: 6 ChannelStateDesc: Up CallerIDNum: 104 CallerIDName: Default Extension ConnectedLineNum: 104 ConnectedLineName: Uniqueid: askozia-1438348824.146 

The attentive reader will notice in the example of some nonsense:

 Action: Originate Channel: SIP/104 Application: PickupChan Data: SIP/104-0000003b 

There is no error. The call is performed with the Channel SIP / 104, PickupChan is performed for the channel SIP / 104-0000003b. That is, for your own channel.

I will comment on the example


We have launched this feature for everyday use. An IP phone is installed in my workplace. A headset is connected to the phone.
  1. I receive an incoming call;
  2. I press the button “Answer the call” in our CTI application;
  3. The originate example described above is executed;
  4. Thanks to the “SIPADDHEADER” installed, an auto-answer occurs;
  5. The phone makes an outgoing call and a pick-up call.

Physically, I do not pick up the phone. I communicate with the client on the headset. Hands free - profit on the face.

Listen to the recording of the conversation


In some cases, it is convenient to listen to the recording of a conversation from a telephone as a callback. Our number 104 will receive a call. When answered, we will hear a recording of the conversation.

AMI Example:

 Action: Originate Channel: SIP/104 Application: Playback Data: /storage/usbdisk1/test_file Priority: 1 Callerid: Playback Variable: SIPADDHEADER="Call-Info:\;answer-after=0" 

The application " Playback " is used, the full file name without the extension " / storage / usbdisk1 / test_file " is transferred as data.

Overhear the conversation


For training new employees, we began to use an unusual approach. Each intern can eavesdrop / listen to the conversations of his supervisor. Due to this, the employee quickly begins to understand how to build a conversation with the client.
In this case, we use the application " ChanSpy ":

 Action: Originate Channel: SIP/104 Application: ChanSpy Data: SIP/105,qx Priority: 1 Callerid: Spy-105 <105> Variable: SIPADDHEADER="Call-Info:\;answer-after=0" 



Join the conversation


In some cases, the curator needs to join the conversation and “get out” the situation. In this case, use the following example:

 Action: Originate Channel: SIP/104 Application: ChanSpy Data: SIP/105,qBx Priority: 1 Callerid: Spy-105 <105> Variable: SIPADDHEADER="Call-Info:\;answer-after=0" 



Prompter mode


The curator can join the conversation and prompt the intern:

 Action: Originate Channel: SIP/104 Application: ChanSpy Data: SIP/105,wx Priority: 1 Callerid: Spy-105 <105> Variable: SIPADDHEADER="Call-Info:\;answer-after=0" 



Conclusion


The teams described fit perfectly into CTI applications and can significantly improve the usability and efficiency of employees.

When developing, I recommend to pay attention to the PAMI, NAMI and Shift8 projects .

I hope this article will help in understanding the work of the originate command, which will make your CTI applications more functional.

Source: https://habr.com/ru/post/265647/


All Articles