You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Microsoft Bot Builder聊天机器人报错:Bot State API已弃用,如何配置排查?

Hey there, let's break down this Bot Builder issue clearly for you:

Bot State API Deprecation Error: Causes, Fixes, and Local Storage Context

What's Triggering This Error?

  • Microsoft has officially retired the Bot State API—this was a cloud-hosted service that used to handle bot state storage by default. If your bot is still relying on this old API to save user conversations, session data, or bot state, you'll get this deprecation warning because the service no longer operates.
  • This isn't inherently a "local storage problem," but it does require you to implement your own storage solution (which can be local or cloud-based, depending on your use case).

Step-by-Step Configuration Fixes

You need to replace the deprecated API with a custom storage adapter. Here are the most common approaches:

1. Local Storage (For Development/Testing)

Perfect for quick local testing since it's easy to set up:

  • First, install the required package:
    npm install botbuilder --save
    # For .NET, use NuGet: Install-Package Microsoft.Bot.Builder
    
  • Then, update your bot code to use local memory storage instead of the deprecated API:
    // Node.js example
    const { BotFrameworkAdapter, MemoryStorage, ConversationState, UserState } = require('botbuilder');
    
    // Initialize local memory storage
    const memoryStorage = new MemoryStorage();
    
    // Create state managers using the local storage
    const conversationState = new ConversationState(memoryStorage);
    const userState = new UserState(memoryStorage);
    
    // Attach state managers to your bot adapter
    const adapter = new BotFrameworkAdapter({
        appId: process.env.MicrosoftAppId,
        appPassword: process.env.MicrosoftAppPassword
    });
    adapter.use(conversationState);
    adapter.use(userState);
    

    Note: MemoryStorage is not suitable for production—it's volatile and resets every time your bot restarts.

2. Cloud Storage (For Production)

For production bots, you'll need persistent, scalable storage. Popular options include:

  • Azure Blob Storage (seamless Bot Builder integration)
  • Azure Cosmos DB (great for queryable state data)
  • SQL Database (if you prefer relational storage)

Example for Azure Blob Storage (Node.js):

const { BlobStorage } = require('botbuilder-azure');

// Initialize blob storage
const blobStorage = new BlobStorage({
    containerName: 'your-bot-state-container',
    storageAccountOrConnectionString: 'your-azure-storage-connection-string'
});

// Use this storage for state management
const conversationState = new ConversationState(blobStorage);
const userState = new UserState(blobStorage);

3. Update Your Bot Builder SDK

Ensure you're using the latest version of the Bot Builder SDK—older versions may still default to the deprecated API. Update via:

npm update botbuilder --save
# For .NET: Update-Package Microsoft.Bot.Builder

Is This a Local Storage Problem?

Short answer: No, but local storage can be part of the solution.

  • The error stems from relying on Microsoft's retired cloud-hosted state service, not an issue with local storage itself.
  • You can use local storage (like MemoryStorage) for testing, but production bots require a persistent cloud storage solution. The core fix is moving away from the deprecated API to any custom storage provider you choose.

内容的提问来源于stack exchange,提问作者Jhon Caylog

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:16:37