title: Waiting for external events in Durable Functions
body: <p>I have an Orchestrator function as follows:</p>
  <pre><code>[FunctionName(&quot;O_OrchestratorFunction)]
          public async Task&lt;object&gt; Process(
              [OrchestrationTrigger] IDurableOrchestrationContext context,
              ILogger log)
          {
              await context.CallActivityAsync(&quot;A_SendApprovalRequestEmail&quot;, &quot;email&quot;);
  
              var _approvalResult = await context.WaitForExternalEvent&lt;string&gt;(&quot;ApprovalResult&quot;);
  
              if (_approvalResult == &quot;Approved&quot;)
              {
                  await context.CallActivityAsync(&quot;A_ResumeJobSync&quot;, &quot;email&quot;);
              }
              else
              {
                  await context.CallActivityAsync(&quot;A_PauseJobSync&quot;, &quot;email&quot;);
              }
              return _approvalResult;
          }
      }
  </code></pre>
  <p>Here is my A_SendApprovalRequestEmail Activiy function:</p>
  <pre><code>    [FunctionName(&quot;A_SendApprovalRequestEmail&quot;)]
      public async Task Run([ActivityTrigger] string job, TraceWriter log)
      {
              var functionAddress = $&quot;http://localhost:7071/api/&quot;;
              var approvedLink = functionAddress + &quot;approve?id=MYID&quot;;
              var rejectedLink = functionAddress + &quot;reject?id=MYID&quot;;
              var content = $&quot;{approvedLink}  {rejectedLink}&quot;;
              await _mailRepository.SendMail(&quot;Subject&quot;, content, &quot;&lt;recipient-address&gt;&quot;);
              log.Info($&quot;Requesting approval for {job}&quot;);
              await Task.Delay(1000);
      }
  </code></pre>
  <p>How do I modify this code to connect 2 links to the orchestrator - one for Approve and one for Reject (that returns the result ‘Approved’ or ‘Rejected’)?</p>
  <p>UPDATE:</p>
  <p>I have added 2 starter functions:</p>
  <pre><code>        [FunctionName(&quot;Approve&quot;)]
          public static async Task&lt;IActionResult&gt; Approve(
          [HttpTrigger(AuthorizationLevel.Anonymous, &quot;get&quot;, Route = null)]
          HttpRequest req,
          ILogger log,
          [DurableClient] IDurableOrchestrationClient client)
          {
              string orchestratorId = req.Query[&quot;id&quot;];                 
              log.LogInformation($&quot;Approval request for {orchestratorId}&quot;); 
              var status = await client.GetStatusAsync(orchestratorId);
              if (status == null || status.RuntimeStatus != OrchestrationRuntimeStatus.Running)
                  return new NotFoundResult();
  
              await client.RaiseEventAsync(orchestratorId, &quot;ApprovalResult&quot;, &quot;Approve&quot;);
  
              return new OkObjectResult(&quot;Approval successfull&quot;);
          }
  
          [FunctionName(&quot;Reject&quot;)]
          public static async Task&lt;IActionResult&gt; Reject(
             [HttpTrigger(AuthorizationLevel.Anonymous, &quot;get&quot;, Route = null)]
              HttpRequest req,
              ILogger log,
             [DurableClient] IDurableOrchestrationClient client)
          {
              string orchestratorId = req.Query[&quot;id&quot;];
  
              log.LogInformation($&quot;Reject request for {orchestratorId}&quot;);
  
              var status = await client.GetStatusAsync(orchestratorId);
  
              if (status == null || status.RuntimeStatus != OrchestrationRuntimeStatus.Running)
                  return new NotFoundResult();
  
  
              await client.RaiseEventAsync(orchestratorId, &quot;ApprovalResult&quot;, &quot;Reject&quot;);
  
              return new OkObjectResult(&quot;Rejected&quot;);
          }
  </code></pre>
  <p>This is what I see on clicking Approve/Reject link:</p>
  <p><a href="https://i.stack.imgur.com/ipb52.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ipb52.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/85cVY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/85cVY.png" alt="enter image description here" /></a></p>
  <p>On putting breakpoint at</p>
  <pre><code>var status = await client.GetStatusAsync(orchestratorId);
  </code></pre>
  <p>I see status as null.</p>