class_docstr: Channel that uses Google Hangouts Chat API to communicate.
class_docstr_tok: ["Channel","that","uses","Google","Hangouts","Chat","API","to","communicate","."]
docstr: API configuration for the channel webhook.
docstr_tok: ["API","configuration","for","the","channel","webhook","."]
code: def blueprint(
      self, on_new_message: Callable[[UserMessage], Awaitable[None]]
  ) -> Blueprint:
      """API configuration for the channel webhook."""
      custom_webhook = Blueprint("hangouts_webhook", __name__)
  
      @custom_webhook.route("/", methods=["GET"])
      async def health(request: Request) -> HTTPResponse:
          return response.json({"status": "ok"})
  
      @custom_webhook.route("/webhook", methods=["POST"])
      async def receive(request: Request) -> HTTPResponse:
          if self.project_id:
              token = request.headers.get("Authorization", "").replace(
                  "Bearer ", ""
              )
              self._check_token(token)
  
          sender_id = self._extract_sender(request)
          room_name = self._extract_room(request)
          text = self._extract_message(request)
          if text is None:
              return response.text("OK")
          input_channel = self._extract_input_channel()
  
          collector = HangoutsOutput()
  
          try:
              await on_new_message(
                  UserMessage(
                      text,
                      collector,
                      sender_id,
                      input_channel=input_channel,
                      metadata={"room": room_name},
                  )
              )
          except CancelledError:
              structlogger.error(
                  "hangouts.message.blueprint.timeout",
                  text=copy.deepcopy(text),
              )
          except Exception:
              structlogger.exception(
                  "hangouts.message.blueprint.failure",
                  text=copy.deepcopy(text),
              )
  
          return response.json(collector.messages)
  
      return custom_webhook
  
imports: import copy
  import logging
  import structlog
  import google.auth.transport.requests
  import cachecontrol
  import requests
  from asyncio import CancelledError
  from sanic import Blueprint, response
  from sanic.request import Request
  from typing import Text, List, Dict, Any, Optional, Callable, Iterable, Awaitable, Union
  from google.oauth2 import id_token
  from sanic.response import HTTPResponse
  from sanic.exceptions import SanicException
  from rasa.core.channels.channel import InputChannel, OutputChannel, UserMessage
label_desc: Use image node_id 9 for calling the HangoutsInput obj's underlying member method code with example usage: obj.blueprint(on_new_message) and returns: custom_webhook, response, response, response