Templates
Branches
Branches refer to the different versions of a template that are created to work on new features or bug fixes.
Stubber uses branches to isolate development work without affecting the live version of a template.
Each template has two default branches, draft and live.
The draft branch is where all development work is done.
The live branch is the version of the template that is currently live and being used by stubs.
You can think of branches in terms of a testing and production environment.
draft branch would interact with your testing or UAT (User Acceptance Testing) environment, while the live branch would interact with your production environment.
This way, you can test changes in the testing environment before publishing them to production.
Publish changes to the live branch
When you make changes to a template, they won't affect any live stubs until you publish them to the live branch.
Once you publish, your changes will be copied from the draft branch into the live branch, and all stubs using the template will be updated to use the new version.
How to use branches
If you have a production and staging environment, you can use the draft branch for staging and the live branch for production.
This way, you can test changes in the staging environment before publishing them to production.
You might want to enable different API endpoints and different notifications based on if you're testing and developing vs in production.
API Endpoints
- You can use template data to set a different API endpoint for each branch.
- On the apicall task, you can set the conditions to use different endpoints based on the branch.
- You can use the
stub.program.branch
variable to get the current branch of the stub.
Email Notifications
Another great use of branches is to set notifications to go to a different email address based on the branch.
- You can setup 2 identical email notifications, then use conditions on the email notification to set the send_to email address based on the branch.
- You can do this by using the
stub.program.branch
variable to get the current branch of the stub. - The condition could look like this:
Whatsapp Profiles
If you frequently need to test a Whatsapp based template it might be useful to have a different Whatsapp profile for each branch.
You can setup a separate number and Whatsapp profile and then use the stub.program.branch
variable to set the profile to use based on which branch the stub is following.
Webchat Profiles
The webchat profile has built in support for draft
and live
branches. You can set different heimdall paths to emit on and then handle those paths differently in your template.
The action that registers for the webchat heimdall event would look at a different path depending on if the stub is in the draft
or live
branch.