Table of Contents

ODBC

Example 1 Outgoing call - Conditional rules - some numbers can call but others not

  1. 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.

  2. 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.

  3. 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.
        • ODBC: [example]
        • SQL:
    Select disponible from `disponibilidad` where cliente = '${caller_id_number}';

    When it's ok, click on Add.

  4. 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:
    • Name: [example].
    • Priority: after [example].
    • Continue: not
    • Conditions: Custom.
      • ODBC variable: check on.
        • Name: disponible.
        • Check on expression and write NO
    • Action:
      • Custom.
      • Text To Speech:
        • Language: en-EN
        • Text: You can't call.
  5. 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)

  1. 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');
  2. 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.

  3. 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.
        • ODBC: pruebas.
        • SQL:
    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 ;
    • Execute: On hangup.
      • ODBC: pruebas.
      • SQL:
    insert into `llamadas` values ('${start_epoch}', '${caller_id_number}', '${billsec}') ;

    When it's ok, click on Add.

  4. 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.
      • ODBC variable: check on.
        • Name: respuesta.
        • Check on expression and write bloqueo
    • Action:
      • Custom.
      • Text To Speech:
        • Language: en-EN
        • Text: You've exceeded the limit of minutes.
  5. 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

  1. 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');
  2. 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.

  3. 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.
        • ODBC: pruebas.
        • SQL:
    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 ; 
    • Execute: On hangup.
      • ODBC: pruebas.
      • SQL:
    insert into `llamadas` values ('${start_epoch}', '${caller_id_number}', '${billsec}') ;

    When it's ok, click on Add.

  4. 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.
      • ODBC variable: check on.
        • Name: respuesta.
        • Check on expression and write bloqueo
    • Action:
      • Custom.
      • Text To Speech:
        • Language: en-EN
        • Text: You've exceeded the limit of time.

    When it's ok, click on Add.

  5. 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.
        • ODBC: pruebas.
        • SQL:
    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.

  6. To finish, we will go to create the last “Outgoing call condition”, we will configure the parameters the next way:
    • Name: llamar.
    • Priority: After pruebas2.
    • Continue: Not.
    • Conditions: Any.
    • Action:
      • Custom.
      • Bridge Local:
        • General:
          • Type: Account.
          • Destination: Domain: [Your Domain] Number: ${destination_number}
        • Scheduler:
          • Hangup: TimeOut: ${odbc_restante}

    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:

  1. 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);
  2. 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.

  3. 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: Traducción_corto-largo.
    • Priority: First.
    • Continue: Check on.
    • Conditions: Any.
    • Action:
      • Custom.
      • ODBC.
      • Execute: On start.
        • ODBC: agenda_ODBC.
        • SQL:
    select  largo  from Agenda where corto = ${destination_number};

    When it's ok, click on Add.

  4. To continue will be add a new “Outgoing call condition”, we will configure the parameters the next way:
    • Name: llamar_traduccion.
    • Priority: after Traducción_corto-largo.
    • Continue: not
    • Conditions: Custom.
      • ODBC variable: check on.
        • Name: LARGO.
        • Check on expression and write \d+
    • Action:
      • Custom.
      • bridge local:
        • General:
          • Type: Account.
          • Destination: Domain: [Your Domain] Number: ${odbc_LARGO}

    When it's ok, click on Add.

  5. 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:

  1. 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');
  2. 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.

  3. 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: Traducción_corto-largo_nombre.
    • Priority: First.
    • Continue: Check on.
    • Conditions: Any.
    • Action:
      • Custom.
      • ODBC.
      • Execute: On start.
        • ODBC: agenda_2_ODBC.
        • SQL:
    select nombre from Agenda_2 where corto = ${caller_id_number};

    When it's ok, click on Add.

  4. To continue will be add a new “Outgoing call condition”, we will configure the parameters the next way:
    • Name: mostrar_corto_y_nombre_2.
    • Priority: after Traducción_corto-largo_nombre.
    • Continue: check on.
    • Conditions: any
    • Action:
      • Custom.
      • bridge local:
        • General:
          • Type: Account.
          • Destination: Domain: [Your Domain] Number: ${destination_number}
        • Caller ID:
          • Caller ID name: ${odbc_NOMBRE}

    When it's ok, click on Add.

  5. 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:

  1. 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.

  2. 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.

  1. 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}
      • Continue; Condition: x - Busy; x - transfer: ivr @ outgoing
    • click Add
  1. Adding a rule call trigger upon hangup. Add the rule using the following parameters:
    • Name: call trigger
    • Priority: first
    • Continue: x - Continue after extension
    • Conditions: x - any
    • Action: x - custom: Execute on Hangup;
    • click Add
  1. To add a new menu action go to the page Telephony → IVR:
    1. 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.
    2. 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
      1. Set the value for the Digits, 6
      2. Set the value for the Priority, first
      3. Set the Action for the ivr menu, choose:
        • Custom
        • ODBC
        • x - Execute inline;
        • ODBC: localhost;
        • SQL: INSERT INTO `numbers` (`phone`, `account`) VALUES('${caller_id_number}', '${destination_number}');
      4. Click Add
  1. Adding a trigger:
    • Name: numbers
    • X- key : <key trigger>
  1. Adding a trigger rule that check in odbc query:
    • Name: odbc_query
    • Priority: First
    • Continue: Continue after rule
    • Conditions: x - Any
    • Action: x - Custom, odbc
      • ODBC: loalhost.
      • SQL: select * from numbers where account = '${account}' limit 1;
  1. Adding a trigger rule that to call:<WRAP>
  1. 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:

  1. In the lines table (where the configured lines are listed), click Add
  2. Set the value for the name, CM-B
  3. Set the value for the context, incoming
  4. For the gateway parameters, choose:
    • Trunk (Identify by IP)
    • Select you Local IP, 10.10.10.1
    • Domain, 10.10.20.1
  5. For the parameters parameters, choose:
    • check Template, and then default sip line
  6. Click Add

Adding the SIP trunk in CM-B

To add a SIP line go to the page Telephony → Lines:

  1. In the lines table (where the configured lines are listed), click Add
  2. Set the value for the name, CM-A
  3. Set the value for the context, incoming
  4. For the gateway parameters, choose:
    • Trunk (Identify by IP)
    • Select you Local IP, 10.10.20.1
    • Domain, 10.10.10.1
  5. For the parameters parameters, choose:
    • check Template, and then default sip line
  6. Click Add

The next steps is to configure the dialplan to allow calls between the two servers.

Configure dialplan in CM-A

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:

  1. Select the incoming context by clicking in the folder icon, near its name on the contexts table.
  2. In the extensions table (Context 'incoming': Extensions), click Add
  3. Set the Name parameter, Local calls
  4. Set the Priority parameter, first
  5. For the Conditions parameters, choose:
    • Custom
    • Destination number: x - List, set the local domain list, commsmundi.com
  6. For the actions parameters, choose:
    • Custom
    • Bridge Local
    • Type: select Account
    • Destination: set the Domain to the local domain, commsmundi.com, set the Number to ${destination_number}
  7. 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:

  1. Select the outgoing context by clicking in the folder icon, near its name on the contexts table.
  2. In the extensions table (Context 'outgoing': Extensions), click Add
  3. Set the Name parameter, Local calls in CM-B
  4. Set the Priority parameter, first
  5. For the Conditions parameters, choose:
    • Custom
    • Destination number: x - expression, set the value to, ^1(3\d{3})$
  6. For the actions parameters, choose:
    • Custom
    • Bridge custom
    • Type: select Single
    • Destination: set remote, set Line to CM-B, set the Number to ${val1}
  7. Click Add

Configure dialplan in CM-B

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:

  1. Select the incoming context by clicking in the folder icon, near its name on the contexts table.
  2. In the extensions table (Context 'incoming': Extensions), click Add
  3. Set the Name parameter, Local calls
  4. Set the Priority parameter, first
  5. For the Conditions parameters, choose:
    • Custom
    • Destination number: x - List, set the local domain list, commsmundi.com
  6. For the actions parameters, choose:
    • Custom
    • Bridge Local
    • Type: select Account
    • Destination: set the Domain to the local domain, commsmundi.com, set the Number to ${destination_number}
  7. 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:

  1. Select the outgoing context by clicking in the folder icon, near its name on the contexts table.
  2. In the extensions table (Context 'outgoing': Extensions), click Add
  3. Set the Name parameter, Local calls in CM-A
  4. Set the Priority parameter, first
  5. For the Conditions parameters, choose:
    • Custom
    • Destination number: x - expression, set the value to, ^1(3\d{3})$
  6. For the actions parameters, choose:
    • Custom
    • Bridge custom
    • Type: select Single
    • Destination: set remote, set Line to CM-A, set the Number to ${val1}
  7. Click Add

Polls in Commsmundi

How to configure a poll on the Commsmundi server

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

Transfer to avoid loops

Option 1, Rule #2

Option 2, Rule #3

Second question, Rule #4

Final, Rule #5