Notes of Asterisker. Make a duty schedule ...

    “We decided to make a FAIR distribution of incoming calls,” the management said: “Every day of the month, calls will go DIFFERENT routes to managers. We’ll schedule a month in advance. ”
    So, then once a month I will need to shovel the entire Asterisk dialplan in accordance with the established scheme. Very pleased ...
    How it worked before.

    All incoming calls are received by secretaries and transferred to managers of the type:
    exten => 555.1, Dial (SIP / 22 & SIP / 23 & SIP / 24 & SIP / 25)

    i.e. At the same time, all devices start ringing. Who first grabbed the phone - "that and slippers."
    But this scheme has ceased to like. They requested a RANDOM priority distribution. Well, no question:

    exten => 555.1, Set (variant = $ [RAND (1,5)])
    exten => 555, n, Goto (n ($ {variant})
    exten => 555, n (1), Dial (SIP / 22)
    ...


    This design lasted almost a few months and no one complained. But the sales season began to subside and ... decided to change the sequence of calls. Like Monday, first 22, then 25, then 23, etc.
    I had to resort to the design like GotoIFTime, and drop the sequence into groups by the days of the week.
    As a result, for a couple of months everything was fine.
    But now we have decided to make a schedule for each month! Well - we will simplify the procedure.

    Solution.

    To get started, I built a tablet in the MySQL database of the form: Dat (date of the month) and variant (a string listing the sequence of manager sip numbers). It turned out something like "12.10.2011" - "2324252122"
    Next, in order not to suffer, I made a view that returns an entry from this table of the current day:

    CREATE
    VIEW `view_grafik`
    AS
    SELECT variant FROM grafik_work WHERE dat = CURDATE ();
    Remaining

    trifles remained:

    exten => s, n, MYSQL (Connect uid localhost asterisk 12345678 asterisk)
    exten => s, n, MYSQL (Query result $ {uid} Select `variant` from view_grafik)
    exten => s, n, MYSQL (Fetch row $ {result} variant)
    exten => s, n, NoOp (- $ {row} - $ {variant})
    exten => s, n, MYSQL (Disconnect $ {uid})


    That is, at the output we get the sequence itself in the variable $ {variant} . Without forgetting to check for the “void” of the variable, we proceed to the call:
    exten => s, n, Set (count = 0)
    exten => s, n, While ($ [$ {count} <= 5])
    exten => s , n, Set (begin = $ [$ {count} * 2]}
    exten => s, n, Set (nomer = $ {variant: $ [$ {begin}]: 2})
    exten => s, n, Dial (SIP / $ {nomer})
    exten => s, n, Set (count = $ [$ {count} +1])
    exten => s, n, EndWhile ()


    That's it! There is still a web-interface to fill in by days of the month .
    . By the way
    faced with an interesting problem when solving note the construction:. $ {variant: $ [$ {} the begin]: 2}.
    it was originally a different type: $ {variant: $ {} the begin: 2}but ... I got this:
    232425
    2425
    25
    i.e. It seems to be correct, but the line did not consist of two digits. But only after the introduction of square quotes, everything began to work correctly.

    Also popular now: