Skip to content

Commit 6ef4b0c

Browse files
authored
Merge pull request #981 from hchen2020/master
OnCallBusyStatus
2 parents 8c93870 + 752ffb8 commit 6ef4b0c

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ await HookEmitter.Emit<ITwilioCallStatusHook>(_services, async hook =>
348348
await HookEmitter.Emit<ITwilioCallStatusHook>(_services, x => x.OnUserDisconnected(request));
349349
}
350350
}
351+
else if (request.CallStatus == "busy")
352+
{
353+
await HookEmitter.Emit<ITwilioCallStatusHook>(_services, x => x.OnCallBusyStatus(request));
354+
}
351355

352356
return Ok();
353357
}

src/Plugins/BotSharp.Plugin.Twilio/Interfaces/ITwilioCallStatusHook.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ public interface ITwilioCallStatusHook
1010
Task OnRecordingCompleted(ConversationalVoiceRequest request);
1111
Task OnTranscribeCompleted(ConversationalVoiceRequest request);
1212
Task OnVoicemailStarting(ConversationalVoiceRequest request);
13+
14+
/// <summary>
15+
/// 1. The recipient's phone line is already engaged.
16+
/// 2. Some users block unknown or spam calls, which may cause a "busy" status.
17+
/// 3. Some carriers explicitly return a busy signal instead of routing the call to voicemail.
18+
/// </summary>
19+
/// <param name="request"></param>
20+
/// <returns></returns>
21+
Task OnCallBusyStatus(ConversationalVoiceRequest request);
1322
}

src/Plugins/BotSharp.Plugin.Twilio/Models/ConversationalVoiceRequest.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ public class ConversationalVoiceRequest : VoiceRequest
3939
[FromForm]
4040
public int MachineDetectionDuration { get; set; }
4141

42-
[FromForm]
43-
public int Duration { get; set; }
44-
4542
[FromForm]
4643
public int CallDuration { get; set; }
4744

src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/OutboundPhoneCallFn.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,25 @@ private async Task ForkConversation(LlmContextIn args,
145145
Title = args.InitialMessage
146146
});
147147

148+
var messageId = Guid.NewGuid().ToString();
148149
convStorage.Append(newConversationId, new List<RoleDialogModel>
149150
{
150151
new RoleDialogModel(AgentRole.User, "Hi")
151152
{
153+
MessageId = messageId,
152154
CurrentAgentId = entryAgentId
153155
},
154156
new RoleDialogModel(AgentRole.Assistant, args.InitialMessage)
155157
{
158+
MessageId = messageId,
156159
CurrentAgentId = entryAgentId
157160
}
158161
});
159162

160163
convService.SetConversationId(newConversationId,
161164
[
162165
new MessageState(StateConst.ORIGIN_CONVERSATION_ID, originConversationId),
166+
new MessageState("channel", "phone"),
163167
new MessageState("phone_from", call.From),
164168
new MessageState("phone_direction", call.Direction),
165169
new MessageState("phone_number", call.To),

0 commit comments

Comments
 (0)