【发布时间】:2021-03-24 23:20:03
【问题描述】:
我正在尝试使用 Lex 构建一个聊天机器人来获取实例详细信息。我正在尝试使用 json 构建 Bot。当我导入 json 文件时,它说“请求中的 JSON 结构无效。检查 JSON 结构并再次尝试您的请求。” .. 尝试了几个代码和相同的问题. 我不认为问题出在代码上,但我错过了什么.. 或者请指导我使用 Json 文件创建一个 Bot。
谢谢
{
"name": "AWSBot",
"intents": [
{
"intentName": "RunningInstances",
"intentVersion": "7"
},
{
"intentName": "InstanceStatus",
"intentVersion": "2"
},
{
"intentName": "GetAddress",
"intentVersion": "2"
},
{
"intentName": "ShutdownReason",
"intentVersion": "9"
},
{
"intentName": "Discovery",
"intentVersion": "1"
},
{
"intentName": "StartInstance",
"intentVersion": "3"
},
{
"intentName": "GetLaunchTime",
"intentVersion": "1"
},
{
"intentName": "StopInstance",
"intentVersion": "3"
}
],
"clarificationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Sorry, can you please repeat that?"
}
],
"maxAttempts": 5
},
"abortStatement": {
"messages": [
{
"contentType": "PlainText",
"content": "Sorry, I could not understand. Goodbye."
}
]
},
"status": "READY",
"lastUpdatedDate": 1508081752.212,
"createdDate": 1495671152.723,
"idleSessionTTLInSeconds": 300,
"voiceId": "0",
"checksum": "4a7de68b-468c-43d0-8c6d-1e37e3f99ed3",
"version": "$LATEST",
"locale": "en-US",
"childDirected": false
}
{
"name": "RunningInstances",
"slots": [],
"sampleUtterances": [
"What's the number of running instances",
"Tell me how many instances are running.",
"How many servers are up"
],
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1498612715.974,
"createdDate": 1495671367.924,
"version": "$LATEST",
"checksum": "bd5811f5-9ae1-4381-8f4a-c9dda7f690c8"
}
{
"name": "InstanceStatus",
"slots": [],
"sampleUtterances": [
"Tell me the status of my instances.",
"Status report.",
"how are my instances"
],
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1498612653.385,
"createdDate": 1496013449.711,
"version": "$LATEST",
"checksum": "1525e15a-aa06-49c1-8031-68c14c861376"
}
{
"name": "GetAddress",
"slots": [
{
"name": "instance_id",
"slotConstraint": "Optional",
"slotType": "instance_id",
"slotTypeVersion": "2",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 1,
"sampleUtterances": []
},
{
"name": "short_code",
"slotConstraint": "Optional",
"slotType": "AMAZON.NUMBER",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 2,
"sampleUtterances": []
}
],
"sampleUtterances": [
"What is the IP address of instance {instance_id}",
"What is the IP address of instance {short_code}",
"what's the name of {instance_id}",
"what's the name of {short_code}",
"hostname {instance_id}",
"hostname {short_code}"
],
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1508081701.779,
"createdDate": 1499550333.168,
"version": "$LATEST",
"checksum": "5ae31dcd-fde0-4cb4-b57e-7cb0ed7de635"
}
{
"name": "ShutdownReason",
"slots": [
{
"name": "instance_id",
"slotConstraint": "Optional",
"slotType": "instance_id",
"slotTypeVersion": "2",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 1,
"sampleUtterances": []
},
{
"name": "short_code",
"slotConstraint": "Optional",
"slotType": "AMAZON.NUMBER",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "e.g. What city?"
}
],
"maxAttempts": 2
},
"priority": 2,
"sampleUtterances": []
}
],
"sampleUtterances": [
"Why is {instance_id} shut down",
"Why is {short_code} shut down",
"what's the reason for {instance_id} shutdown",
"what's the reason for {short_code} shutdown",
"why is {instance_id} off",
"why is {short_code} off"
],
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1498612810.201,
"createdDate": 1496798177.871,
"version": "$LATEST",
"checksum": "edbadfd6-e1e5-47c5-9cf7-22c06acde602"
}
{
"name": "Discovery",
"slots": [],
"sampleUtterances": [
"What can I ask you",
"What can you do",
"What functions do you have",
"Tell me your available functions"
],
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1499530232.691,
"createdDate": 1499530127.365,
"version": "$LATEST",
"checksum": "a4564397-238e-4c90-a4e4-c72e991c84c2"
}
{
"name": "StartInstance",
"slots": [
{
"name": "instance_id",
"slotConstraint": "Optional",
"slotType": "instance_id",
"slotTypeVersion": "2",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 1,
"sampleUtterances": []
},
{
"name": "short_code",
"slotConstraint": "Optional",
"slotType": "AMAZON.NUMBER",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which number?"
}
],
"maxAttempts": 2
},
"priority": 2,
"sampleUtterances": []
}
],
"sampleUtterances": [
"Start instance {instance_id}",
"Start instance {short_code}",
"start {instance_id}",
"start {short_code}",
"turn on {instance_id}",
"turn on {short_code}",
"Spin up {instance_id}",
"Spin up {short_code}"
],
"confirmationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Are you sure you want to start this instance?"
}
],
"maxAttempts": 3
},
"rejectionStatement": {
"messages": [
{
"contentType": "PlainText",
"content": "OK, I won't start this instance."
}
]
},
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1498612493.964,
"createdDate": 1497201911.538,
"version": "$LATEST",
"checksum": "3d24d22f-cf77-4d59-b773-14a2f3eda596"
}
{
"name": "GetLaunchTime",
"slots": [
{
"name": "instance_id",
"slotConstraint": "Optional",
"slotType": "instance_id",
"slotTypeVersion": "2",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 1,
"sampleUtterances": []
},
{
"name": "short_code",
"slotConstraint": "Optional",
"slotType": "AMAZON.NUMBER",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 2,
"sampleUtterances": []
}
],
"sampleUtterances": [
"When was {instance_id} started",
"When was {short_code} started",
"Uptime {instance_id}",
"Uptime {short_code}",
"Tell me when {instance_id} was launched",
"Tell me when {short_code} was launched"
],
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1503272964.782,
"createdDate": 1503272771.838,
"version": "$LATEST",
"checksum": "06328fa0-15b9-4875-a2e0-1b5f9ac1b940"
}
{
"name": "StopInstance",
"slots": [
{
"name": "instance_id",
"slotConstraint": "Optional",
"slotType": "instance_id",
"slotTypeVersion": "2",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which instance?"
}
],
"maxAttempts": 2
},
"priority": 1,
"sampleUtterances": []
},
{
"name": "short_code",
"slotConstraint": "Optional",
"slotType": "AMAZON.NUMBER",
"valueElicitationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Which number?"
}
],
"maxAttempts": 2
},
"priority": 2,
"sampleUtterances": []
}
],
"sampleUtterances": [
"Stop instance {instance_id}",
"Stop instance {short_code}",
"Stop {instance_id}",
"stop {short_code}",
"shut down {instance_id}",
"shut down {short_code}"
],
"confirmationPrompt": {
"messages": [
{
"contentType": "PlainText",
"content": "Are you sure you want to stop this instance?"
}
],
"maxAttempts": 3
},
"rejectionStatement": {
"messages": [
{
"contentType": "PlainText",
"content": "OK, I won't stop this instance."
}
]
},
"fulfillmentActivity": {
"type": "CodeHook",
"codeHook": {
"uri": "arn:aws:lambda:us-east-1:account-id:function:get-ec2-status",
"messageVersion": "1.0"
}
},
"lastUpdatedDate": 1498612645.996,
"createdDate": 1497202428.572,
"version": "$LATEST",
"checksum": "faa549de-c578-4448-8010-0b46f2757722"
}
预计 Bot 应该使用上面提到的插槽、话语等代码创建......
但它说错误..
【问题讨论】:
标签: json amazon-web-services aws-lambda chatbot amazon-lex