This is a simple Golang Model-Controller template using AWS Lambda Go and mongodb.com as the database host. It is compatible with AWS Lambda CI/CD deployment.
Start here: Just Fork this repo
The first thing to do is prepare a Mongo database using this template:
- Sign up for mongodb.com and create one instance of Data Services of mongodb.
- Download MongoDB Compass, connect with your mongo string URI from mongodb.com
- Create database name iteung and collection reply

- Import this json into reply collection.



This boilerplate has several folders with different functions, such as:
- .github: GitHub Action yml configuration.
- config: all apps configuration like database, API, token.
- controller: all of the endpoint functions
- model: all of the type structs used in this app
- helper: helper folder with list of function only called by others file
Sign Up and login into aws console and go to AWS Lambda menu and follow this instruction:
- Klik Create Function and input Function name, select Amazon Linux 2023 Runtime, select x86_64 Architecture

- In Advanced settings select Enable function URL, None Aut type.

- Please set the environment variable in Configuration tab:
MONGOSTRING=YOURMONGOSTRINGACCESS WAQRKEYWORD=yourkeyword WEBHOOKURL=https://yourappname.alwaysdata.net/whatsauth/webhook WEBHOOKSECRET=yoursecret WAPHONENUMBER=62811111
- Go to the menu Identity and Access Management (IAM), set lambda:UpdateFunctionCode Policies, and add new users.

- Create an access key from the Security credentials tab.

- Go to settings>Secrets and variables>Actions in the GitHub repo. Add several Repository secrets.

-
Go to the WhatsAuth signup page and scan with your WhatsApp camera menu for login.
-
Input the webhook URL(https://yourappname.alwaysdata.net/whatsauth/webhook) and your secret from the WEBHOOKSECRET setting environment on Always Data.

-
Follow this instruction, in the end of the instruction you will get 30 days token using this request
-
Save the token into MongoDB, open iteung db, create a profile collection and insert this JSON document with your 30-day token and your WhatsApp number.


{ "token":"v4.public.asoiduas", "phonenumber":"6281111" }
To continue using the WhatsAuth service, we must get a new token every 3 weeks before the token expires in 30 days.
- Open Menu Amazon EventBridge> Buses > Rules > Create Rule. Choose like screenshot.

- Input for every 20 days; next, choose lambda function then set ENable state.


- Completing create schedule

If you want to upgrade apps, please delete (go.mod) and (go.sum) files first, then type the command in your terminal or cmd :
go mod init gocroot
go mod tidy