1
{
  "messageVersion": "1.0",
  "invocationSource": "DialogCodeHook",
  "userId": "xxx",
  "sessionAttributes": {
    "currentReservation": ""
  },
  "requestAttributes": {

  },
  "bot": {
    "name": "BookTrip",
    "alias": "shoping",
    "version": "7"
  },
  "outputDialogMode": "Text",
  "currentIntent": {
    "name": "Shoping",
    "slots": {
      "offer": "Yes",
      "email_address": null
    },
    "slotDetails": {
      "offer": {
        "resolutions": [{
          "value": "Yes"
        }],
        "originalValue": "Yes"
      },
      "email_address": {
        "resolutions": [],
        "originalValue": null
      }
    },
    "confirmationStatus": "None"
  },
  "inputTranscript": "<mailto:xxx.20@gmail.com|xxx.20@gmail.com>"
}

When bot asks for email address. User entered xxx.20@gmail.com for the email_address slot.

But when the request comes from the slack, it is not coming in the slot.

double-beep
  • 5,031
  • 17
  • 33
  • 41

1 Answers1

0

Lex is not able to recognize the input as an email because Slack is wrapping the actual input with <mailto:...|...>. You can see the input that Lex is provided in the inputTranscipt value of the event.

I'm assuming you have Lex connected directly to Slack, and that you are using a Lambda Function.

In Lambda, you will have to parse the inputTranscript and fill the slot yourself. You can try something like this (Node.js):

var userInput = event["inputTranscript"];

var email = userInput .split("|");
email = email[1].replace(">","");

console.log(email);
event["currentIntent"]["slots"]["email_address"] = email;

You should only do the above after user inputs their email. It will take the whole input from Slack, including the mailto: wrapper tag and split that in half as an array. Then it takes the second half and removes the ">" at the end. You should then be left with the pure email, as the user had originally input it. Then set that in the slot. As you pass the slots back to lex in the response, Lex will then recognize the email_address slot as filled.

You may have to process the inputTranscript often like this. I have found that keeping track of the last elicited slot in a sessionAttribute helps me determine where in the conversation I need to parse the input in specific ways.

Jay A. Little
  • 3,239
  • 2
  • 11
  • 32