Search code examples
alexa-skills-kit

How to give the response if the user give unknow intent name in alexa


I created PHP webhook and used https service to call the intent response, but when user says unknow intent name it must give the response sorry.

but I didn't get the response.

My code

if(intent->name="name of intent") {
   echo response
}
else if(intent->name="name of intent") {
   echo response
}
else{
   echo response
}

But I'm not getting into else part


Solution

  • In your code:

    if(intent->name="name of intent") {
       echo response
    }
    else if(intent->name="name of intent") {
       echo response
    }
    else{
       echo response
    }
    

    you are using "=" instead of "==" and hence it never goes to else part.

    edited code:

    if(intent->name=="name of intent") {
       echo response
    }
    else if(intent->name=="name of intent") {
       echo response
    }
    else{
       echo response
    }