# Working with VUI prompts for OMG project (order my groceries)
### Overview
[](https://)
- OMGService repo has the code where our OMG Service is ran
- OMGRemoteTransformer repo is a dependency for OMGService repo, which handles transformation from directives -> prompts
- directives: an object containing information which can be used to assemble prompts, for example: {"store": "fresh", ..}
- prompts: literally the prompts that users will get from our Echo devices. For example: "Okay, based on your grocery order history, I've added 2 items to your fresh cart."
- OMGServicePrompts has the translation mapping defined. The translation definitions will be used to build a database, which OMGRemoteTransformer can refer to, when doing the translations.
- RDE-OMGService is how we run OMGService conveniently
### Setup
- There are different ways for setting this up. Here we are going use "brazil" to set the repos up locally, then use "cdd" (cloud desktop cli) to migrate our local set-up to our cloud desktop.
- We are going to run OMGService on cloud desktop with "RDE", and use IntelliJ to remote-debug.
1, set up repos locally
- reference https://w.amazon.com/bin/view/ASG_North/OMGService/Development/ for additional information
- all commands needed in this step are listed below
```
brazil workspace create --root omg_tonyhxli // create an empty workspace
cd omg_tonyhxli
brazil ws use --versionset OMGService/development-native // simply use default version set
brazil ws use --package OMGService // get the packages (repos)
brazil ws use --package OMGServicePrompts
brazil ws use --package OMGRemoteTransformers
brazil ws use --package RDE-OMGService
// or, ws use --package OMGService --package OMGServicePrompts --package OMGRemoteTransformer --package RDE-OMGService
```
2, sync clouddesktop with local packages that we just created
- we can use cloud-desktop cli to sync our cloud-desktop against our local setup (upload from local to cloud-desktop)
```
toolbox install cloud-desktop
cloud-desktop remote add --dir /Users/tonyhxli/Desktop/omg_tonyhxli --host tonyhxli-clouddesk.aka.corp.amazon.com
```
3, run our service on cloud-desktop
ssh into your clouddesktop, and go to the workspace that we just created:
```
ssh tonyhxli-clouddesk.aka.corp.amazon.com
ls ~/cdd2/Users/tonyhxli/Desktop/omg_tonyhxli
```
Next we need to run OMGService in debug mode:
- to run prepare OMGService for running in debug mode: 1. In the OMGService package's build.xml file, uncomment the jdwp line for the "apollo-script" target
- more information can be found in https://w.amazon.com/bin/view/ASG_North/OMGService/Development/#HRemoteDebugging
```
cd src/RDE-OMGService
rde wflow run provision
rde wflow run start-service-debug -v
```
Special Notes:
- if "rde wflow run start-service" fails, and you see an error saying "brazil-path: PathGenerationException: Package caching error: Error occurred while caching":
- try `brazil-package-cache enable_edge_cache`
- more info available at: https://sage.amazon.com/questions/492731
- if everything works well `docker ps` should show 4 containers running
- refer to https://w.amazon.com/bin/view/ASG_North/OMGService/Development/#HHowtotestOMGstep for how to test your deployment
4, set up remote debugging
- set up ssh tunnel on your local laptop
```
(on local)
ssh -o ProxyCommand=none -T -N -L 5050:localhost:5050 tonyhxli@tonyhxli-clouddesk.aka.corp.amazon.com
```
- open the workspace that was created earlier with IntelliJ
- follow https://w.amazon.com/bin/view/AlexaStyle/ASQA/Automation/RDE_Remote_Debugging/#Hdebuggingonclouddesktop to set up remote debugging
- click "brazil" -> "sync from workspace" on the top navigation bar
- if you see error "Unable to get the signature for <some dependency> was not built for the platform 'RHEL5_64'":
- do `brazil ws --use --platform AL2012`
- more details can be found at https://sage.amazon.com/questions/245870
- make sure deployment on clouddesktop is exposed & reachable by coral webdriver
```
(on cloud-desktop)
socat tcp-listen:8083,reuseaddr,fork tcp:localhost:443
```
### Special Note 1: how to reset hint
- by resetting hint, we can reset a customer to be a first-time customer. This is helpful when we want to test scenerios which are applicable to first-time users.
One example user in prod environment:
```
email: asqa-test+us-freshwf-omg@amazon.com
password: asqa2019
user_id: A3CA8AITGUUQCP
```
For prod:
Go to https://coral.amazon.com/AlexaShoppingHintsService/Prod/Segment1/NA/1Box/Prod/explorer
- under TARGET select `prod/segment1/NA/fleet/prod`
- use the request body below:
```
{
"Operation": "com.amazon.alexashoppinghints#ResetHint",
"Service": "com.amazon.alexashoppinghints#AlexaShoppingHintsService",
"Input": {
"customerId": "A3CA8AITGUUQCP",
"hintName": "FTUX.ORDER_MY_GROCERIES"
}
}
```
- send the request
- if the request failed, the user might've already been a first-time user. Try invoking OMG with this user and then try again.
### Special Note 2: how to check logs
Let's say we are hitting our cloud-desktop deployment with coral webdriver, but how do we make sure our service is being called? Where are the logs?
```
ssh $your-cloud-desktop
docker exec -it OMGService bash
tail -f /apollo/env/OMGService/var/output/logs/service_log.$latest_timestamp
```
For devo:
- go to https://cafeportal.aka.amazon.com/reset-hint/devo
- select "FTUX.order_my_groceries"
- note that you have to refresh the page every now and then to avoid getting "unauthorized" error
- note that you have to make sure the user is NOT FTU, to avoid getting "Bad Input: No matching record is found" error
### Special Note 3: a few problems that could cause remote debugging to stop working
- turning on debugging might cause the program to slow down and time out.
- if breakpoints are in TransformActivity (OMGRemoteTransformers is also part of this), and FindShoppingCandidatesRemoteStepActivity took too long to response, the breakpoinks will not be reached.
- to fix this, if we were testing with dev studio, we could overwrite the timeout for the user, from 1000ms to say, 4000ms
- edit in flare and overwrite for user, take this link for an example: https://alexashop.integ.amazon.com/changesets/FLARE_WORK_REQUEST:56862/remote-transformers/TELL_OMG_HAS_NO_CANDIDATES_TRANSFORMER/edit
- after fixing, we can verify it in action: https://alexashop.integ.amazon.com/interaction/amzn1.vshop.int.8e6a177e-a1e9-4082-97cf-21744a8426d4/blob?hl_lines=3996-4021#line-3993
- try removing all the breakpoints and restart the debugger, see if the service can run normally
- if it could, add the breakpoints back one by one, test the debugger each step
### Special note 4: How to find users & Check user eligibility
- find users:
- here is a pool of users https://alexa-apex.corp.amazon.com/testPool.jsp?id=OMG_Manual_Test_Accounts_Devo
- here is another pool of users shared by Anand, for prod users: https://w.amazon.com/bin/view/Alexa_Grocery_QA/Resources/TestAccounts/
- check user eligibility:
- (prod) https://zamboni-iad.aka.amazon.com/storeResolution/getRankedStores?srsAPIName=getRankedStores&marketplace=US&customerId=A3E15E9MG76H76
- (test) https://zamboni-na.integ.amazon.com/storeResolution/getRankedStores?srsAPIName=getRankedStores&marketplace=US&shoppingServiceName=&customerId=A26OG763GQ1MOY&keyword=&locale=en-US&requestedStoreResolutionIds=
- one devo user with eligibility for both fresh & wholefoods: A26OG763GQ1MOY US_15919067706043vgg@amazon.com
- user only eligible for whole foods: A3E15E9MG76H76
- user only eligible for fresh: A39AL1J6DXZ7QR US_1590168467166c17q@email.amazon.com testtest
- user that can be user to trigger StoreDisambiguation:
```
{
"Operation": "com.amazon.omgservice#FindShoppingCandidatesRemoteStep",
"Service": "com.amazon.omgservice#OMGService",
"Input": {
"customerInfo": {
"customerId": "A3IBQ01GQMCN07",
"locale": "en-US",
"preferredMarketplace": "ATVPDKIKX0DER"
}
}
}
```
### Special note 5: Coral Diver testing
https://coral.amazon.com/OMGService/Prod/explorer
Basic request format:I
```
{
"Operation": "com.amazon.omgservice#FindShoppingCandidatesRemoteStep",
"Service": "com.amazon.omgservice#OMGService",
"Input": {
"conversationContext": {
"__type": "com.amazon.ava.types.coral#ConversationContext",
"entityMap": {
"com.amazon.avacontext.slotvalue.ShoppingServiceName": {
"__type": "com.amazon.coral.envelope#WireEnvelope",
"id": "com.amazon.avacontext.intent#IntentSlotValue",
"payload": "eyJfX3R5cGUiOiJjb20uYW1hem9uLmF2YWNvbnRleHQuaW50ZW50I0ludGVudFNsb3RWYWx1ZSIsImZvcm1hdHRlclJlc3VsdHMiOnt9LCJzbG90TmFtZSI6IlNob3BwaW5nU2VydmljZU5hbWUiLCJzbG90VmFsdWUiOiJBTUFaT05fUFJJTUVfRlJFU0gifQ==",
"serializer": {
"__type": "com.amazon.coral.serialize#Descriptor",
"name": "rpc"
}
}
},
"turnsWithRequestedEntities": []
},
"customerInfo": {
"customerId": "A26OG763GQ1MOY",
"locale": "en-US",
"preferredMarketplace": "ATVPDKIKX0DER"
}
}
}
```
- decode the payload to see what payload is for
- how to find more examples for request payload formats
- https://access.amazon.com/aws/accounts/show/OMGService-NA-Prod
- Access Aws Console
- make sure you are in us-east-1
- go to Service:CloudWatch (search for this service)
- search for omgservice/request.log
- in any entry, look for log entries for "OMGService"
### Special note 6: Some common errors you might run into when deploying
How to triage errors:
- most of the errors have their reasons in the error log
- brazil-build build can have better error log than deployment error
- brazil wd sync --md if there have been code changes that require dependency change
### Special note 7: manually testing the new prompts
For updates that span on [OMGService, OMGServicePrompts, OMGRemoteTransformers], we can manually test them on beta dev-studio
- release OMGServicePrompts to beta, manually
- first release it to alpha brazil-build publish-prompts-to-alpha -DlivePrompts.publish.login=autopublish -DlivePrompts.publish.namespace=Shopping.Grocery.OMG
- then release it to beta brazil-build publish-prompts-to-beta -DlivePrompts.publish.login=autopublish -DlivePrompts.publish.namespace=Shopping.Grocery.OMG
- check the result (prompts db database) https://prompts.aka.amazon.com/namespace/Shopping.Grocery.OMG/stage/BETA
- be aware that this release may actually be picked up and pushed to production if there are other releases, so it's not very safe to do either.
- make sure all changes to OMGServicePrompts are backwards-compatible
- deploy updated OMGService on cloud-desktop, with updated OMGRemoteTransformers in the same workspace.
- then we can test that deployment on beta dev-studio.
### Special note 8: checkstyle
to run checkstyle locally:
- brazil-build standard-checkstyle
- brazil-build release if the above is not available
### Special note 9: working with weblab
We use weblab for doing A/B testing.
an example weblab that was created for A/B testing: https://weblab.amazon.com/wl/ALEXA_ORDER_MY_GROCERY_283490
the weblab for users that use OMGService:
https://weblab.amazon.com/legacy#ALEXA_ORDER_MY_GROCERIES_231663
Note that if we want to use overrides, prod and deve are separated, each has to be enabled separately
An exmaple commit that uses weblab: https://code.amazon.com/packages/OMGService/commits/9e4f7f797256ed71798547486ff3b8d921f72c7b#
### Interaction missing in alexashop
https://dodb-beta-iad.integ.amazon.com/utterances?customer_id=A3P0GNZ8QO4SVG
### Check weblab
https://atochadp.amazon.com/alexa/advancedSearch?_operation=advancedSearch&_search=TimeWindow%3D2020-07-02_15_30_27%2C2020-07-02_16_11_27%3A_result_size%3D10%3Aservice%3Domgs%3AcustomerId%3DA2I0ZJA92UAVO6&_queryId=&_timezone=America/Toronto
### conversation configuration override:
- basic VUI:
- example flare work request that contains override: https://alexashop.integ.amazon.com/changesets/FLARE_WORK_REQUEST:56862
- release: https://flare.aka.amazon.com/alexaShoppingDialogPlatform/releases/85987
- release snapshot_id: 544934
- basic VUI with preferredStore (easy testing):
- using the same flare work request as the one above: https://alexashop.integ.amazon.com/changesets/FLARE_WORK_REQUEST:56862
- release: https://flare.aka.amazon.com/alexaShoppingDialogPlatform/releases/86592
- release snapshot_id: 548832
GUI update release snapshot_id: 540078
# Debugging:
- to restart service after making changes: `rde wflow run deploy-service`
- if we add a breakoping and restart debugger, the debugger will freeze up. need to re-deploy service in this case.
"{\"customerProductStorePreferences\":[{\"browseNodeLevel\":0,\"browseNodeId\":16310101,\"preferences\":[{\"store\":\"FRESH\",\"numberOfPurchases\":126,\"lastPurchaseDate\":\"2021-02-26T20:10:48Z\",\"score\":0.01},{\"store\":\"Wholefoods\",\"numberOfPurchases\":126,\"lastPurchaseDate\":\"2021-02-26T20:10:48Z\",\"score\":0.99}]}]}"