Skip to content

Instantly share code, notes, and snippets.

View anchetaWern's full-sized avatar
🏠
Working from home

Wern Ancheta anchetaWern

🏠
Working from home
View GitHub Profile
@anchetaWern
anchetaWern / type_effectiveness.csv
Last active July 13, 2019 05:09
Pokedex Bot: type_effectiveness entity
double_damage_from double damage from double_damage_from super effective against super effective to very effective against weakness of
double_damage_to double damage against double damage to double_damage_to strong against
half_damage_from half damage from half_damage_from not so effective against not very effective against not very effective to
half_damage_to half damage against half damage to half_damage_to
no_damage_from no damage against no damage from no effect against no_damage_from resistant against resistant to
no_damage_to has no damage to has zero damage to no effect to no_damage_to
@anchetaWern
anchetaWern / specs.csv
Created July 12, 2019 03:32
Pokedex Bot: specs entity
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 3. in line 1.
"abilities","abilities","ability","skill"
"description","about","description"
"moves","attack","move","moves"
"photo","image","sprite"
@anchetaWern
anchetaWern / run the server
Created July 12, 2019 00:26
Pokedex Bot: run the server
cd server
nodemon server.js
~/ngrok http 5000
@anchetaWern
anchetaWern / Run the project
Created July 12, 2019 00:25
Pokedex Bot: Run the project
react-native run-android
react-native run-ios
@anchetaWern
anchetaWern / config.js
Last active July 12, 2019 00:24
Pokedex Bot: Dialogflow config.js
export const dialogflowConfig = {
"type": "service_account",
"project_id": "XXX-XXXX-XXXX",
"private_key_id": "XXXXX",
"private_key": "-----BEGIN PRIVATE KEY----XXXXX\n-----END PRIVATE KEY-----\n",
"client_email": "dialogflow-XXXX@XXXXX-XXX-XXXX.iam.gserviceaccount.com",
"client_id": "XXXXXXXXXX",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_xxxx_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
@anchetaWern
anchetaWern / Bootstrapping the project
Last active July 12, 2019 06:03
Pokedex Bot: Bootstrapping the project
git clone https://github.com/anchetaWern/RNPokedexBot.git
cd RNPokedexBot
git checkout starter
yarn
react-native eject
react-native link react-native-dialogflow
react-native link react-native-voice
react-native run-android
react-native run-ios
@anchetaWern
anchetaWern / Expose the server in server.js
Created July 12, 2019 00:16
Pokedex bot: Expose the server
const PORT = 5000;
app.listen(PORT, (err) => {
if (err) {
console.error(err);
} else {
console.log(`Running on ports ${PORT}`);
}
});
@anchetaWern
anchetaWern / Type effectiveness endpoint in server.js
Created July 12, 2019 00:15
Pokedex bot: Type effectiveness endpoint in server.js
if (get_type_effectiveness) {
const pokemon_type = parameters.pokemon_types;
let type_effectiveness = parameters.type_effectiveness;
const type_effectiveness_formatted = type_effectiveness.replace(/_/g, ' ');
const type_effectiveness_word = outputContexts[0].parameters['type_effectiveness.original'];
let from_or_to = type_effectiveness.split('_')[2];
const pokemon_type_comes_first = (queryText.indexOf(pokemon_type) < queryText.indexOf(type_effectiveness_word)) ? true : false;
@anchetaWern
anchetaWern / Pokemon description and evolution endpoint in server.js
Created July 12, 2019 00:14
Pokedex Bot: Pokemon description and evolution endpoint in server.js
if (pokemon_species_endpoint.indexOf(specs) !== -1 || intent.displayName == 'evolution') {
const { data } = await axios_instance.get(`/pokemon-species/${pokemon}`);
const evolution_chain_id = data.evolution_chain.url.split('/')[6];
const text = data.flavor_text_entries.find(item => {
return item.language.name == 'en';
});
let fulfillmentText;
@anchetaWern
anchetaWern / Pokemon endpoint in server.js
Created July 12, 2019 00:12
Pokedex Bot: Pokemon endpoint
if (pokemon_endpoint.indexOf(specs) !== -1) {
const { data } = await axios_instance.get(`/pokemon/${pokemon}`);
let fulfillmentText;
const id = String(data.id).padStart(3, '0');
const value = (specs == 'abilities') ? data.abilities.map(item => item.ability.name).join(', ') : data.moves.map(item => item.move.name).join(', ');
fulfillmentText = `The ${specs} of ${pokemon} are: ${value}`;
Object.assign(response_obj, { fulfillmentText });