Skip to content

V balajium/call automation gcch test for dailog #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Call_Automation_GCCH/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore all bin and obj folders (C# projects)
bin/
obj/

# Ignore user-specific Visual Studio files
.vscode/
*.user
*.suo

# Ignore compiled code
*.dll
*.exe

# Ignore log files
*.log

# Ignore environment-specific files
.env
22 changes: 22 additions & 0 deletions Call_Automation_GCCH/Call_Automation_GCCH.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35728.132 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Call_Automation_GCCH", "Call_Automation_GCCH\Call_Automation_GCCH.csproj", "{1094CA30-3CC4-4B93-92D4-0F313B241B3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1094CA30-3CC4-4B93-92D4-0F313B241B3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1094CA30-3CC4-4B93-92D4-0F313B241B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1094CA30-3CC4-4B93-92D4-0F313B241B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1094CA30-3CC4-4B93-92D4-0F313B241B3F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Communication.CallAutomation" Version="1.4.0-alpha.20250408.1" />
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.16.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions Call_Automation_GCCH/Call_Automation_GCCH/ConfigurationRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Call_Automation_GCCH
{
public class ConfigurationRequest
{
public string AcsConnectionString { get; set; } = string.Empty;
public string AcsPhoneNumber { get; set; } = string.Empty;
public string CongnitiveServiceEndpoint { get; set; } = string.Empty;
public string CallbackUriHost { get; set; } = string.Empty;
public Dictionary<string, string> BotRouting { get; set; } = new();
public string DefaultBotId { get; set; } = string.Empty;
}
}
100 changes: 100 additions & 0 deletions Call_Automation_GCCH/Call_Automation_GCCH/Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using Azure.Communication.CallAutomation;
using System.Net.WebSockets;
using System.Text;
using System.Text.Json;

namespace Call_Automation_GCCH
{
public static class Helper
{
public static async Task ProcessRequest(WebSocket webSocket)
{
try
{
var buffer = new byte[1024 * 4];
var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(60)).Token;
WebSocketReceiveResult receiveResult = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), cancellationToken);

while (!receiveResult.CloseStatus.HasValue)
{
string msg = Encoding.UTF8.GetString(buffer, 0, receiveResult.Count);

var response = StreamingData.Parse(msg);

if (response != null)
{
if (response is AudioMetadata audioMetadata)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("MEDIA SUBSCRIPTION ID-->" + audioMetadata.MediaSubscriptionId);
Console.WriteLine("ENCODING-->" + audioMetadata.Encoding);
Console.WriteLine("SAMPLE RATE-->" + audioMetadata.SampleRate);
Console.WriteLine("CHANNELS-->" + audioMetadata.Channels);
Console.WriteLine("LENGTH-->" + audioMetadata.Length);
Console.WriteLine("***************************************************************************************");
}
if (response is AudioData audioData)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("DATA-->" + JsonSerializer.Serialize(audioData.Data));
Console.WriteLine("TIMESTAMP-->" + audioData.Timestamp);
Console.WriteLine("IS SILENT-->" + audioData.IsSilent);
if (audioData.Participant != null && audioData.Participant.RawId != null)
{
Console.WriteLine("Participant Id-->" + audioData.Participant.RawId);
}

Console.WriteLine("***************************************************************************************");
}

if (response is TranscriptionMetadata transcriptionMetadata)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("TRANSCRIPTION SUBSCRIPTION ID-->" + transcriptionMetadata.TranscriptionSubscriptionId);
Console.WriteLine("LOCALE-->" + transcriptionMetadata.Locale);
Console.WriteLine("CALL CONNECTION ID--?" + transcriptionMetadata.CallConnectionId);
Console.WriteLine("CORRELATION ID-->" + transcriptionMetadata.CorrelationId);
Console.WriteLine("***************************************************************************************");
}
if (response is TranscriptionData transcriptionData)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("TEXT-->" + transcriptionData.Text);
Console.WriteLine("FORMAT-->" + transcriptionData.Format);
Console.WriteLine("OFFSET-->" + transcriptionData.Offset);
Console.WriteLine("DURATION-->" + transcriptionData.Duration);
Console.WriteLine("PARTICIPANT-->" + transcriptionData.Participant.RawId);
Console.WriteLine("CONFIDENCE-->" + transcriptionData.Confidence);
//Console.WriteLine("RESULT STATUS-->" + transcriptionData.ResultStatus);
foreach (var word in transcriptionData.Words)
{
Console.WriteLine("WORDS TEXT-->" + word.Text);
Console.WriteLine("WORDS OFFSET-->" + word.Offset);
Console.WriteLine("WORDS DURATION-->" + word.Duration);
}
Console.WriteLine("***************************************************************************************");
}
}

await webSocket.SendAsync(
new ArraySegment<byte>(buffer, 0, receiveResult.Count),
receiveResult.MessageType,
receiveResult.EndOfMessage,
CancellationToken.None);

receiveResult = await webSocket.ReceiveAsync(
new ArraySegment<byte>(buffer), CancellationToken.None);
}

await webSocket.CloseAsync(receiveResult.CloseStatus.Value, receiveResult.CloseStatusDescription, CancellationToken.None);
}
catch (Exception ex)
{
Console.WriteLine($"Exception -> {ex}");
}
finally
{
}
}
}
}
16 changes: 16 additions & 0 deletions Call_Automation_GCCH/Call_Automation_GCCH/InstructionToDeploy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Install Git Bash

Open Git Bash

Navigate to deployment file location

<Drive>:/<Drive>/Call_Automation_GCCH/Call_Automation_GCCH

Execute following command to create executable.
chmod +x gcchDeploy.sh

Execute following command to deploy
./gcchDeploy.sh

https://<app-name>.scm.azurewebsites.net/swagger/index.html

Loading