ADAPTER = CloudAdapter(ConfigurationBotFrameworkAuthentication(CONFIG))
what should be inside Config
somebody Please help me on this
import asyncio
import json
from aiohttp import web
from botbuilder.core import TurnContext
from botbuilder.integration.aiohttp import CloudAdapter, ConfigurationBotFrameworkAuthentication
from botbuilder.schema import Activity
import jwt # pip install pyjwt
# ----- Bot configuration -----
CONFIG = {
"appId": "",
"appSecret": ""
}
# Setup Bot Authentication
bot_auth = ConfigurationBotFrameworkAuthentication(CONFIG)
# Create Cloud Adapter
adapter = CloudAdapter(bot_auth)
# ----- Bot logic -----
async def bot_logic(turn_context: TurnContext):
if turn_context.activity.type == "message":
await turn_context.send_activity(f"You said: {turn_context.activity.text}")
else:
await turn_context.send_activity(f"[{turn_context.activity.type} event received]")
# ----- HTTP request handler -----
async def messages(req: web.Request) -> web.Response:
# Print headers
print("\n--- Headers ---")
for k, v in req.headers.items():
print(f"{k}: {v}")
# Print incoming JSON
body = await req.json()
print("\n--- Incoming Activity ---")
print(json.dumps(body, indent=4))
# Print and decode Authorization header
auth_header = req.headers.get("Authorization", "")
print("\n--- Authorization Header ---")
print(auth_header)
if auth_header.startswith("Bearer "):
token = auth_header[7:]
try:
decoded = jwt.decode(token, options={"verify_signature": False})
print("\n--- Decoded JWT Token ---")
print(json.dumps(decoded, indent=4))
except Exception as e:
print("Error decoding JWT token:", e)
# Deserialize Activity
activity = Activity().deserialize(body)
# Process the activity
try:
await adapter.process_activity(auth_header, activity, bot_logic)
except Exception as e:
print("\n--- Adapter Error ---")
print(e)
return web.json_response({"status": "ok"})
# ----- Setup web server -----
app = web.Application()
app.router.add_post("/api/messages", messages)
if __name__ == "__main__":
print("======= Running on http://localhost:3978 =======")
web.run_app(app, host="0.0.0.0", port=3978)
I gave config something like this
I could find proper documentation for cloud adaptor
[Errno Unauthorized. Invalid AppId passed on token: ]
I'm getting unauthorized error. Due to app id is passed as None while creating cloudadaptor. Even though I gave proper app id it's not aligning properly