Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions samples/django/13.core-bot/bots/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
""" Bot initialization """
# pylint: disable=line-too-long
import sys
import asyncio
from django.apps import AppConfig
from botbuilder.core import (BotFrameworkAdapter, BotFrameworkAdapterSettings, TurnContext, ConversationState, MemoryStorage, UserState)
from dialogs import MainDialog
Expand All @@ -17,6 +18,7 @@ class BotConfig(AppConfig):

SETTINGS = BotFrameworkAdapterSettings(appConfig.APP_ID, appConfig.APP_PASSWORD)
ADAPTER = BotFrameworkAdapter(SETTINGS)
LOOP = asyncio.get_event_loop()

# Create MemoryStorage, UserState and ConversationState
memory = MemoryStorage()
Expand Down
5 changes: 3 additions & 2 deletions samples/django/13.core-bot/bots/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def messages(request):

activity = Activity().deserialize(body)
auth_header = request.headers['Authorization'] if 'Authorization' in request.headers else ''
loop = asyncio.get_event_loop()

bot_app = apps.get_app_config('bots')
bot = bot_app.bot
loop = bot_app.LOOP
adapter = bot_app.ADAPTER

async def aux_func(turn_context):
asyncio.ensure_future(bot.on_turn(turn_context), loop=loop)
await bot.on_turn(turn_context)

try:
task = asyncio.ensure_future(adapter.process_activity(activity, auth_header, aux_func), loop=loop)
loop.run_until_complete(task)
Expand Down