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 / import modules in App.js
Created July 11, 2019 05:18
Pokedex Bot: Import modules in App.js
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { GiftedChat } from 'react-native-gifted-chat';
import { Dialogflow_V2 } from 'react-native-dialogflow';
import { dialogflowConfig } from './config';
@anchetaWern
anchetaWern / sample request body.json
Created July 4, 2019 10:04
E-commerce chat bot with React Native and Dialogflow: Sample Dialogflow fulfillment server request body
{
"responseId":"xxxx-xxx-4087-8df8-9f515xxxxxx2b-6xxxxx",
"queryResult":{
"queryText":"Pick loop 2020",
"parameters":{
"yoyos":"loop2020"
},
"allRequiredParamsPresent":true,
"outputContexts":[
{
@anchetaWern
anchetaWern / sample dialogflow response.json
Created July 4, 2019 10:02
E-commerce chat bot with React Native and Dialogflow: Sample Dialogflow response
{
"responseId":"xxxxx5cf-510c-xxxx-ae21-5d93e71xxxxxxxx",
"queryResult":{
"queryText":"What do you have",
"parameters":{
"yoyos":[
]
},
"allRequiredParamsPresent":true,
@anchetaWern
anchetaWern / extract data in server.js
Created July 4, 2019 04:18
E-commerce chat bot with React Native and Dialogflow: Extract data in fulfillment server
const { parameters, outputContexts } = req.body.queryResult;
@anchetaWern
anchetaWern / add ngrok URL
Created July 4, 2019 02:55
E-commerce chat bot with React Native and Dialogflow: Add the ngrok URL
const BASE_URL = 'YOUR NGROK HTTPS URL';
@anchetaWern
anchetaWern / run the server
Created July 4, 2019 02:53
E-commerce chat bot with React Native and Dialogflow: Run the server
cd server
nodemon server.js
~/ngrok http 5000
@anchetaWern
anchetaWern / run the app
Created July 4, 2019 02:10
E-commerce chat bot with React Native and Dialogflow: run the app
react-native run-android
react-native run-ios
@anchetaWern
anchetaWern / set up starter branch
Last active July 4, 2019 02:10
E-commerce chat bot with React Native and Dialogflow: set up starter project
git clone https://github.com/anchetaWern/RNDialogflowEcommerceBot.git
cd RNDialogflowEcommerceBot
git checkout starter
yarn
react-native eject
react-native link react-native-dialogflow
react-native link react-native-voice
@anchetaWern
anchetaWern / get yoyo specs in server.js
Created July 3, 2019 07:57
E-commerce chat bot with React Native and Dialogflow: Get yoyo specs
else if (parameters.specs) {
const yoyo_id = outputContexts[0].parameters.yoyos.replace(/ /g, '');
const spec = parameters.specs;
let spec_value = yoyos.find(item => item.id == yoyo_id)[spec];
let payload = { is_url: false };
if (spec == 'image') {
spec_value = `${BASE_URL}/images/${spec_value}`
payload = {
is_url: true
@anchetaWern
anchetaWern / pick yoyo in server.js
Created July 3, 2019 07:56
E-commerce chat bot with React Native and Dialogflow: Pick yoyo
if (parameters.yoyos && parameters.yoyos.length) {
return res.json({
fulfillmentText: `What would you like to know about ${parameters.yoyos}?`
});
}