class_docstr: Twilio input channel.
class_docstr_tok: ["Twilio","input","channel","."]
code: def blueprint(
      self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
  ) -> Blueprint:
      twilio_webhook = Blueprint("twilio_webhook", __name__)
  
      @twilio_webhook.route("/", methods=["GET"])
      async def health(_: Request) -> HTTPResponse:
          return response.json({"status": "ok"})
  
      @twilio_webhook.route("/webhook", methods=["POST"])
      async def message(request: Request) -> HTTPResponse:
          sender = request.form.get("From", None)
          text = request.form.get("Body", None)
          out_channel = self.get_output_channel()
  
          if self._is_location_message(request):
              # Text is always None with a location message/media from Twilio whatsapp
              text = "/locationData{{'Latitude': {lat},'Longitude': {long}}}".format(
                  lat=request.form.get("Latitude"),
                  long=request.form.get("Longitude"),
              )
  
          if sender is not None and message is not None:
              metadata = self.get_metadata(request)
              try:
                  # @ signs get corrupted in SMSes by some carriers
                  text = text.replace("¡", "@")
                  await on_new_message(
                      UserMessage(
                          text,
                          out_channel,
                          sender,
                          input_channel=self.name(),
                          metadata=metadata,
                      )
                  )
              except Exception as e:
                  logger.error(
                      f"Exception when trying to handle message.{e}"
                  )
                  logger.debug(e, exc_info=True)
                  if self.debug_mode:
                      raise
                  pass
          else:
              logger.debug("Invalid message")
  
          return response.text("", status=204)
  
      return twilio_webhook
  
imports: import logging
  from sanic import Blueprint, response
  from sanic.request import Request
  from sanic.response import HTTPResponse
  from twilio.base.exceptions import TwilioRestException
  from twilio.rest import Client
  from typing import Dict, Text, Any, Callable, Awaitable, Optional, TYPE_CHECKING
  from rasa.core.channels.channel import InputChannel
  from rasa.core.channels.channel import UserMessage, OutputChannel
label_desc: Use image node_id 5 for calling the TwilioInput obj's underlying member method code with example usage: obj.blueprint(on_new_message) and returns: twilio_webhook, response, response