Movatterモバイル変換


[0]ホーム

URL:


Skip to contentSkip to navigationSkip to topbar
Go to the Twilio Docs home page
Twilio Docs

Function Request Flow


The best way to understand how Twilio Functions works is to start by understanding the HTTP request flow and how Twilio ultimately executes your code. Twilio Functions is designed to handle as much of the infrastructure work of building a web app as possible so that you can focus on application logic instead. For Twilio Functions, this work begins at the front door, handling the HTTP request for your Function and continues through the pipeline up to your code.

Functions Request Flow.
  1. Every Function invocation begins with an HTTP client issuing a request to your Function. For most Functions, the client is the Twilio Voice or Messaging API responding to an incoming phone call or text message.
  2. The Twilio Functions Gateway receives this request and attempts to validate it. If your Function has Signature Validation enabled, the Function Gateway will attempt to validate the signature. If the request or the Twilio Signature are invalid, the request is rejected with anHTTP 400 response.
  3. After the Function Gateway has accepted the request, it will normalize the request into a payload for your Function. The normalized request is provided to your Function as two arguments:context andevent. Once the payload has been constructed, it is used to invoke your Function.
  4. At invocation, your Function begins executing thehandler code that you have provided. When your Function completes executing, it can emit a response using thecallback method. The emitted response will be transmitted to the Function Gateway.
  5. Upon receiving the result from your Function, the Function Gateway will construct an HTTP response and return it to the client that issued the request.

Currently, Twilio Functions only supports HTTP requests. Twilio Functions will respond to three HTTP verbs:GET,POST, andOPTIONS.PUT andDELETE are currently not supported.

ForPOST requests, Twilio Functions natively supports theapplication/json andapplication/x-www-form-urlencoded content types. This means that JSON bodies and form and query parameters will be normalized into theevent parameter.


There are several important limitations to Twilio Functions that you should consider when designing your application:

  • Execution time: Twilio Functions execute for at most 10 seconds. Any Function that exceeds the 10-second limit will be terminated, and the client will receive anHTTP 504 Gateway Time-out response.
  • Path parameter support: Twilio Functions does not provide support for path parameters. You must provide query parameters or JSON in order to pass information into your application.
  • Maximum response size: Twilio Functions have a constrained response size of4MB.
  • Maximum request size: Twilio Functions can accept payload size up to1MB including the request headers and cookies.

Now that you have an understanding of the request flow to your Functions, it's time to learn aboutthe execution process, handler method, and response building processes.


[8]ページ先頭

©2009-2025 Movatter.jp