Time Based Routing with CFD

Discussion in 'Call Flow Designer' started by Alex Howard, May 30, 2017.

Thread Status:
Not open for further replies.
  1. Alex Howard

    Joined:
    Apr 18, 2017
    Messages:
    17
    Likes Received:
    1
    I want to create a simple Call flow that transfers calls based on the time of day. I cannot figure out how to get the current time from the phone system. I found some old posts the indicated simply assigning a variable with an initial value or GETTIME() would work, but I just get an error.

    Are there ant helpfull tutorials for this or examples? It seems like the most basic and common use for CFD

    Thanks
     
  2. Alex Howard

    Joined:
    Apr 18, 2017
    Messages:
    17
    Likes Received:
    1
    I believe DateTime.Now works to get the current time, (at least the build does not error out)
    but now I need to compare it to a range for business hours. Has anyone done this before?

    Thanks
     
  3. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    Hi @Alex Howard,

    In order to do that, you need to use a "Create a condition" component. This component has as many branches as you need, and each branch has a Condition, which needs to be true in order to execute the components inside that branch. So, for example, if you want to transfer to a specific extension from 9 to 12, and then to a different extension from 12 to 18, you need to configure the conditional component with 2 branches, and set the first condition to:
    DateTime.Now.Hour >= 9 && DateTime.Now.Hour < 12

    And the second condition to:
    DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18

    Then, inside each branch of the "Create a condition" component, you add a "Transfer" component to transfer the call to the destination for that specific time range.

    Hope the information helps.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    jed likes this.
  4. Thomas Six

    Joined:
    May 31, 2017
    Messages:
    8
    Likes Received:
    0
    Hello edossantos

    I've tried the condition DateTime.Now.Hour >= 9 but it is not working. Are you sure the syntax is correct?

    Regards,

    Thomas
     
  5. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Thomas Six

    Joined:
    May 31, 2017
    Messages:
    8
    Likes Received:
    0
    1. Hello

      I have found the solution. When you want to check if it is saterday or Sunday, this is the Condition: new Date().getDay() == 6 || new Date().getDay() ==0 . Sunday is 0 and saterday 6. When you want to check if it is 12 o'clock : new Date().getHours() == 12.

      For other time values: https://www.w3schools.com/js/js_date_methods.asp

      Regards,

      Thomas
     
  7. Thomas Six

    Joined:
    May 31, 2017
    Messages:
    8
    Likes Received:
    0
    Hello Edossantos

    We use VAD V14 and our projects are .vadproj. The one you send to us is a .cfdproj. Is this another VAD version?

    regards,

    Thomas
     
  8. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    Yes, that was a misunderstanding. At the beginning of the thread you mentioned the CFD, so I thought you were using the new CFD for 3CX v15.5. In this new version we don't use javascript anymore, we use C#. Your solution is the way to go in v14.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Alex Howard

    Joined:
    Apr 18, 2017
    Messages:
    17
    Likes Received:
    1
    Hi Ernesto,

    Thanks for the solution, I am indeed using the new CFD. Is there are way to do this but with half hours or minutes? If we want to open for business at 5:30am for instance,

    Thanks
    Alex
     
  10. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    Hi Alex,

    Sure, you need to include the value of "DateTime.Now.Minute" to your expression. That will tell you the current minute, so if you want to check if the current time is between 8:30am and 5:30pm you can use this expression:
    Code:
    (DateTime.Now.Hour == 8 && DateTime.Now.Minute >= 30) || (DateTime.Now.Hour > 8 && DateTime.Now.Hour < 17) || (DateTime.Now.Hour == 17 && DateTime.Now.Minute < 30)
    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. b2b

    b2b

    Joined:
    Jan 11, 2011
    Messages:
    3
    Likes Received:
    0
    Edissantos,

    For example, if I want a rule for a day, Monday morning form 7:00 to 8:30, is this the option?

    new Date().getDay() == 1 || DateTime.Now.Hour >= 7 && DateTime.Now.Minute >= 00) || DateTime.Now.Hour < 8 && DateTime.Now.Minute <= 30)
     
  12. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    Hi @b2b,

    You're mixing javascript and C# there. The correct expression is this:
    DateTime.Now.DayOfWeek == DayOfWeek.Monday && (DateTime.Now.Hour == 7 || (DateTime.Now.Hour == 8 && DateTime.Now.Minute <= 30))

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. b2b

    b2b

    Joined:
    Jan 11, 2011
    Messages:
    3
    Likes Received:
    0
    Edossantos,

    Thank you...
    But I have one more rule whether this is good or not:
    Monday from 17:30 to 19:00
    DateTime.Now.DayOfWeek == DayOfWeek.Monday && (DateTime.Now.Hour == 17 && DateTime.Now.Minute <= 30 || (DateTime.Now.Hour == 19))
     
  14. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    The right expression for that would be:
    DateTime.Now.DayOfWeek == DayOfWeek.Monday && (DateTime.Now.Hour == 17 && DateTime.Now.Minute >= 30 || DateTime.Now.Hour == 18)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. b2b

    b2b

    Joined:
    Jan 11, 2011
    Messages:
    3
    Likes Received:
    0
    Dear Edossantos,

    Why 18 and not 19
     
  16. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,260
    Likes Received:
    97
    Because between 18:00 and 18:59, the hour is 18.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. docs5000

    Joined:
    Jul 13, 2017
    Messages:
    2
    Likes Received:
    0
    Sorry to revive a dead thread, but how would i structure the the first condition to check to see if it is between 8AM and 12:30PM or 1:30 and 5PM? And then have the second condition look to see if its between 12:30 and 1:30?
     
  18. SECOIT GmbH

    Joined:
    Apr 3, 2017
    Messages:
    64
    Likes Received:
    19
    1. 8:00 - 12:30:
    (DateTime.Now.Hour >= 8 && DateTime.Now.Hour < 12) || (DateTime.Now.Minute < 30 && DateTime.Now.Hour == 12)

    2. 12:30 - 13:30:
    (DateTime.Now.Hour == 12 && DateTime.Now.Minute >= 30) || (DateTime.Now.Minute < 30 && DateTime.Now.Hour == 13)

    3. 13:30 - 17:00:
    (DateTime.Now.Minute >= 30 && DateTime.Now.Hour == 13) || (DateTime.Now.Hour >= 14 && DateTime.Now.Hour <= 17)

    That should do it...

    Best Regards
    Michael
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    edossantos likes this.
  19. docs5000

    Joined:
    Jul 13, 2017
    Messages:
    2
    Likes Received:
    0
    That did the trick. I don't really understand it, but it works.
     
Thread Status:
Not open for further replies.