Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from ocelotconsulting/fix-goBack
Browse files Browse the repository at this point in the history
Fix go back
  • Loading branch information
OMontano authored Apr 29, 2022
2 parents 7df3dad + a8a08b2 commit eb5ba91
Show file tree
Hide file tree
Showing 3 changed files with 315 additions and 61 deletions.
20 changes: 3 additions & 17 deletions lambda/conversation/reportOutage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@ const {
guard,
} = require('robot3')
const { utils } = require('@ocelot-consulting/ocelot-voice-framework')
const { reportOutageAPI } = require('../service/reportOutageAPI')
const { fakePhoneNumber, fakeWebsite } = require('../constants')

const callOutageApi = async ({houseNumber, phoneNumber}) => {
console.log('outage reported', houseNumber, phoneNumber)

return [{
result: 'noOutage'
}, {
result: 'yesOutage',
impact: '300',
areaDescription: 'The pines neighborhood north of Park Street',
workDescription: 'Crews are on the scenen and expect repairs to complete in about an hour.'
}, {
result: 'badCombination'
}][houseNumber % 3]
}

const stateMap = {
fresh: state(
transition('processIntent', 'askForHouseNumber')
Expand Down Expand Up @@ -80,7 +66,7 @@ const stateMap = {
transition('processIntent', 'goBack',
guard(({ misunderstandingCount }, { intent }) => intent.name === 'GoBackIntent' || misunderstandingCount > 3)
),
transition('processIntent', 'letYouKnow',
transition('processIntent', 'letYouKnowWOutageReport',
reduce(ctx => ({ ...ctx, misunderstandingCount: ctx.misunderstandingCount + 1 })),
),
),
Expand Down Expand Up @@ -116,7 +102,7 @@ const stateMap = {
reduce(ctx => ({ ...ctx, misunderstandingCount: ctx.misunderstandingCount + 1 })),
),
),
gotAllData: invoke(callOutageApi,
gotAllData: invoke(reportOutageAPI,
transition('done', 'reportAnOutage',
guard((ctx, {data: { result }}) => result === 'noOutage'),
reduce((ctx, { data }) => ({ ...ctx, attemptCount: ctx.attemptCount + 1 })),),
Expand Down
19 changes: 19 additions & 0 deletions lambda/service/reportOutageAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


// replace this with an api call
const reportOutageAPI = async ({houseNumber, phoneNumber}) => {
//console.log('outage reported', houseNumber, phoneNumber)

return [{
result: 'noOutage'
}, {
result: 'yesOutage',
impact: '300',
areaDescription: 'The pines neighborhood north of Park Street',
workDescription: 'Crews are on the scenen and expect repairs to complete in about an hour.'
}, {
result: 'badCombination'
}][houseNumber % 3]
}

module.exports = { reportOutageAPI }
Loading

0 comments on commit eb5ba91

Please sign in to comment.