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

Fix go back #3

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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