Use AMI (Asterisk Manager Interface) to interact with the Asterisk server. The API enables client programs to connect to Asterisk server by using TCP/IP protocol. The Application Programming Interface enables you to process events in the digital multiplex system (DMS), and send commands to control calls.
A client uses a simple text protocol for communication between the Asterisk and the connected Manager API: "parameter: value". The end of a string is determined by the sequence of Carriage Return and Line Feed (CRLF).
Set up the configuration file of the Messaging Service to integrate Asterisk to Creatio
For integration to work with Creatio, you need to install Terrasoft Messaging Service (TMS) on a dedicated computer that will be used as the integration server. You must set the following parameters for Asterisk in the Terrasoft.Messaging.Service.exe.config configuration file:
Ports for Asterisk integration with Creatio
- TMS accepts WebSocket connection to the 2013 port via TCP.
- TMS connects to the Asterisk server by default via the 5038 port.
The Terrasoft Messaging Service for Asterisk integration with Creatio
The integration part of the Messaging Service is implemented in the main Creatio solution kernel in the Terrasoft.Messaging.Asterisk library.
Library main classes:
- AsteriskAdapter — an Asterisk class that transforms events to the top-level call model events used in Creatio integration.
- AsteriskManager — a class that creates and deletes user connections to the Asterisk server.
- AsteriskConnection — a class that represents the user connection for integration with Asterisk.
- AsteriskClient — a class used to send commands to the Asterisk server.
Example of CtiModel, Terrasoft Messaging Service and Asterisk Manager API interaction
Operator outgoing call to a subscriber: putting a call on hold, putting off hold by a subscriber and finishing the call by the operator.
The order of events during a call for the current example:
The table shows an example of event processing including how the event data is interpreted by TMS and which values from the listed events are used when processing an incoming call.
Asterisk log | TMS | Action | Client |
---|---|---|---|
|
A channel is created and added to a collection |
||
|
Search for the channel by <unique_id> and generate an event by using the fireEvent method. | PutHoldAction | Processing the PutHoldAction and displaying the call on hold. |
|
Search for the channel by <unique_id> and generate an event by using the fireEvent method. | EndHoldAction | Processing the EndHoldAction and displaying the call on hold. |
|
Search for the channel by <unique_id> and generate an event by using the fireEvent method. | RingFinished | Processing event and displaying the call end. |
|
Search for the channel by <unique_id>, fill in the data and generate an event by using the fireEvent method. | RingStarted | Processing the RingStarted event and displaying it on the outgoing call panel. |
|
Search for the channel by <unique_id> and generate an event by using the fireEvent method. | CommutationStarted | Processing the CommunicationStarted event and displaying the communication. |
Clicking the "Answer" button initiates a new event in Asterisk. |
Asterisk events
A detail list of events and information about their parameters is described in the Asterisk documentation.