[FunctionName("ApprovalFromManagerWorkflow")]
public static async Task Run([OrchestrationTrigger]
IDurableOrchestrationContext context)
{
    await context.CallActivityAsync("RequestApprovalFromManager", null);
    using (var timeout = new CancellationTokenSource())
    {
        DateTime dueTime = context.CurrentUtcDateTime.AddHours(72);
        Task durableTimeout = context.CreateTimer(dueTime, timeout.Token);

        Task<bool> humanInteractionEvent =
        context.WaitForExternalEvent<bool>("ManagerApprovalEvent");
        if (humanInteractionEvent ==
        await Task.WhenAny(humanInteractionEvent, durableTimeout))
        {
            timeout.Cancel();
            await context.CallActivityAsync("ProcessRequest",
            humanInteractionEvent.Result);
        }
        else
        {
            // Jeżeli nie ma zatwierdzenia lub upłynął limit czasu
            await context.CallActivityAsync("EscalateToAnotherPerson", null);
        }
    }
}
