Microsoft Bot Framework通过键入“重置”无法在Azure中工作来重置Bot

时间:2018-06-21 20:08:48

标签: c# botframework

我有一个简单的漫游器,这样,当用户键入单词“ reset”并发送给漫游器时,漫游器会自行重置。 我在这里有一个代码,但是它可以在Localhost Emulator中使用,但是当我发布到Azure时,它不起作用?

我在哪里错了?

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
    if (activity.Type == ActivityTypes.Message)
    {
        //if the user types certain messages, quit all dialogs and start over
        string msg = activity.Text.ToLower().Trim();
        if (msg == "start over" || msg == "exit" || msg == "quit" || msg == "done" || msg == "start again" || msg == "restart" || msg == "leave" || msg == "reset")
        {
            //    //This is where the conversation gets reset!
            await activity.GetStateClient().BotState
                        .DeleteStateForUserWithHttpMessagesAsync(activity.ChannelId, activity.From.Id);

        var client = new ConnectorClient(new Uri(activity.ServiceUrl));
        var clearMsg = activity.CreateReply();

        clearMsg.Text = $"Lets star";
        await client.Conversations.SendToConversationAsync(clearMsg);
            await Conversation.SendAsync(activity, () => new BookRoom());


        }
        else
        {
            //ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
            //Activity reply = activity.CreateReply();
            //reply.Type = ActivityTypes.Typing;
            //reply.Text = null;
            //await connector.Conversations.ReplyToActivityAsync(reply);
            //and even if we reset everything, show the welcome message again
            //  BotUtils.SendTyping(activity); //send "typing" indicator upon each message received
            await Conversation.SendAsync(activity, () => new BookRoom());
        }


        //await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
    }
    else
    {
        HandleSystemMessage(activity);
    }
    var response = Request.CreateResponse(HttpStatusCode.OK);
    return response;
}

任何帮助,我将不胜感激。

0 个答案:

没有答案