Your slot2 is continuously getting elicited because your first IF statement for slot1 continues to resolve as true, so it returns the elicit slot2 again to Lex, and the rest of your code, never gets reached.
You should consider including checks for if a slot is empty before checking what the value is. For example, I chose to write my bot's Lambda code as something like this:
--((pseudo code))--
if slot1 is empty then
elicit slot1
else --slot1 is filled
if slot1 is Yes then
if slot2 is empty then
elicit slot2
else --slot2 is filled
if slot3 is empty
elicit slot3
else --slot3 is filled
...and so on
end
else --slot1 is No
elicit slotDates
end
You can simplify it depending on your conversation flow, but that's the basic idea. The deeper into the conversation also brings you deeper into the nested if statements. And when you read the code, you can follow it down it's branches.
Side Tips (feel free to ignore this advice):
const optSlot1 = ['1','2'];
...
if(slot1 === optSlot1[0]) {...
This will be hard to understand as your bot becomes more complex because you will have to constantly scroll back out of your conversation logic to review the options for that slot. You can make it much easier on yourself, more natural for the user, and use more of Lex's built-in slot value recognition.
For example when you have a boolean question of Yes/No, then you can create a custom SlotType in Lex, provide 2 values "Yes" and "No", and then provide many synonyms for each such as "yea, yeah, yep, right, for sure, of course". This way, the bot can ask a natural open-ended question, and the user can respond naturally.
You should avoid using Lex like an old style automatic phone operator that spoon-feeds the user how to answer each question like this: "For Yes, please type 1. For No, please type 2" Lex is much more powerful than that.
So if you use Lex to determine what the user said and equate it to either "Yes" or "No" and fill the slot with one of those values, then your code would read like this:
const slot1 = event.slots.slot1
if (slot1 == "Yes") { ...
Much easier to read.