Azure Skype呼叫机器人示例

Azure Skype呼叫机器人示例,azure,botframework,skype,Azure,Botframework,Skype,我刚刚开发了一个skype呼叫机器人的演示,遵循[SDK参考]中发布的示例。我在Azure中发布了该项目,并在skype频道的门户中注册,更新了相关页面。 如果我在Skype上与机器人聊天,一切都正常,但如果我尝试Skype通话,我会收到一条语音消息“无法与此项目通话,但我们正在处理”。 这是因为审批过程正在进行还是我遗漏了某个步骤 以下是呼叫控制器代码: using Microsoft.Bot.Builder.Calling; using Microsoft.Bot.Builder.Calli

我刚刚开发了一个skype呼叫机器人的演示,遵循[SDK参考]中发布的示例。我在Azure中发布了该项目,并在skype频道的门户中注册,更新了相关页面。 如果我在Skype上与机器人聊天,一切都正常,但如果我尝试Skype通话,我会收到一条语音消息“无法与此项目通话,但我们正在处理”。 这是因为审批过程正在进行还是我遗漏了某个步骤

以下是呼叫控制器代码:

using Microsoft.Bot.Builder.Calling;
using Microsoft.Bot.Builder.Calling.Events;
using Microsoft.Bot.Builder.Calling.ObjectModel.Contracts;
using Microsoft.Bot.Builder.Calling.ObjectModel.Misc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Web;

namespace skyva
{
    public class SimpleCallingBot : ICallingBot
    {
        public ICallingBotService CallingBotService
        {
            get; private set;
        }

        public SimpleCallingBot(ICallingBotService callingBotService)
        {
            if (callingBotService == null)
                throw new ArgumentNullException(nameof(callingBotService));
            this.CallingBotService = callingBotService;
            CallingBotService.OnIncomingCallReceived += OnIncomingCallReceived;
            CallingBotService.OnPlayPromptCompleted += OnPlayPromptCompleted;
            CallingBotService.OnRecognizeCompleted += OnRecognizeCompleted;
            CallingBotService.OnRecordCompleted += OnRecordCompleted;
            CallingBotService.OnHangupCompleted += OnHangupCompleted;
        }

        private Task OnIncomingCallReceived(IncomingCallEvent incomingCallEvent)
        {
            var id = Guid.NewGuid().ToString();
            incomingCallEvent.ResultingWorkflow.Actions = new List<ActionBase>
                {
                    new Answer { OperationId = id },
                    GetPromptForText("Hello, this is skiva, your virtual assistant on skype")
                };
            return Task.FromResult(true);
        }

        private Task OnPlayPromptCompleted(PlayPromptOutcomeEvent playPromptOutcomeEvent)
        {
            playPromptOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
            {
                CreateIvrOptions("Say yes if you want to know current weather conditions, otherwise say no", 2, false)
            };
            return Task.FromResult(true);
        }

        private Task OnRecognizeCompleted(RecognizeOutcomeEvent recognizeOutcomeEvent)
        {
            switch (recognizeOutcomeEvent.RecognizeOutcome.ChoiceOutcome.ChoiceName)
            {
                case "Yes":
                    recognizeOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
                    {
                        GetPromptForText("Current weather is sunny!"),
                        new Hangup { OperationId = Guid.NewGuid().ToString() }
                    };
                    break;
                case "No":
                    recognizeOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
                    {
                        GetPromptForText("At the moment I don't have other options. Goodbye!"),
                        new Hangup { OperationId = Guid.NewGuid().ToString() }
                    };
                    break;
                default:
                    recognizeOutcomeEvent.ResultingWorkflow.Actions = new List<ActionBase>
                    {
                        CreateIvrOptions("Say yes if you want to know weather conditions, otherwise say no", 2, false)
                    };
                    break;
            }
            return Task.FromResult(true);
        }


        private Task OnHangupCompleted(HangupOutcomeEvent hangupOutcomeEvent)
        {
            hangupOutcomeEvent.ResultingWorkflow = null;
            return Task.FromResult(true);
        }

        private static Recognize CreateIvrOptions(string textToBeRead, int numberOfOptions, bool includeBack)
        {            
            var id = Guid.NewGuid().ToString();
            var choices = new List<RecognitionOption>();
            choices.Add(new RecognitionOption
            {
                Name = "Yes",
                SpeechVariation = new List <string>() { "Yes", "Okay" }
        });
            choices.Add(new RecognitionOption
            {
                Name = "No",
                SpeechVariation = new List<string>() { "No", "None" }
            });

            var recognize = new Recognize
            {
                OperationId = id,
                PlayPrompt = GetPromptForText(textToBeRead),
                BargeInAllowed = true,
                Choices = choices
            };
            return recognize;
        }

        private static PlayPrompt GetPromptForText(string text)
        {
            var prompt = new Prompt { Value = text, Voice = VoiceGender.Male };
            return new PlayPrompt { OperationId = Guid.NewGuid().ToString(), Prompts = new List<Prompt> { prompt } };
        }
    }
}
使用Microsoft.Bot.Builder.Calling;
使用Microsoft.Bot.Builder.Calling.Events;
使用Microsoft.Bot.Builder.Calling.ObjectModel.Contracts;
使用Microsoft.Bot.Builder.Calling.ObjectModel.Misc;
使用制度;
使用System.Collections.Generic;
使用System.IO;
使用System.Threading.Tasks;
使用System.Web;
命名空间skyva
{
公共类SimpleCalingBot:iCalingBot
{
公共iCalingBotService CallingBotService
{
获得;私人设置;
}
公共SimpleCallingBot(iCalingBotService调用BotService)
{
if(callingBotService==null)
抛出新ArgumentNullException(nameof(callingBotService));
this.CallingBotService=CallingBotService;
CallingBotService.OnIncomingCallReceived+=OnIncomingCallReceived;
CallingBotService.OnPlayPromptCompleted+=OnPlayPromptCompleted;
CallingBotService.onRecograzeCompleted+=onRecograzeCompleted;
CallingBotService.OnRecordCompleted+=OnRecordCompleted;
CallingBotService.OnHangupCompleted+=OnHangupCompleted;
}
接收到OnIncomingCallReceived的私有任务(IncomingCallEvent IncomingCallEvent)
{
var id=Guid.NewGuid().ToString();
incomingCallEvent.ResultingWorkflow.Actions=新列表
{
新答案{OperationId=id},
GetPromptForText(“您好,我是skiva,您在skype上的虚拟助理”)
};
返回Task.FromResult(true);
}
PlayPromptEvent上的私有任务已完成(PlayPromptOutComEvent PlayPromptOutComEvent)
{
playPromptOutcomeEvent.ResultingWorkflow.Actions=新列表
{
CreateIvrOptions(“如果你想知道当前的天气状况,就说是,否则就说不”,2,false)
};
返回Task.FromResult(true);
}
OnRecognizeCompleted的私人任务(RecognizeOutcomeEvent RecognizeOutcomeEvent)
{
开关(recognizeOutcomeEvent.RecognizeOutcome.ChoiceOutcome.ChoiceName)
{
案例“是”:
recognizeOutcomeEvent.ResultingWorkflow.Actions=新列表
{
GetPromptForText(“当前天气晴朗!”),
新挂起{OperationId=Guid.NewGuid().ToString()}
};
打破
案例“否”:
recognizeOutcomeEvent.ResultingWorkflow.Actions=新列表
{
GetPromptForText(“目前我没有其他选择。再见!”),
新挂起{OperationId=Guid.NewGuid().ToString()}
};
打破
违约:
recognizeOutcomeEvent.ResultingWorkflow.Actions=新列表
{
CreateIvrOptions(“如果你想知道天气情况,就说是,否则就说不”,2,false)
};
打破
}
返回Task.FromResult(true);
}
挂起时的私人任务已完成(挂起事件挂起事件)
{
hangupOutcomeEvent.ResultingWorkflow=null;
返回Task.FromResult(true);
}
私有静态识别CreateIvrOptions(字符串textToBeRead、int numberOfOptions、bool includeBack)
{            
var id=Guid.NewGuid().ToString();
var choices=新列表();
选项。添加(新识别选项)
{
Name=“是”,
SpeechVariation=新列表(){“是”、“好”}
});
选项。添加(新识别选项)
{
Name=“否”,
SpeechVariation=新列表(){“否”,“无”}
});
var识别=新识别
{
操作id=id,
PlayPrompt=GetPromptForText(textToBeRead),
BargeInAllowed=正确,
选择=选择
};
回归认识;
}
专用静态播放提示GetPromptForText(字符串文本)
{
var prompt=new prompt{Value=text,Voice=VoiceGender.Male};
返回新的播放提示{OperationId=Guid.NewGuid().ToString(),提示=newlist{prompt};
}
}
}

根据您的评论,我认为问题在于您在启用Skype频道时使用的URL。根据您的URL,在Bot框架的Skype设置中配置的调用WebHook URL应为

您的
呼叫控制器
应该如下所示:

[BotAuthentication]
[RoutePrefix("api/calling")]
public class CallingController : ApiController
{
    public CallingController() : base()
    {
        CallingConversation.RegisterCallingBot(callingBotService => new SimpleCallingBot(callingBotService));
    }

    [Route("callback")]
    public async Task<HttpResponseMessage> ProcessCallingEventAsync()
    {
        return await CallingConversation.SendAsync(this.Request, CallRequestType.CallingEvent);
    }

    [Route("call")]
    public async Task<HttpResponseMessage> ProcessIncomingCallAsync()
    {
        return await CallingConversation.SendAsync(this.Request, CallRequestType.IncomingCall);
    }
}
[BotAuthentication]
[RoutePrefix(“api/调用”)]
公共类调用控制器:ApiController
{
public CallingController():base()
{
CallingConversation.RegisterCallingBot(callingBotService=>new SimpleCallingBot(callingBotService));
}
[路由(“回调”)]
公共异步任务进程CallingEventAsync()
{
返回wait CallingConversation.sendaync(this.Request,CallRequestType.CallingEvent);
}
[路线(“呼叫”)]
公共异步任务进程IncomingCallAsync()
{
返回wait CallingConversation.sendaync(this.Request,CallRequestType.IncomingCall);
}
}
我在年解决了这个问题