C# 在Azure上测试Echo聊天机器人时出错

C# 在Azure上测试Echo聊天机器人时出错,c#,azure,chatbot,azure-bot-service,C#,Azure,Chatbot,Azure Bot Service,我在跟踪 在创建python聊天机器人时,我的源代码如下所示,但是当我尝试运行它时,我得到了一个错误。根据存储库,错误是适配器的on_错误处理程序接收bot的turn逻辑引发的任何异常。如果抛出异常,处理程序将删除当前会话的会话状态,以防止bot因处于错误状态而陷入错误循环。有专家能帮忙吗 using System.Collections.Generic; using System.Threading;

我在跟踪 在创建python聊天机器人时,我的源代码如下所示,但是当我尝试运行它时,我得到了一个错误。根据存储库,错误是适配器的on_错误处理程序接收bot的turn逻辑引发的任何异常。如果抛出异常,处理程序将删除当前会话的会话状态,以防止bot因处于错误状态而陷入错误循环。有专家能帮忙吗

       using System.Collections.Generic;                 
       using System.Threading;           
       using System.Threading.Tasks;          
       using Microsoft.Bot.Builder;          
       using Microsoft.Bot.Schema;          
       using System.Net;       
       using System;         
       using System.Net.Http;          
       using System.Text;  // for class Encoding         
       using System.IO;               
       using Newtonsoft.Json;                 
       using Newtonsoft.Json.Serialization;     
            

       namespace Microsoft.BotBuilderSamples.Bots
       {
           public class EchoBot : ActivityHandler
           {
               public class FlaskRequestModel
               {
                   [JsonProperty("text")]
                   public string Text {get; set;}            
        
               }

               protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity>                       turnContext, CancellationToken cancellationToken)
               {           
                   var replyText = $"{turnContext.Activity.Text}";
                   //if (!replyText.ToLower().Contains("Hey Bot")){  # Optional bit of code that only sends the sends the message to the back end if it contains a particular keyword
                   //    return;
                   //}
                   var replyTextModel = new FlaskRequestModel()
                   {
                       Text = replyText 
                   };

                   var jsonObject = JsonConvert.SerializeObject(replyTextModel);
    
                   var request = new HttpRequestMessage()
                   {

                       Content = new StringContent(jsonObject, Encoding.UTF8, "application/json"),
                       Method = HttpMethod.Post,
                       RequestUri = new Uri("yudao.azurewebsites.net"),   //  <- Replace the URL with the the URL for your function app
                   };            
    
                   var httpClient = new HttpClient();
                   // httpClient.DefaultRequestHeaders.Add("API-Key","your API-key");  <- required if your HTTP trigger authorization was set to something other than Anonymous
                   var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);      
    
                   if (response.IsSuccessStatusCode)
                   {
                       var responseString = await response.Content.ReadAsStringAsync();
                       await turnContext.SendActivityAsync(MessageFactory.Text(responseString, responseString), cancellationToken);
                   }
                   else
                   {
                       await turnContext.SendActivityAsync(MessageFactory.Text("failure", "failure"), cancellationToken);
                       var responseString = await response.Content.ReadAsStringAsync();
                       await turnContext.SendActivityAsync(MessageFactory.Text(responseString, responseString), cancellationToken);   
                   }
    
               }
           }    
       }
使用System.Collections.Generic;
使用系统线程;
使用System.Threading.Tasks;
使用Microsoft.Bot.Builder;
使用Microsoft.Bot.Schema;
Net系统;
使用制度;
使用System.Net.Http;
使用System.Text;//用于类编码
使用System.IO;
使用Newtonsoft.Json;
使用Newtonsoft.Json.Serialization;
命名空间Microsoft.BotBuilderSamples.Bots
{
公共类EchoBot:ActivityHandler
{
公共级烧瓶模型
{
[JsonProperty(“文本”)]
公共字符串文本{get;set;}
}
受保护的重写异步任务OnMessageActivityAsync(ITurnContext turnContext,CancellationToken CancellationToken)
{           
var replyText=$“{turnContext.Activity.Text}”;
//如果(!replyText.ToLower()。包含(“Hey Bot”){#可选代码位,该代码位仅发送消息,如果消息包含特定关键字,则将消息发送到后端
//返回;
//}
var replyTextModel=new FlaskRequestModel()
{
Text=replyText
};
var jsonObject=JsonConvert.SerializeObject(replyTextModel);
var request=newhttprequestmessage()
{
Content=newstringcontent(jsonObject,Encoding.UTF8,“application/json”),
方法=HttpMethod.Post,
RequestUri=newuri(“yudao.azurewebsites.net”),//使用正则表达式尝试以下操作:

A2 = "12 15|||Pform|||their|||REQUIRED|||-NONE-|||0"
intval=[val for val in A2.split('|||') if bool(re.search(pattern='\d+', string=val))]
输出:

['12 15', '0']

什么是错误
parts=s.split(“| | |”)
/
p1,p2=[int(k)表示部分[0]中的k。split()]