Skip to content

Commit

Permalink
Change yaml definition in preperation for specifying a mono bot
Browse files Browse the repository at this point in the history
  • Loading branch information
sethkor committed Sep 16, 2020
1 parent fd1181a commit e4d9ab8
Show file tree
Hide file tree
Showing 13 changed files with 389 additions and 296 deletions.
71 changes: 71 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package main

import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/lexmodelbuildingservice"
)

type botYaml struct {
LexBot *lexmodelbuildingservice.PutBotInput `locationName:"lexBot" type:"structure"`
}

func putBot(svc *lexmodelbuildingservice.LexModelBuildingService) {

var myBot botYaml
readAndUnmarshal((*putBotCommandFile).Name(), &myBot)

if myBot.LexBot == nil {
log.Fatal("Yaml file is not as expected, please check your syntax.")
}

if *putBotCommandName != "" {
myBot.LexBot.Name = putBotCommandName
}

getResult, err := svc.GetBot(&lexmodelbuildingservice.GetBotInput{
Name: myBot.LexBot.Name,
VersionOrAlias: aws.String("$LATEST"),
})

checkError(err)

myBot.LexBot.Checksum = getResult.Checksum

putResult, err := svc.PutBot(myBot.LexBot)

checkError(err)

//loop and poll the status
if !*dontWait {
currentStatus := *putResult.Status
fmt.Print(currentStatus)
for {

if currentStatus == "READY" {
fmt.Println()
break
} else if currentStatus == "FAILED" {
fmt.Printf("\n%s\n", *getResult.FailureReason)
break
}

time.Sleep((time.Duration(*poll) * time.Second))

getResult, err = svc.GetBot(&lexmodelbuildingservice.GetBotInput{
Name: myBot.LexBot.Name,
VersionOrAlias: aws.String("$LATEST"),
})

if currentStatus != *getResult.Status {
currentStatus = *getResult.Status
fmt.Printf("\n" + currentStatus)
} else {
fmt.Print(".")
}
}
}
}
27 changes: 14 additions & 13 deletions examples/yaml/bots/AskTime.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Talking Clock
description: A Lex bot that tells you the time
locale: en-US
voiceId: Salli
childDirected: false
idleSessionTTLInSeconds: 600
intents:
- intentName: AskTime
intentVersion: $LATEST
abortStatement:
messages:
- content: Sorry, I can't help you right now
contentType: PlainText
lexBot:
name: Talking Clock
description: A Lex bot that tells you the time
locale: en-US
voiceId: Salli
childDirected: false
idleSessionTTLInSeconds: 600
intents:
- intentName: AskTime
intentVersion: $LATEST
abortStatement:
messages:
- content: Sorry, I can't help you right now
contentType: PlainText
37 changes: 19 additions & 18 deletions examples/yaml/bots/OrderFlowersBot.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
intents:
- intentVersion: $LATEST
intentName: OrderFlowers
name: OrderFlowersBot
locale: en-US
abortStatement:
messages:
- content: Sorry, I'm not able to assist at this time
contentType: PlainText
clarificationPrompt:
maxAttempts: 2
messages:
- content: I didn't understand you, what would you like to do?
contentType: PlainText
voiceId: Salli
childDirected: false
idleSessionTTLInSeconds: 600
description: Bot to order flowers on the behalf of a user
lexBot:
intents:
- intentVersion: $LATEST
intentName: OrderFlowers
name: OrderFlowersBot
locale: en-US
abortStatement:
messages:
- content: Sorry, I'm not able to assist at this time
contentType: PlainText
clarificationPrompt:
maxAttempts: 2
messages:
- content: I didn't understand you, what would you like to do?
contentType: PlainText
voiceId: Salli
childDirected: false
idleSessionTTLInSeconds: 600
description: Bot to order flowers on the behalf of a user
41 changes: 21 additions & 20 deletions examples/yaml/bots/TalkingClock.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Another Clock
description: A Lex bot that tells you the time
locale: en-US
voiceId: Salli
childDirected: false
idleSessionTTLInSeconds: 600
intents:
- intentName: AskTime
intentVersion: $LATEST
- intentName: AskDay
intentVersion: $LATEST
clarificationPrompt:
maxAttempts: 3
messages:
- content: Sorry, I don't understand what you would like to do
contentType: PlainText
abortStatement:
messages:
- content: Sorry, I can't help you right now
contentType: PlainText
lexBot:
name: Another Clock
description: A Lex bot that tells you the time
locale: en-US
voiceId: Salli
childDirected: false
idleSessionTTLInSeconds: 600
intents:
- intentName: AskTime
intentVersion: $LATEST
- intentName: AskDay
intentVersion: $LATEST
clarificationPrompt:
maxAttempts: 3
messages:
- content: Sorry, I don't understand what you would like to do
contentType: PlainText
abortStatement:
messages:
- content: Sorry, I can't help you right now
contentType: PlainText
2 changes: 2 additions & 0 deletions examples/yaml/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
region: ap-southeast-2
profile: versent
27 changes: 14 additions & 13 deletions examples/yaml/intents/AskDay.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: AskDay
description: Intent to ask what the day is
version: 1
sampleUtterances:
- 'Whats the day'
- 'What day is it'
- 'Day please'
- 'Four'
fulfillmentActivity:
codeHook:
uri: arn:aws:lambda:us-west-2:166330533654:function:LexLambdaSampleFulfilment
messageVersion: "1.0"
type: CodeHook
lexIntent:
name: AskDay
description: Intent to ask what the day is
version: 1
sampleUtterances:
- 'Whats the day'
- 'What day is it'
- 'Day please'
- 'Four'
fulfillmentActivity:
codeHook:
uri: arn:aws:lambda:us-west-2:166330533654:function:LexLambdaSampleFulfilment
messageVersion: "1.0"
type: CodeHook
25 changes: 13 additions & 12 deletions examples/yaml/intents/AskTime.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: AskTime
description: Intent to ask what the time is
version: 1
sampleUtterances:
- 'Whats the time'
- 'What time is it'
- 'Time please'
fulfillmentActivity:
codeHook:
uri: arn:aws:lambda:ap-southeast-2:293499315857:function:LexLambdaSampleFulfilment
messageVersion: "1.0"
type: CodeHook
lexIntent:
name: AskTime
description: Intent to ask what the time is
version: 1
sampleUtterances:
- 'Whats the time'
- 'What time is it'
- 'Time please'
fulfillmentActivity:
codeHook:
uri: arn:aws:lambda:ap-southeast-2:293499315857:function:LexLambdaSampleFulfilment
messageVersion: "1.0"
type: CodeHook
101 changes: 51 additions & 50 deletions examples/yaml/intents/OrderFlowers.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
name: OrderFlowers
description: Intent to order a bouquet of flowers for pick up
sampleUtterances:
- I would like to pick up flowers
- I would like to order some flowers
slots:
- slotType: FlowerTypes
slotTypeVersion: $LATEST
name: FlowerType
slotConstraint: Required
valueElicitationPrompt:
maxAttempts: 2
messages:
- content: What type of flowers would you like to order?
contentType: PlainText
priority: 1
sampleUtterances:
- I would like to order {FlowerType}
description: The type of flowers to pick up
- slotType: AMAZON.DATE
name: PickupDate
slotConstraint: Required
valueElicitationPrompt:
maxAttempts: 2
messages:
- content: What day do you want the {FlowerType} to be picked up?
contentType: PlainText
priority: 2
description: The date to pick up the flowers
- slotType: AMAZON.TIME
name: PickupTime
slotConstraint: Required
valueElicitationPrompt:
maxAttempts: 2
messages:
- content: Pick up the {FlowerType} at what time on {PickupDate}?
contentType: PlainText
priority: 3
description: The time to pick up the flowers
confirmationPrompt:
maxAttempts: 2
messages:
- content: Okay, your {FlowerType} will be ready for pickup by {PickupTime} on {PickupDate}. Does this sound okay?
contentType: PlainText
rejectionStatement:
messages:
- content: Okay, I will not place your order.
contentType: PlainText
fulfillmentActivity:
type: ReturnIntent
lexIntent:
name: OrderFlowers
description: Intent to order a bouquet of flowers for pick up
sampleUtterances:
- I would like to pick up flowers
- I would like to order some flowers
slots:
- slotType: FlowerTypes
slotTypeVersion: $LATEST
name: FlowerType
slotConstraint: Required
valueElicitationPrompt:
maxAttempts: 2
messages:
- content: What type of flowers would you like to order?
contentType: PlainText
priority: 1
sampleUtterances:
- I would like to order {FlowerType}
description: The type of flowers to pick up
- slotType: AMAZON.DATE
name: PickupDate
slotConstraint: Required
valueElicitationPrompt:
maxAttempts: 2
messages:
- content: What day do you want the {FlowerType} to be picked up?
contentType: PlainText
priority: 2
description: The date to pick up the flowers
- slotType: AMAZON.TIME
name: PickupTime
slotConstraint: Required
valueElicitationPrompt:
maxAttempts: 2
messages:
- content: Pick up the {FlowerType} at what time on {PickupDate}?
contentType: PlainText
priority: 3
description: The time to pick up the flowers
confirmationPrompt:
maxAttempts: 2
messages:
- content: Okay, your {FlowerType} will be ready for pickup by {PickupTime} on {PickupDate}. Does this sound okay?
contentType: PlainText
rejectionStatement:
messages:
- content: Okay, I will not place your order.
contentType: PlainText
fulfillmentActivity:
type: ReturnIntent

21 changes: 11 additions & 10 deletions examples/yaml/slots/FlowerTypes.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Flower Types yaml
description: types of flowers to pick up from a yaml file
enumerationValues:
- value: tulips
synonyms:
- dutch
- holland
- value: lilies
- value: roses
- value: carnations
lextSlot:
name: Flower Types yaml
description: types of flowers to pick up from a yaml file
enumerationValues:
- value: tulips
synonyms:
- dutch
- holland
- value: lilies
- value: roses
- value: carnations
Loading

0 comments on commit e4d9ab8

Please sign in to comment.