) # Listen for incoming requests on /api/messages async def messages(req: Request) -> Response: # Main bot message handler. if "application/json" in req.headers["Content-Type"]: body = await req.json() else: return Response(status=415) activity = Activity().deserialize(body) auth_header = req.headers["Authorization"] if "Authorization" in req.headers else "" try: await ADAPTER.process_activity(activity, auth_header, BOT.on_turn) return Response(status=201) except Exception as exception: raise exception APP = web.Application(middlewares=[aiohttp_error_middleware]) APP.router.add_post("/api/messages", messages) APP.router.add_routes(aiohttp_channel_service_routes(SKILL_HANDLER, "/api/skills")) if __name__ == "__main__": try: web.run_app(APP, host="localhost", port=CONFIG.PORT) except Exception as error: raise error
if "application/json" in req.headers["Content-Type"]: body = await req.json() else: return Response(status=415) inbound_activity: Activity = Activity().deserialize(body) current_conversation_id = inbound_activity.conversation.id current_service_url = inbound_activity.service_url next_conversation_id = FACTORY.create_skill_conversation_id( current_conversation_id, current_service_url) await CLIENT.post_activity(CONFIG.APP_ID, CONFIG.SKILL_APP_ID, TO_URI, SERVICE_URL, next_conversation_id, inbound_activity) return Response(status=201) APP = web.Application() APP.router.add_post("/api/messages", messages) APP.router.add_routes( aiohttp_channel_service_routes(ROUTING_HANDLER, "/api/connector")) if __name__ == "__main__": try: web.run_app(APP, host="localhost", port=CONFIG.PORT) except Exception as error: raise error