Help please with JS code

can any one please help me with below code what is wrong with it the function is not working


function receivedMessage(event) {
  var senderID = event.sender.id;
  var recipientID = event.recipient.id;
  var timeOfMessage = event.timestamp;
  var message = event.message;

  
  console.log("Received message for user %d and page %d at %d with message:", 
    senderID, recipientID, timeOfMessage);
  console.log(JSON.stringify(message));

  var messageId = message.mid;

  
  var messageText = message.text().toLowerCase();
 
  var messageAttachments = message.attachments;
  
 


  
  if (messageText.indexOf('') > -1) { 
  

    switch (messageText) {  
        
      case 'hi' :case 'hey':
      sendTextMessage(senderID, "Hello, How can i help you");
        break;
      
    }
  } else if (messageAttachments) {
    sendTextMessage(senderID, "Message with attachment received");
  }
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

Can you explain what you expect to happen and what you are seeing instead?

Please see my above post on how to format code. (If this is the same code that you included above, adding it again is just confusing.)
Note: you can edit your previous post.

In terms of helping you with your project, we need to know the answers to @RandellDawson’s questions before we could even start to help.

thanks @RandellDawson i am actually no coder ,with no knowledge of code, but i working on a FB bot and want the function that if i received a massage with specific word in the massage sentence to reply with specific massage

that’s it :slight_smile: