Skip to content

OnCallBusyStatus #981

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

Merged
merged 4 commits into from
Apr 1, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ await HookEmitter.Emit<ITwilioCallStatusHook>(_services, async hook =>
await HookEmitter.Emit<ITwilioCallStatusHook>(_services, x => x.OnUserDisconnected(request));
}
}
else if (request.CallStatus == "busy")
{
await HookEmitter.Emit<ITwilioCallStatusHook>(_services, x => x.OnCallBusyStatus(request));
}

return Ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ public interface ITwilioCallStatusHook
Task OnRecordingCompleted(ConversationalVoiceRequest request);
Task OnTranscribeCompleted(ConversationalVoiceRequest request);
Task OnVoicemailStarting(ConversationalVoiceRequest request);

/// <summary>
/// 1. The recipient's phone line is already engaged.
/// 2. Some users block unknown or spam calls, which may cause a "busy" status.
/// 3. Some carriers explicitly return a busy signal instead of routing the call to voicemail.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task OnCallBusyStatus(ConversationalVoiceRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public class ConversationalVoiceRequest : VoiceRequest
[FromForm]
public int MachineDetectionDuration { get; set; }

[FromForm]
public int Duration { get; set; }

[FromForm]
public int CallDuration { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,25 @@ private async Task ForkConversation(LlmContextIn args,
Title = args.InitialMessage
});

var messageId = Guid.NewGuid().ToString();
convStorage.Append(newConversationId, new List<RoleDialogModel>
{
new RoleDialogModel(AgentRole.User, "Hi")
{
MessageId = messageId,
CurrentAgentId = entryAgentId
},
new RoleDialogModel(AgentRole.Assistant, args.InitialMessage)
{
MessageId = messageId,
CurrentAgentId = entryAgentId
}
});

convService.SetConversationId(newConversationId,
[
new MessageState(StateConst.ORIGIN_CONVERSATION_ID, originConversationId),
new MessageState("channel", "phone"),
new MessageState("phone_from", call.From),
new MessageState("phone_direction", call.Direction),
new MessageState("phone_number", call.To),
Expand Down
Loading