プロアクティブなアクティビティ

BotBuilder プロアクティブ メッセージ フローでは、会話参照を保存する必要があります。 Teams SDK では、コンテキストを介してアクティビティ ハンドラーに渡されるものとほぼ同じ send メソッドを App クラスで公開します。 このメソッドは conversation_id を受け入れるため、格納するだけで十分です。

BotBuilder プロアクティブ メッセージ フローでは、会話参照を保存する必要があります。 Teams SDK では、コンテキストを介してアクティビティ ハンドラーに渡されるものとほぼ同じ send メソッドを App クラスで公開します。 このメソッドは conversationId を受け入れるため、格納するだけで十分です。

from botbuilder.core import TurnContext
from botbuilder.integration.aiohttp import CloudAdapter, ConfigurationBotFrameworkAuthentication
from botbuilder.schema import ChannelAccount, ConversationAccount, ConversationReference

adapter = CloudAdapter(ConfigurationBotFrameworkAuthentication(config))

conversation_reference = ConversationReference(
    service_url="...",
    bot=ChannelAccount(...),
    channel_id="msteams",
    conversation=ConversationAccount(...),
    user=ChannelAccount(...)
)

async def send_proactive(turn_context: TurnContext):
    await turn_context.send_activity("proactive hello")

await adapter.continue_conversation(
    conversation_reference,
    send_proactive
)
import {
  CloudAdapter,
  ConfigurationBotFrameworkAuthentication,
  ConversationReference,
} from 'botbuilder';

const auth = new ConfigurationBotFrameworkAuthentication(process.env);
const adapter = new CloudAdapter(auth);

(async () => {
  const conversationReference: ConversationReference = {
    serviceUrl: '...',
    bot: { ... },
    channelId: 'msteams',
    conversation: { ... },
    user: { ... },
  };

  await adapter.continueConversationAsync(process.env.MicrosoftAppId ?? '', conversationReference, async context => {
    await context.sendActivity('proactive hello');
  });
}());