Collection of Lambda handlers to process Google reviews
- Find a sample event JSON in the
tst/data/
folder. E.g.,"body": "{\"businessId\": \"accounts/106775638291982182570/locations/4496688115335717986\", \"createdAt\": \"2024-03-25T21:35:50.399385Z\", \"numberRating\": \"4\", \"review\": \"Shawn2 says good\", \"reviewLastUpdated\": \"2024-03-25T21:35:50.399385Z\", \"reviewerName\": \"Shawn Wang\", \"reviewerProfilePhoto\": \"https://lh3.googleusercontent.com/a-/ALV-UjV38DiAvegmeiCBrzTqD96KnS8v6Lf_-u46wHrwdao7=s120-c-rp-mo-br100\", \"userId\": \"Ucc29292b212e271132cee980c58e94eb\", \"vendorEventId\": \"AbFvOqlN5vDVwiHxseIJiokzlM58zCd_zwCtQSdGkssestHwymY-yXBSamZfrSr5iJdmdQ0gvOsqlg\", \"vendorReviewId\": \"accounts/107069853445303760285/locations/4496688115335717986/reviews/AbFvOqlN5vDVwiHxseIJiokzlM58zCd_zwCtQSdGkssestHwymY-yXBSamZfrSr5iJdmdQ0gvOsqlg\", \"zapierReplyWebhook\": \"https://hooks.zapier.com/hooks/catch/15416479/3hdtkdh/\"}",
- Run the handler with your input event with AWS SAM. Something like this (idk, I used Intellij IDEA plugin)
sam local invoke -e tst/data/sample-event.json
No need to commit to any branch. Can deploy changes in multiple repos (e.g., CoreDataAccess) with go.work
configured.
- See for details on go.work
- Get alpha credentials
../script/get-tmp-creds.sh
- Requires
aws configure sso
for the account if you haven't, or withaws sso login --profile=AdministratorAccess-$DEV_ACCOUNT
if you have previously configured.
- Requires
npm run ls
to find the lambda stack namenpm run deploy IntelliLead-ap-northeast-1-alpha-DeploymentStacks/IntelliLead-ap-northeast-1-alpha-Lambda
to deploy the lambda
- Update the JSON in
src/pkg/jsonUtil/json/lineRichMenu/createRichMenuInput.json
. Increment the version name in thename
field. - Choose the right channel access token for your environment
- Create rich menu entity in LINE by running
https://api.line.me/v2/bot/richmenu
with the updated JSON as body. Record therichMenuId
in the response.{ "richMenuId": "richmenu-d2102f540de0e2a3c8c70d52ce622194" }
- Upload Rich menu image associated with new Rich Menu entity by running
https://api-data.line.me/v2/bot/richmenu/{{richMenuId}}/content
with the (new) Rich Menu image as attachment. Verify response is empty 200. - Set the newly configured Rich Menu entity as default by running
https://api.line.me/v2/bot/user/all/richmenu/{{richMenuId}}
. Verify response is empty 200.
Run script/sendReviewToUser with SAM CLI
- modify businessId, userId, and reviewIds arguments in script
- Create SAM CLI template
Resources: Function: Type: AWS::Serverless::Function Properties: Timeout: 300 MemorySize: 128 Handler: sendReviewToUser CodeUri: /Users/shawn/workspace/intellilead/code-workspace/ReviewHandlers/script Runtime: go1.x Architectures: - x86_64 Environment: Variables: STAGE: local
- Ensure SAM CLI AWS connection profile is set to the designated AWS account
- Run with SAM CLI with any input arguments
[profile il-alpha]
sso_start_url = https://d-926756898f.awsapps.com/start
sso_region = us-west-2
sso_account_id = 222196498939
sso_role_name = AdministratorAccess
region = ap-northeast-1
output = json
[profile il-beta]
sso_start_url = https://d-926756898f.awsapps.com/start
sso_region = us-west-2
sso_account_id = 673067564576
sso_role_name = AdministratorAccess
region = ap-northeast-1
output = json
[profile il-gamma]
sso_start_url = https://d-926756898f.awsapps.com/start
sso_region = us-west-2
sso_account_id = 250743217525
sso_role_name = AdministratorAccess
region = ap-northeast-1
output = json
[profile il-prod]
sso_start_url = https://d-926756898f.awsapps.com/start
sso_region = us-west-2
sso_account_id = 613539315064
sso_role_name = AdministratorAccess
region = ap-northeast-1
output = json
Unnecessary with CDK deployment. Only for testing new lambda handlers.
- Test the handler locally. Expect
❯ go run main.go 2023/05/26 10:51:02 expected AWS Lambda environment variables [_LAMBDA_SERVER_PORT AWS_LAMBDA_RUNTIME_API] are not defined exit status 1
- build zip
❯ GOOS=linux GOARCH=amd64 go build -o main main.go && zip main.zip main
- Upload via Lambda console
- Make request and observe response in CloudWatch Logs/Metrics