Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bot naming #6

Merged
merged 3 commits into from
Sep 16, 2020
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
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)

}