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 |
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 |
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 |
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 |