-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from sethkor/single-file-lex
Single file lex
- Loading branch information
Showing
21 changed files
with
657 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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, file string, poll int) { | ||
|
||
var myBot botYaml | ||
readAndUnmarshal(file, &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"), | ||
}) | ||
|
||
checkError(err) | ||
|
||
if currentStatus != *getResult.Status { | ||
currentStatus = *getResult.Status | ||
fmt.Printf("\n" + currentStatus) | ||
} else { | ||
fmt.Print(".") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
{ | ||
"intents": [ | ||
{ | ||
"intentVersion": "$LATEST", | ||
"intentName": "OrderFlowers" | ||
} | ||
], | ||
"name": "OrderFlowersBot", | ||
"locale": "en-US", | ||
"abortStatement": { | ||
"messages": [ | ||
"lexBot" : { | ||
"intents": [ | ||
{ | ||
"content": "Sorry, I'm not able to assist at this time", | ||
"contentType": "PlainText" | ||
"intentVersion": "$LATEST", | ||
"intentName": "OrderFlowers" | ||
} | ||
] | ||
}, | ||
"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" | ||
], | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
{ | ||
"name": "AskTime", | ||
"description": "Intent to ask what the time is", | ||
"version": "1", | ||
"sampleUtterances": [ | ||
"lexIntent" : { | ||
"name": "AskTime", | ||
"description": "Intent to ask what the time is", | ||
"version": "1", | ||
"sampleUtterances": [ | ||
"Whats the time", | ||
"What time is it", | ||
"Time please", | ||
"Time" | ||
], | ||
"slots": [], | ||
"fulfillmentActivity": { | ||
"codeHook": { | ||
"uri": "arn:aws:lambda:us-west-2:166330533654:function:LexLambdaSampleFulfilment", | ||
"messageVersion": "1.0" | ||
}, | ||
"type": "CodeHook" | ||
], | ||
"slots": [], | ||
"fulfillmentActivity": { | ||
"codeHook": { | ||
"uri": "arn:aws:lambda:ap-southeast-2:293499315857:function:LexLambdaSampleFulfilment", | ||
"messageVersion": "1.0" | ||
}, | ||
"type": "CodeHook" | ||
} | ||
} | ||
} |
Oops, something went wrong.