create a variable that contains the call duration

Discussion in 'Call Flow Designer' started by luca pellegrini, Sep 19, 2017.

Thread Status:
Not open for further replies.
  1. luca pellegrini

    Joined:
    Sep 14, 2017
    Messages:
    11
    Likes Received:
    0
    I would like to use a variable to find the duration of the call and send it into an email
     
    #1 luca pellegrini, Sep 19, 2017
    Last edited: Sep 19, 2017
  2. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,078
    Likes Received:
    76
    Hi @luca pellegrini,

    In order to determine the duration of the call, you need to use a variable to store the date and time when the call started. So as soon as you receive the call, you use an "Assign a Variable" component to set a callflow/project variable, for example "callflow$.StartTicks", to "DateTime.Now.Ticks".

    Then, when the call ends and you're about to send the email, you can calculate the number of seconds using the following expression:
    DIVIDE_LONG(SUM_LONG(DateTime.Now.Ticks,NEGATIVE_LONG(callflow$.StartTicks)),10000000)

    That expression will take "DateTime.Now.Ticks" (which is the current tick counter) and will substract the start ticks. That will tell you the number of "ticks" between the start and the end of the call. Then you divide that by 10.000.000, which is the number of ticks in a second, and you get the number of seconds of the call.

    Kind regards.
    Ernesto.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    luca pellegrini likes this.
  3. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,078
    Likes Received:
    76
    Finally, in order to send it in an email message, you create the body or subject expression to include that value... If you need help with that let me know. Here you have an example on how to add a variable to the subject:
    https://www.3cx.com/docs/cfd-emails-voice-app/

    The same applies to the body...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. luca pellegrini

    Joined:
    Sep 14, 2017
    Messages:
    11
    Likes Received:
    0
    thanks edossantos!
     
    #4 luca pellegrini, Sep 20, 2017
    Last edited: Sep 20, 2017
Thread Status:
Not open for further replies.