I am working with Twilio and Nodejs. But I usually code in the Twilio console, which I don't like. I am aware of the Nodejs helper library but the execution is highly dependent on Autopilot tasks. So even if I am able to test function in VS Code by passing dummy data, if I need to test whether it's working along with other functions and tasks or not, I have to copy-paste it in the Twilio console. I am not sure how to simulate autopilot execution in VS Code.
-
When you say you are coding in the Twilio console, what do you mean? Are you using Twilio Functions? Or do you mean you are editing your Autopilot bot directly in the console? – philnash Jun 17 '21 at 04:14
-
Yes, I mean twilio functions. – Himanshu Kumar Jun 17 '21 at 11:08
1 Answers
Twilio developer evangelist here.
If you are looking to build with Twilio Functions on your local machine, then I can recommend the Twilio Serverless Toolkit. It's a set of tools that allow you to develop, run and deploy your Twilio Functions on your local machine. It includes an integration with ngrok to help you to test your webhooks from Twilio too.
You can install the Serverless Toolkit as a plugin to the Twilio CLI.
twilio plugins:install @twilio-labs/plugin-serverless
Then you can create a Twilio Functions project with the command:
twilio serverless:init project-name
That will give you an example project so you can see how it all works. You can start the project with the command:
twilio serverless:start
You can now develop, with automatic code reloading, until you are happy with your functions project. Then you can deploy the project to the Twilio infrastructure with:
twilio serverless:deploy
The Serverless Toolkit is open source and you can see all the code on GitHub.
Let me know if this helps at all.

- 70,667
- 10
- 60
- 88
-
Thanks for the response. How do I trigger a function on VS code? If I am using Twilio console, I can do it using the simulator or calling the assigned phone number. – Himanshu Kumar Jun 18 '21 at 03:06
-
1To be clear, this isn't running your functions in VS Code, just in Node.js on your own machines. When you start up functions project it creates URLs for the functions on localhost on your machine. If you want to trigger those from Autopilot then you need to expose those URLs with a tunnel like [ngrok](https://ngrok.com). Once you have a publicly available URL for your local functions you can use those URLs in your Autopilot bot actions while you are testing. – philnash Jun 18 '21 at 03:17