This is an old revision of the document!


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:
  • Name: llamar_normal.
  • Priority: after llamar_traduccion.
  • Continue: not
  • Conditions: Any.
  • Action:
    • Custom.
    • bridge local:
      • General:
        • Type: Account.
        • Destination: Domain: [Your Domain] Number: ${destination_number}

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:
  • Name: llamar_traduccion.
  • Priority: after mostrar_corto_y_nombre_2.
  • 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.

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

  • 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: Fina
  • 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}.
/home/www/wiki/data/attic/configuration/telephony/examples.1558610613.txt.gz · Last modified: 2019/05/23 13:23 by jgil
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki