Пример #1
0
        private IActivityExecutionResult ExecuteInternal(ActivityExecutionContext context)
        {
            var webhookModel = (TelnyxWebhook)context.Input !;

            if (webhookModel.Data.Payload is CallPayload callPayload)
            {
                context.WorkflowExecutionContext.CorrelationId = callPayload.CallSessionId;

                if (!context.HasCallControlId())
                {
                    context.SetCallControlId(callPayload.CallControlId);
                }

                if (callPayload is CallInitiatedPayload callInitiatedPayload)
                {
                    if (!context.HasFromNumber())
                    {
                        context.SetFromNumber(callInitiatedPayload.To);
                    }

                    context.SetCallerNumber(callInitiatedPayload.From);
                }
            }

            Model  = webhookModel;
            Output = webhookModel.Data.Payload;

            context.LogOutputProperty(this, "Webhook Payload", webhookModel);
            return(Done());
        }
        private static ValueTask <IActivityExecutionResult> ExecuteInternal(ActivityExecutionContext context)
        {
            var webhook = (TelnyxWebhook)context.Input !;

            if (webhook.Data.Payload is CallPayload callPayload)
            {
                context.WorkflowExecutionContext.CorrelationId ??= callPayload.CallSessionId;

                if (!context.HasCallControlId())
                {
                    context.SetCallControlId(callPayload.CallControlId);
                }

                if (callPayload is CallInitiatedPayload callInitiatedPayload)
                {
                    if (!context.HasFromNumber())
                    {
                        context.SetFromNumber(callInitiatedPayload.To);
                    }
                }
            }

            return(new(new CombinedResult(new OutputResult(context.Input), new DoneResult())));
        }