diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c88c3c --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Github Templates + +This repository was created for my talk at [Javaland 2021 about Voice apps](https://programm.javaland.eu/2021/#/scheduledEvent/606587). + +The app presented here is an Alexa voice app that allows the user to create repositories from Github templates. +It was created using the [Alexa Skills Kit](https://developer.amazon.com/en-US/alexa/alexa-skills-kit) + +## Structure : + +The structure of this repository is the typical structure of a Java generated ask app. + +* _skill-package_ contains all the information about the skill itself, as well as the 'front-end' of the app +* _lambda_ contains the Java code and represents the 'back-end' of the app. It is uploaded as an AWS lambda. + +Some interesting files : + +* [en-GB.json](skill-package/interactionModels/custom/en-GB.json) contains the JSON representation of my app model (basically its front-end). +* [CreateRepositoryIntentHandler.java](lambda/src/com/amazon/ask/githubtemplates/handlers/CreateRepositoryIntentHandler.java) is where the magic happens, and the repository is created based on user input. + +## Running the code + +This code is specifically wired to run on my environment. However, you can try it in a few steps. + +* Make sure to be logged in the AWS CLI locally. +* In the [skill.json](skill-package/skill.json) file, empty out the "apis" object. +* Make sure that the [ask-resources.json](ask-resources.json) file "type" key contains your default AWS region. +* Once you have deployed the lambda using `ask deploy`, create the `GITHUB_LOGIN` and `GITHUB_OAUTH` environment variables so the lambda can interact with your Github account. +* If you want to be able to run [GithubDataGrabber](lambda/src/com/amazon/ask/githubtemplates/data/GithubDataGrabber.java), create a .githubconfig file in the root of the repository with the `GITHUB_LOGIN` and `GITHUB_OAUTH` values. + +_note : You can find more information about the Github API [here](https://github-api.kohsuke.org/index.html)._ + +_note2: Using environment variables is fine for testing, but for actual production usage there are better ways to interact with the Github API._ + +## Slides of the talk + +See [slides](slides/hey-google-javaland.pdf). + +## Author + +* [Julien Lengrand-Lambert](https://twitter.com/jlengrand) \ No newline at end of file diff --git a/lambda/src/com/amazon/ask/githubtemplates/handlers/CreateRepositoryIntentHandler.java b/lambda/src/com/amazon/ask/githubtemplates/handlers/CreateRepositoryIntentHandler.java index 3bcf1a7..2b28f88 100644 --- a/lambda/src/com/amazon/ask/githubtemplates/handlers/CreateRepositoryIntentHandler.java +++ b/lambda/src/com/amazon/ask/githubtemplates/handlers/CreateRepositoryIntentHandler.java @@ -52,8 +52,8 @@ public class CreateRepositoryIntentHandler implements RequestHandler { try{ GithubAPI api = new GithubAPI(); - String language = slots.get("language").getValue(); - String title = slots.get("title").getValue(); + String language = slots.get("language").getValue().toLowerCase(); + String title = slots.get("title").getValue().replace(" ", "-"); api.getGithub().createRepository(title) .fromTemplateRepository( diff --git a/lambda/src/com/amazon/ask/githubtemplates/handlers/github/GithubAPI.java b/lambda/src/com/amazon/ask/githubtemplates/handlers/github/GithubAPI.java index 67bb617..a03102f 100644 --- a/lambda/src/com/amazon/ask/githubtemplates/handlers/github/GithubAPI.java +++ b/lambda/src/com/amazon/ask/githubtemplates/handlers/github/GithubAPI.java @@ -12,7 +12,9 @@ public class GithubAPI { public static final Map> TEMPLATES = Map.of( "java", new Pair<>("Spring-Boot-Framework", "Spring-Boot-Application-Template"), - "typescript", new Pair<>("carsonfarmer", "ts-template") + "typescript", new Pair<>("carsonfarmer", "ts-template"), + "javascript", new Pair<>("jlengrand", "openwc-template"), + "elm", new Pair<>("jlengrand", "elm-firebase") ); private GitHub github; diff --git a/skill-package/interactionModels/custom/en-GB.json b/skill-package/interactionModels/custom/en-GB.json index 0fff089..bce9d96 100644 --- a/skill-package/interactionModels/custom/en-GB.json +++ b/skill-package/interactionModels/custom/en-GB.json @@ -72,6 +72,12 @@ } ], "samples": [ + "make me a new {language} repo", + "make me a new {language} repository", + "create a repository in {language} called {title}", + "create a repo in {language}", + "create a new {language} repo called {title}", + "create a new {language} repository please", "make me a repo called {title}", "I want a new {language} repo called {title}", "new {language} repo with name {title}", diff --git a/slides/hey-google-javaland.pdf b/slides/hey-google-javaland.pdf new file mode 100644 index 0000000..88f06c6 Binary files /dev/null and b/slides/hey-google-javaland.pdf differ