Skip to content

Commit

Permalink
Merge pull request #6 from sethkor/fix-bot-naming
Browse files Browse the repository at this point in the history
Fix bot naming
  • Loading branch information
sethkor authored Sep 16, 2020
2 parents 81fed10 + d437e46 commit c958c77
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ your-lex-workspace
├──bots
└──monobot
```
When using the provision command for a mono bot, the `--name` flag is optional. If it is not present `lexbelt` will use the `lexBotName` in the monobot specification file.

You can take a look at examples/yaml/monobot/OrderFlowersMono.yaml to see an example monobot yaml file like so:
```
Expand Down
6 changes: 3 additions & 3 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type botYaml struct {
LexBot *lexmodelbuildingservice.PutBotInput `locationName:"lexBot" type:"structure"`
}

func putBot(svc *lexmodelbuildingservice.LexModelBuildingService, file string, poll int) {
func putBot(svc *lexmodelbuildingservice.LexModelBuildingService, file string, name string, poll int) {

var myBot botYaml
readAndUnmarshal(file, &myBot)
Expand All @@ -22,8 +22,8 @@ func putBot(svc *lexmodelbuildingservice.LexModelBuildingService, file string, p
log.Fatal("Yaml file is not as expected, please check your syntax.")
}

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

getResult, err := svc.GetBot(&lexmodelbuildingservice.GetBotInput{
Expand Down
2 changes: 0 additions & 2 deletions examples/yaml/config.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions lexbelt.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func main() {
case putIntentCommand.FullCommand():
putIntent(svc, (*putIntentCommandFile).Name())
case putBotCommand.FullCommand():
putBot(svc, (*putBotCommandFile).Name(), *putBotCommandPoll)
putBot(svc, (*putBotCommandFile).Name(), *putBotCommandName, *putBotCommandPoll)
case provisionCommand.FullCommand():
provision(svc, (*provisionCommandFile).Name(), *provisionCommandPoll)
provision(svc, (*provisionCommandFile).Name(), *provisionCommandName, *provisionCommandPoll)
}

}
12 changes: 6 additions & 6 deletions provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type provisionerSpecification struct {
} `locationName:"lexBotProvisioner" type:"structure"`
}

func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string, poll int) {
func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string, name string, poll int) {

var myProvisionerSpecification provisionerSpecification
readAndUnmarshal(file, &myProvisionerSpecification)
Expand All @@ -34,11 +34,11 @@ func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string
}

var myProvisioner provisioner
if *provisionCommandName != "" {
myProvisioner.LexBot.Name = putIntentCommandName
} else {
myProvisioner.LexBot.Name = myProvisionerSpecification.LexBotProvisioner.LexBotName

if name == "" {
name = *myProvisionerSpecification.LexBotProvisioner.LexBotName
}
myProvisioner.LexBot.Name = &name

//based on the mono bot yaml, load slots, intents and the bot and provision in the correct order

Expand All @@ -59,6 +59,6 @@ func provision(svc *lexmodelbuildingservice.LexModelBuildingService, file string

//lastly the bot
fmt.Println("Adding the bot and building it")
putBot(svc, basePath+"bots"+separator+*myProvisionerSpecification.LexBotProvisioner.LexBot, poll)
putBot(svc, basePath+"bots"+separator+*myProvisionerSpecification.LexBotProvisioner.LexBot, name, poll)

}

0 comments on commit c958c77

Please sign in to comment.