This application works as a sample to show how Twilio Functions & Studio Flows can be tracked together in one repository and deployed automatically via a Continuous Delivery mechanism such as GitHub Actions.
sample-flows-github-actions
├── LICENSE
├── README.md
├── assets
├── flows
├── functions
├── node_modules
├── package-lock.json
├── package.json
└── scripts
5 directories, 4 files
The functions and assets folders contain any Twilio Functions & Assets you might want to deploy. They'll be deployed using npm run ci:deploy-functions that leverages twilio-run, that is part of the Twilio Serverless Toolkit](https://www.twilio.com/docs/labs/serverless-toolkit).
The flows directory is used to store the JSON representation of the Twilio Studio flow we are trying to deploy. In our case that is a webinar-flow.json example file. It gets deployed through the npm run ci:deploy-flows command that internally runs the scripts/deployFlows.js file using the Twilio Studio API.
You can find the GitHub Actions workflow that is being triggered on each push
to main inside .github/workflows/deploy.yml. The logic can be ported to any
other CI/CD platform that can:
- Can store secrets and set them as environment variables
- Install Node.js
- Install dependencies from npm
- Run npm scripts with environment variables
This project is not intended to immediately work by forking the project. Instead it is intended to work as a blueprint for your own projects and to understand how the Studio Flows API works.
You might have to change:
- The name of your flows JSON file
- Any references to the friendly name in the
deployFlow.jsfile to deploy your flow correctly - If your flow triggers a Function make sure that the configuration for those is pointing to the correct Function
- Set your Twilio Account SID and Auth Token as
TWILIO_ACCOUNT_SIDandTWILIO_AUTH_TOKENsecrets inside GitHub Actions' Secrets Store
Important We are currently scoping out on how to add Studio support directly into the Twilio Serverless Toolkit. We'll update this example once that lands but feel free to chime in with feedback.
This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.
MIT