15 | Congratulations you just started a new Twilio
16 | Serverless project.
17 |
18 |
19 |
Assets
20 |
21 | Assets are static files, like HTML, CSS, JavaScript, images or audio
22 | files.
23 |
24 |
25 |
26 | This HTML page is an example of a public asset, you can
27 | access this by loading it in the browser. The HTML also refers to
28 | another public asset for CSS styles.
29 |
30 |
31 | You can also have private assets, there is an example
32 | private asset called message.private.js in the
33 | /assets directory. This file cannot be loaded in the
34 | browser, but you can load it as part of a function by finding its path
35 | using Runtime.getAssets() and then requiring the file.
36 | There is an example of this in
37 | /functions/private-message.js.
38 |
39 |
40 |
Functions
41 |
42 | Functions are JavaScript files that will respond to incoming HTTP
43 | requests. There are public and
44 | protected functions.
45 |
46 |
47 |
48 | Public functions respond to all HTTP requests. There is
49 | an example of a public function in
50 | /functions/hello-world.js.
51 |
52 |
53 |
54 | Protected functions will only respond to HTTP requests
55 | with a valid Twilio signature in the header. You can read more about
56 | validating requests from Twilio in the documentation. There is an example of a protected function in
59 | /functions/sms/reply.protected.js
60 |
61 |
62 |
twilio-run
63 |
64 |
65 | Functions and assets are served, deployed and debugged using
66 | twilio-run. You can serve the project locally with the command
69 | npm start which is really running
70 | twilio-run --env under the hood. If you want to see what
71 | else you can do with twilio-run enter
72 | npx twilio-run --help on the command line or check out
73 | the project documentation on GitHub.
76 |
77 |
78 |
79 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/.twilioserverlessrc:
--------------------------------------------------------------------------------
1 | {
2 | "commands": {},
3 | "environments": {},
4 | "projects": {},
5 | // "assets": true /* Upload assets. Can be turned off with --no-assets */,
6 | // "assetsFolder": null /* Specific folder name to be used for static assets */,
7 | // "buildSid": null /* An existing Build SID to deploy to the new environment */,
8 | // "createEnvironment": false /* Creates environment if it couldn't find it. */,
9 | // "cwd": null /* Sets the directory of your existing Serverless project. Defaults to current directory */,
10 | // "detailedLogs": false /* Toggles detailed request logging by showing request body and query params */,
11 | // "edge": null /* Twilio API Region */,
12 | // "env": null /* Path to .env file for environment variables that should be installed */,
13 | // "environment": "dev" /* The environment name (domain suffix) you want to use for your deployment. Alternatively you can specify an environment SID starting with ZE. */,
14 | // "extendedOutput": false /* Show an extended set of properties on the output */,
15 | // "force": false /* Will run deployment in force mode. Can be dangerous. */,
16 | // "forkProcess": true /* Disable forking function processes to emulate production environment */,
17 | // "functionSid": null /* Specific Function SID to retrieve logs for */,
18 | // "functions": true /* Upload functions. Can be turned off with --no-functions */,
19 | // "functionsFolder": null /* Specific folder name to be used for static functions */,
20 | // "inspect": null /* Enables Node.js debugging protocol */,
21 | // "inspectBrk": null /* Enables Node.js debugging protocol, stops execution until debugger is attached */,
22 | // "legacyMode": false /* Enables legacy mode, it will prefix your asset paths with /assets */,
23 | // "live": true /* Always serve from the current functions (no caching) */,
24 | // "loadLocalEnv": false /* Includes the local environment variables */,
25 | // "loadSystemEnv": false /* Uses system environment variables as fallback for variables specified in your .env file. Needs to be used with --env explicitly specified. */,
26 | // "logCacheSize": null /* Tailing the log endpoint will cache previously seen entries to avoid duplicates. The cache is topped at a maximum of 1000 by default. This option can change that. */,
27 | // "logLevel": "info" /* Level of logging messages. */,
28 | // "logs": true /* Toggles request logging */,
29 | // "ngrok": null /* Uses ngrok to create a public url. Pass a string to set the subdomain (requires a paid-for ngrok account). */,
30 | // "outputFormat": "" /* Output the results in a different format */,
31 | // "overrideExistingProject": false /* Deploys Serverless project to existing service if a naming conflict has been found. */,
32 | // "port": "3000" /* Override default port of 3000 */,
33 | // "production": false /* Promote build to the production environment (no domain suffix). Overrides environment flag */,
34 | // "properties": null /* Specify the output properties you want to see. Works best on single types */,
35 | // "region": null /* Twilio API Region */,
36 | "runtime": "node16" /* The version of Node.js to deploy the build to. (node16) */,
37 | // "serviceName": null /* Overrides the name of the Serverless project. Default: the name field in your package.json */,
38 | // "serviceSid": null /* SID of the Twilio Serverless Service to deploy to */,
39 | // "sourceEnvironment": null /* SID or suffix of an existing environment you want to deploy from. */,
40 | // "tail": false /* Continuously stream the logs */,
41 | // "template": null /* undefined */,
42 | }
--------------------------------------------------------------------------------