How to get call duration?

Droid1

New member
I am struggling to get the call duration after a call is ended. I need to log the incoming call when it ends to remote webhook.
 

Jacob L

Moderator (Lawsonator)
Trigger: call incoming
Call ended

Loop( while trigger not fired, call ended)[
Actions: set variable +1
Wait before next action 1 second
]
Dialog [variable_name]
 

RSF

Well-known member
As an alternative, if you don't want to use loops:
Screenshot_20230618-172214.png

You'd want to capture caller info and add your webhook logic etc. of course. Note that this won't log calls that you don't answer, I don't think ... unless the Call Ended trigger occurs for those as well.
 

Droid1

New member
Trigger: call incoming
Call ended

Loop( while trigger not fired, call ended)[
Actions: set variable +1
Wait before next action 1 second
]
Dialog [variable_name]
Trigger: call incoming
Call ended

Loop( while trigger not fired, call ended)[
Actions: set variable +1
Wait before next action 1 second
]
Dialog [variable_name]
This is failing see attached:
 

Attachments

  • 7103fc9e-ab80-4d76-b497-c56a3130c15e.jpeg
    7103fc9e-ab80-4d76-b497-c56a3130c15e.jpeg
    54.9 KB · Views: 3

Droid1

New member
As an alternative, if you don't want to use loops:
View attachment 5833

You'd want to capture caller info and add your webhook logic etc. of course. Note that this won't log calls that you don't answer, I don't think ... unless the Call Ended trigger occurs for those as well.
Will try this. Any issues with using loops? Also, what is a good method to log call date and time?
 

RSF

Well-known member
Any issues with using loops?
In general, nothing; many times, they're essential.

what is a good method to log call date and time?
MacroDroid has a handy user-log action (Logging / Log Event) --
Screenshot 2023-06-19 6.45.28 AM.png
-- that writes to the log visible by tapping "User Log" on the home page. That's easy but note that if you use the action across multiple macros, everything gets logged together in the single log (although you can export/share it to a file, and use a text editor to search it).
There's also the Write to File action (Files / Write to File), where you can append info to a file you choose.
 

Droid1

New member
In general, nothing; many times, they're essential.


MacroDroid has a handy user-log action (Logging / Log Event) --
View attachment 5835
-- that writes to the log visible by tapping "User Log" on the home page. That's easy but note that if you use the action across multiple macros, everything gets logged together in the single log (although you can export/share it to a file, and use a text editor to search it).
There's also the Write to File action (Files / Write to File), where you can append info to a file you choose.
I meant store phone call date and time.
 

RSF

Well-known member
Oh. The Log Event action automatically date/time-stamps each entry. With other actions like Write to File, you can use the "..." button to add various system info like date, time, etc.:

Screenshot 2023-06-19 8.44.35 AM.png

then
Screenshot 2023-06-19 8.45.15 AM.png

You'll have to string a few of these together to get e.g. mm/dd/yyyy hh:mm, which works fine. Just keep tapping the "..." button and add to the string. The "..." scheme is pervasive throughout MacroDroid.
 
Top