class_docstr: Bot Framework input channel implementation.
docstr: Defines the Sanic blueprint for the bot framework integration.
docstr_tok: ["Defines","the","Sanic","blueprint","for","the","bot","framework","integration","."]
code: def blueprint(
      self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
  ) -> Blueprint:
      """Defines the Sanic blueprint for the bot framework integration."""
      botframework_webhook = Blueprint("botframework_webhook", __name__)
  
      @botframework_webhook.route("/", methods=["GET"])
      async def health(request: Request) -> HTTPResponse:
          return response.json({"status": "ok"})
  
      @botframework_webhook.route("/webhook", methods=["POST"])
      async def webhook(request: Request) -> HTTPResponse:
          validation_response = self._validate_auth(
              request.headers.get("Authorization")
          )
          if validation_response:
              return validation_response
  
          postdata = request.json
          metadata = self.get_metadata(request)
  
          metadata_with_attachments = self.add_attachments_to_metadata(
              postdata, metadata
          )
  
          try:
              if postdata["type"] == "message":
                  out_channel = BotFramework(
                      self.app_id,
                      self.app_password,
                      postdata["conversation"],
                      postdata["recipient"],
                      postdata["serviceUrl"],
                  )
  
                  user_msg = UserMessage(
                      text=postdata.get("text", ""),
                      output_channel=out_channel,
                      sender_id=postdata["from"]["id"],
                      input_channel=self.name(),
                      metadata=metadata_with_attachments,
                  )
  
                  await on_new_message(user_msg)
              else:
                  logger.info("Not received message type")
          except Exception as e:
              logger.error(
                  f"Exception when trying to handle message.{e}"
              )
              logger.debug(e, exc_info=True)
              pass
  
          return response.text("success")
  
      return botframework_webhook
  
imports: import datetime
  import json
  import logging
  import re
  from http import HTTPStatus
  from typing import Text, Dict, Any, List, Iterable, Callable, Awaitable, Optional
  import jwt
  import requests
  from jwt import InvalidKeyError, PyJWTError
  from jwt.algorithms import RSAAlgorithm
  from requests import HTTPError
  from sanic import Blueprint, response
  from sanic.request import Request
  from sanic.response import HTTPResponse
  from rasa.core.channels.channel import UserMessage, OutputChannel, InputChannel
label_desc: Use image node_id 8 for calling the BotFrameworkInput obj's underlying member method code with example usage: obj.blueprint(on_new_message) and returns: botframework_webhook, response, response, validation_response