示例#1
0
        protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
        {
            var request = new GatherUsingAudioRequest(
                AudioUrl,
                EmptyToNull(ClientState),
                EmptyToNull(CommandId),
                InterDigitTimeoutMillis,
                InvalidAudioUrl,
                MaximumDigits,
                MaximumTries,
                MinimumDigits,
                EmptyToNull(TerminatingDigit),
                TimeoutMillis,
                EmptyToNull(ValidDigits)
                );

            var callControlId = context.GetCallControlId(CallControlId);

            try
            {
                await _telnyxClient.Calls.GatherUsingAudioAsync(callControlId, request, context.CancellationToken);

                return(Done());
            }
            catch (ApiException e)
            {
                if (await e.CallIsNoLongerActiveAsync())
                {
                    return(Outcome(TelnyxOutcomeNames.CallIsNoLongerActive));
                }

                throw new WorkflowException(e.Content ?? e.Message, e);
            }
        }
示例#2
0
        protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
        {
            var callControlIdA = context.GetCallControlId(CallControlIdA);

            var request = new BridgeCallsRequest(
                CallControlIdB,
                ClientState,
                CommandId,
                ParkAfterUnbridged
                );

            try
            {
                await _telnyxClient.Calls.BridgeCallsAsync(callControlIdA, request, context.CancellationToken);

                return(Done());
            }
            catch (ApiException e)
            {
                if (await e.CallIsNoLongerActiveAsync())
                {
                    return(Outcome(TelnyxOutcomeNames.CallIsNoLongerActive));
                }

                throw new WorkflowException(e.Content ?? e.Message, e);
            }
        }
示例#3
0
        private async ValueTask TransferCallAsync(ActivityExecutionContext context)
        {
            var request = new TransferCallRequest(
                To,
                From,
                FromDisplayName,
                AudioUrl,
                AnsweringMachineDetection,
                AnsweringMachineDetectionConfig,
                ClientState,
                TargetLegClientState,
                CommandId,
                CustomHeaders,
                SipAuthUsername,
                SipAuthPassword,
                TimeLimitSecs,
                TimeoutSecs,
                WebhookUrl,
                WebhookUrlMethod
            );

            var callControlId = context.GetCallControlId(CallControlId);

            try
            {
                await _telnyxClient.Calls.TransferCallAsync(callControlId, request, context.CancellationToken);
            }
            catch (ApiException e)
            {
                throw new WorkflowException(e.Content ?? e.Message, e);
            }
        }
示例#4
0
        protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
        {
            try
            {
                var callControlId = context.GetCallControlId(CallControlId);
                var request       = new AnswerCallRequest(BillingGroupId, ClientState, CommandId, WebhookUrl, WebhookUrlMethod);
                await _telnyxClient.Calls.AnswerCallAsync(callControlId, request, context.CancellationToken);

                return(Done());
            }
            catch (ApiException e)
            {
                if (await e.CallIsNoLongerActiveAsync())
                {
                    return(Outcome(TelnyxOutcomeNames.CallIsNoLongerActive));
                }

                throw new WorkflowException(e.Content ?? e.Message, e);
            }
        }
示例#5
0
        protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
        {
            CallBridgedPayloadA = null;
            CallBridgedPayloadB = null;

            var callControlIdA = CallControlIdA = context.GetCallControlId(CallControlIdA);
            var callControlIdB = CallControlIdB = await GetCallControlBAsync(context);

            if (callControlIdB == null)
            {
                throw new WorkflowException("Cannot bridge calls because the second leg's call control ID was not specified and no incoming activities provided this value");
            }

            CallControlIdA = callControlIdA;

            var request = new BridgeCallsRequest(
                callControlIdB,
                ClientState,
                CommandId,
                ParkAfterUnbridged
                );

            try
            {
                await _telnyxClient.Calls.BridgeCallsAsync(callControlIdA, request, context.CancellationToken);

                return(Combine(Outcome(TelnyxOutcomeNames.Bridging), Suspend()));
            }
            catch (ApiException e)
            {
                if (await e.CallIsNoLongerActiveAsync())
                {
                    return(Outcome(TelnyxOutcomeNames.CallIsNoLongerActive));
                }

                throw new WorkflowException(e.Content ?? e.Message, e);
            }
        }