Is it possible to trigger intent-B from the lambda function of intent-A without prompting to user?
Suppose user typed something and an intent-A is fired, after some processing I want to trigger some other intent i.e intent-B.
User can also directly trigger intent-B through specific utterances.
Any help is appreciated.
You add a fallback intent by adding the built-in AMAZON. FallbackIntent intent type to your bot. You can specify the intent using the PutBot operation or by choosing the intent from the list of built-in intents in the console.
You can follow these steps:Create a Slot type with only one value i.e: HelloMe . Create an Utterances HelloMessage . Create a Slot as follow: Required, name: answer , Slot Type: HelloMe , Prompt: 'AutoWelcomePrompt'. Pick Amazon Lambda for your Fulfillment that will send a response to your user.
To create an intent In the Amazon Lex console, choose the plus sign (+) next to Intents, and then choose Create new intent. In the Create intent dialog box, type the name of the intent ( OrderPizza ), and then choose Add.
I ended up doing below to call intent-B from intent-A without prompting anything to user:
import boto3
client = boto3.client('lambda')
data = {'messageVersion': '1.0', 'invocationSource': 'FulfillmentCodeHook', 'userId': '###',
'sessionAttributes': {}, 'requestAttributes': None,
'bot': {'name': '###', 'alias': '$LATEST', 'version': '$LATEST'},
'outputDialogMode': 'Text',
'currentIntent': {'name': '###', 'slots': {'###': '###'},
'slotDetails': {'###': {'resolutions': [], 'originalValue': '###'}},
'confirmationStatus': 'None'},
'inputTranscript': '###'}
response = client.invoke(
FunctionName='{intent-B lambda function}',
InvocationType='RequestResponse',
Payload=json.dumps(data)
)
output = json.loads(response['Payload'].read())['dialogAction']['message']['content']
Yes it is possible .From the lambda of Intent-A , you can write the below code :
intentRequest.currentIntent.name='Intent-B';
var param1={
slot-B:null
};
intentRequest.currentIntent.slots=param1;
callback(elicitSlot(outputSessionAttributes, 'Intent-B', intentRequest.currentIntent.slots, 'slot-B'));
Below is the function for elicitSlot
function elicitSlot(sessionAttributes, intentName, slots, slotToElicit, message) {
return {
sessionAttributes,
dialogAction: {
type: 'ElicitSlot',
intentName,
slots,
slotToElicit,
message,
},
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With