ODBC
Example 1 Outgoing call - Conditional rules - some numbers can call but others not
The first, we will go to
Services → MySQL
and in the MySQL DataBases we will go to do click in
Add. We will configure the parameters the next way:
Name: [example]
SQL: Execute
SQL Editor:
CREATE TABLE `disponibilidad` (
`cliente` varchar(10) NOT NULL,
`disponible` varchar(4) DEFAULT 'YES'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
insert into `disponibilidad` (cliente, disponible) values (100, 'YES');
insert into `disponibilidad` (cliente, disponible) values (101, 'NO');
insert into `disponibilidad` (cliente, disponible) values (103, 'NO');
insert into `disponibilidad` (cliente, disponible) values (104, 'YES');
When it's ok, click on Add.
Now, we will to create a new ODBC, to this we will go to
Home → ODBC
and we do click on
Add. We will configure the parameters the next way:
Name: [example]
Parameters:
Driver: My SQL Internal
Database: [example]
When it's ok, click on Add.
To continue, we will create an extension for a context, to do this we will go to
Telephony → Dialplan\\, we will select the “Outgoing” context and we will do click on
Add in “Outgoing call condition”. We will configure the parameters the next way:
Name: [example].
Priority: First.
Continue: Check on.
Conditions: Any.
Action:
Custom.
ODBC.
Execute: On start.
Select disponible from `disponibilidad` where cliente = '${caller_id_number}';
When it's ok, click on Add.
The next step will be add a new “Outgoing call condition”, for that, we will repeat the step 3. We will configure the parameters the next way:
To finish, we do click on Add.
Example 2 Outgoing call - Conditional rules - Limit users by call time (after reach the time limit no more calls are allowed)
The first, we will go to
Services → MySQL
and in the MySQL DataBases we will go to do click in
Add. We will configure the parameters the next way:
Name: pruebas.
SQL: Execute
SQL Editor:
CREATE TABLE `llamadas` (
`tiempo` varchar(10) NOT NULL,
`cliente` varchar(10) NOT NULL,
`segundos` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
insert into `llamadas` (tiempo, cliente, segundos) values (curdate(), '100', '20');
insert into `llamadas` (tiempo, cliente, segundos) values (curdate(), '101', '0');
Then, we will to create a new ODBC, to this we will go to
Home → ODBC
and we do click on
Add. We will configure the parameters the next way:
Name: [pruebas]
Parameters:
Driver: My SQL Internal
Database: pruebas.
When it's ok, click on Add.
Now we will create an extension for a context, to do this we will go to
Telephony → Dialplan\\, we will select the “Outgoing” context and we will do click on
Add in “Outgoing call condition”. We will configure the parameters the next way:
Name: pruebas.
Priority: First.
Continue: Check on.
Conditions: Any.
Action:
Custom.
ODBC.
Execute: On start.
SELECT CASE WHEN (select ifnull (sum(segundos), 0) as total from llamadas where cliente = '${caller_id_number}' and tiempo >= unix_timestamp(curdate() + INTERVAL 0 hour)) > 200 THEN 'bloqueo' ELSE 'acceptar' END as respuesta ;
insert into `llamadas` values ('${start_epoch}', '${caller_id_number}', '${billsec}') ;
When it's ok, click on Add.
To continue will be add a new “Outgoing call condition”, for that, we will repeat the step 3. We will configure the parameters the next way:
Name: odbc_no.
Priority: after pruebas.
Continue: not
Conditions: Custom.
Action:
To finish, we do click on Add.
Example 3 Outgoing call - Conditional rules - Limit user by call time, force to hangup on available time, and prevent next call after limit reached
The first, we will go to
Services → MySQL
and in the MySQL DataBases we will go to do click in
Add. We will configure the parameters the next way:
Name: pruebas.
SQL: Execute
SQL Editor:
CREATE TABLE `llamadas` (
`tiempo` varchar(10) NOT NULL,
`cliente` varchar(10) NOT NULL,
`segundos` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
insert into `llamadas` (tiempo, cliente, segundos) values (curdate(), '100', '20');
insert into `llamadas` (tiempo, cliente, segundos) values (curdate(), '101', '0');
Then, we will to create a new ODBC, to this we will go to
Home → ODBC
and we do click on
Add. We will configure the parameters the next way:
Name: [pruebas]
Parameters:
Driver: My SQL Internal
Database: pruebas.
When it's ok, click on Add.
Now we will create an extension for a context, to do this we will go to
Telephony → Dialplan\\, we will select the “Outgoing” context and we will do click on
Add in “Outgoing call condition”. We will configure the parameters the next way:
Name: pruebas.
Priority: First.
Continue: Check on.
Conditions: Any.
Action:
Custom.
ODBC.
Execute: On start.
SELECT CASE WHEN (select ifnull (sum(segundos), 0) as total from llamadas where cliente = '${caller_id_number}' and tiempo >= unix_timestamp(curdate() + INTERVAL 0 hour)) >=200 THEN 'bloqueo' ELSE 'acceptar' END as respuesta ;
insert into `llamadas` values ('${start_epoch}', '${caller_id_number}', '${billsec}') ;
When it's ok, click on Add.
To continue will be add a new “Outgoing call condition”, we will configure the parameters the next way:
Name: odbc_no.
Priority: after pruebas.
Continue: not
Conditions: Custom.
Action:
When it's ok, click on Add.
Now will be add other new “Outgoing call condition”, we will configure the parameters the next way:
Name: pruebas2.
Priority: after odbc_no.
Continue: Check on.
Conditions: Any.
Action:
Custom.
ODBC.
Execute: On start.
select 200 - sum(segundos) as restante from llamadas where cliente = ${caller_id_number} and tiempo >= unix_timestamp(curdate() + INTERVAL 1 minute);
When it's ok, click on Add.
To finish, we will go to create the last “Outgoing call condition”, we will configure the parameters the next way:
When it's ok, click on Add.
Example 4 condition to Outgoing call - Make a call to X digits number, pulsing only the 3 firsts:
The first, we will go to
Services → MySQL
and in the MySQL DataBases we will go to do click in
Add. We will configure the parameters the next way:
Name: Agenda.
SQL: Execute
SQL Editor:
CREATE TABLE Agenda (
LARGO varchar(9) NOT NULL,
CORTO varchar(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO Agenda (LARGO, CORTO) VALUES (698765432, 698);
INSERT INTO Agenda (LARGO, CORTO) VALUES (612345678, 612);
INSERT INTO Agenda (LARGO, CORTO) VALUES (678945612, 678);
INSERT INTO Agenda (LARGO, CORTO) VALUES (632165498, 632);
Then, we will to create a new ODBC, to this we will go to
Home → ODBC
and we do click on
Add. We will configure the parameters the next way:
Name: agenda_ODBC
Parameters:
Driver: My SQL Internal
Database: Agenda.
When it's ok, click on Add.
Now we will create an extension for a context, to do this we will go to
Telephony → Dialplan\\, we will select the “Outgoing” context and we will do click on
Add in “Outgoing call condition”. We will configure the parameters the next way:
select largo from Agenda where corto = ${destination_number};
When it's ok, click on Add.
To continue will be add a new “Outgoing call condition”, we will configure the parameters the next way:
When it's ok, click on Add.
To finish, we will go to create the last “Outgoing call condition”, we will configure the parameters the next way:
When it's ok, click on Add.
Example 5 condition to Outgoing call - Show in the addressee the name and number who is calling:
The first, we will go to
Services → MySQL
and in the MySQL DataBases we will go to do click in
Add. We will configure the parameters the next way:
Name: Agenda_2.
SQL: Execute
SQL Editor:
CREATE TABLE Agenda_2 (
LARGO varchar(9) NOT NULL,
CORTO varchar(3) NOT NULL,
NOMBRE varchar(10) NOT NULL
);
INSERT INTO Agenda_2 (LARGO, CORTO, NOMBRE) VALUES (698765432, 698, 'CARLOS');
INSERT INTO Agenda_2 (LARGO, CORTO, NOMBRE) VALUES (612345678, 612, 'FRANCOIS');
INSERT INTO Agenda_2 (LARGO, CORTO, NOMBRE) VALUES (678945612, 678, 'SERGIO');
INSERT INTO Agenda_2 (LARGO, CORTO, NOMBRE) VALUES (632165498, 632, 'ANTONIO');
Then, we will to create a new ODBC, to this we will go to
Home → ODBC
and we do click on
Add. We will configure the parameters the next way:
Name: agenda_2_ODBC
Parameters:
Driver: My SQL Internal
Database: Agenda_2.
When it's ok, click on Add.
Now we will create an extension for a context, to do this we will go to
Telephony → Dialplan\\, we will select the “Outgoing” context and we will do click on
Add in “Outgoing call condition”. We will configure the parameters the next way:
select nombre from Agenda_2 where corto = ${caller_id_number};
When it's ok, click on Add.
To continue will be add a new “Outgoing call condition”, we will configure the parameters the next way:
When it's ok, click on Add.
To finish, we will go to create the last “Outgoing call condition”, we will configure the parameters the next way:
When it's ok, click on Add.
Example 6 callback, if account is busy:
The first, we will go to
Services → MySQL
and in the MySQL DataBases we will go to do click in
Add. We will configure the parameters the next way:
Name: [localhost]
SQL: Execute
SQL Editor:
CREATE TABLE `numbers` (
`phone` varchar(10) NOT NULL,
`account` varchar(10) DEFAULT 'YES'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
When it's ok, click on Add.
Now, we will to create a new ODBC, to this we will go to
Home → ODBC
and we do click on
Add. We will configure the parameters the next way:
Name: [localhost]
Parameters:
Driver: My SQL Internal
Database: [localhost]
When it's ok, click on Add.
To call to a account and continue if busy.
Name: call account
Priority: last
Continue: x - Continue after extension
Conditions: x - custom; x - Destination number: x-Expression: ^20\d$
Action: x - custom: Bridge Local; Type: x - account; Domain: commsmundi.com; Number: ${destination_number}
click Add
Adding a rule call trigger upon hangup. Add the rule using the following parameters:
To add a new menu action go to the page Telephony → IVR:
Select the IVR where you want to add the new action or actions by clicking in the folder icon, near its name in the IVR table.
In the IVR Actions table (where the configured IVR actions are listed), click Add
Example of some actions that you can add:
Action: insert in odbc
Set the value for the Digits, 6
Set the value for the Priority, first
Set the Action for the ivr menu, choose:
Click Add
Adding a trigger:
Name: numbers
X- key : <key trigger>
Adding a trigger rule that check in odbc query:
Adding a trigger rule that to call:<WRAP>
Name: call
Priority: Last
Continue: Continue after rule
Conditions: x - custom; x - Variable text; Name: odbc_account; Expression: ^.+$
Action: Call
Destination: ${odbc_account} @ outgoing
Action: ${odbc_phone} @ outgoing
Click on Add
Adding a trigger rule that delete in odbc query:<WRAP>
Connecting 2 CM servers using SIP trunks
The two CM are already configured with the service telephony running. Their configuration is:
| CM-A | CM-B |
IP | 10.10.10.1 | 10.10.20.1 |
Local domain | commsmundi.com | commsmundi.com |
Local extensions | 3000-3100 | 3000-3100 |
It's recommended to use a SIP profile with TLS enable. Also, when configure the lines we recommend that Secure media is enable.
The first step is to stablish the SIP trunk between the servers.
Adding the SIP trunk in CM-A
To add a SIP line go to the page Telephony → Lines:
In the lines table (where the configured lines are listed), click Add
Set the value for the name, CM-B
Set the value for the context, incoming
For the gateway parameters, choose:
For the parameters parameters, choose:
Click Add
Adding the SIP trunk in CM-B
To add a SIP line go to the page Telephony → Lines:
In the lines table (where the configured lines are listed), click Add
Set the value for the name, CM-A
Set the value for the context, incoming
For the gateway parameters, choose:
For the parameters parameters, choose:
Click Add
The next steps is to configure the dialplan to allow calls between the two servers.
Context Incoming
This is the context used to receive all the calls from the SIP trunk.
To add the rule, go to the page Telephony → Dialplan:
Select the incoming context by clicking in the folder icon, near its name on the contexts table.
In the extensions table (Context 'incoming': Extensions), click Add
Set the Name parameter, Local calls
Set the Priority parameter, first
For the Conditions parameters, choose:
For the actions parameters, choose:
Click Add
Context outgoing
This is the context used by the local extensions to make calls to outside.
Since the two servers have the same extensions range, is necessary to set a prefix to make the call to go to the remote server. The prefix to identify CM-B is 1.
To add the rule, go to the page Telephony → Dialplan:
Select the outgoing context by clicking in the folder icon, near its name on the contexts table.
In the extensions table (Context 'outgoing': Extensions), click Add
Set the Name parameter, Local calls in CM-B
Set the Priority parameter, first
For the Conditions parameters, choose:
For the actions parameters, choose:
Click Add
Context Incoming
This is the context used to receive all the calls from the SIP trunk.
To add the rule, go to the page Telephony → Dialplan:
Select the incoming context by clicking in the folder icon, near its name on the contexts table.
In the extensions table (Context 'incoming': Extensions), click Add
Set the Name parameter, Local calls
Set the Priority parameter, first
For the Conditions parameters, choose:
For the actions parameters, choose:
Click Add
Context outgoing
This is the context used by the local extensions to make calls to outside.
Since the two servers have the same extensions range, is necessary to set a prefix to make the call to go to the remote server. The prefix to identify CM-A is 1.
To add the rule, go to the page Telephony → Dialplan:
Select the outgoing context by clicking in the folder icon, near its name on the contexts table.
In the extensions table (Context 'outgoing': Extensions), click Add
Set the Name parameter, Local calls in CM-A
Set the Priority parameter, first
For the Conditions parameters, choose:
For the actions parameters, choose:
Click Add
Polls in Commsmundi
Polls at Commsmundi are done by dialplan.
You will need to configure some rules, many as questions you want to ask plus options answers.
Depending what the user press', Commsmundi can realize an action or another.
In this example, in the first question if user press one he will go to another question, but if the user press' 2 he will record a message. In case of the user press' 1 and then he answers the second question he will hear a text to speech saying what he has pressed before.
Starting point, Rule #1
Name: Starting point
Continue: x - Continue after extension
Conditions: x - Custom; x - Destination number: ^1$
Action: x - Custom: Playback and Get digits; Variable digit_question1
Digits: 1|2
Retries: 3
Transfer to avoid loops
Name: Transfer from 1 to 2
Conditions: x - Custom; x - Destination number: ^1$
Actions: x - Custom; Transfer: options2 @ outgoing
Option 1, Rule #2
Name: question1 Option 1
Conditions: x - Custom; x - Destination number: ^options2$
x - Channel variable: Name: digit_question1; x - Expression: ^1$
Action: x - Custom; Transfer: question2 @ outgoing
Option 2, Rule #3
Name: question1 Option 2
Conditions: x - Custom; x - Destination number: ^options2$
x - Channel variable: Name: digit_question1; x - Expression: ^2$
Action: x - Custom: Playback and Record
Second question, Rule #4
Name: question2
x - Continue after extension
Conditions: x - Custom; x - Destination number: ^question2$
Action: x - Custom: Playback and Get digits; Variable digit_question2
Final, Rule #5
Name: Final
Conditions: x - Custom; x - Destination number: ^question2$
Action: x - Custom: Text to Speech; Text: In the first question you pressed ${chan_digit_question1}.In the second question you pressed ${chan_digit_question2}.