function receivedGameplay()

in server-examples/nodejs-bot/bot.js [63:84]


  function receivedGameplay (event) {
    // Page-scoped ID of the bot user
    var senderId = event.sender.id;

    // FBInstant player ID:  event.game_play.player_id
    // FBInstant context ID: event.game_play.context_id
    // User's Page-scoped ID: event.sender.id

    // Check for payload
    if (event.game_play.payload) {
      //
      // The variable payload here contains data set by
      // FBInstant.setSessionData()
      //
      var payload = JSON.parse(event.game_play.payload);

      // In this example, the bot is just "echoing" the message received
      // immediately. In your game, you'll want to delay the bot messages
      // to remind the user to play 1, 3, 7 days after game play, for example.
      sendMessage(senderId, null, 'Want to play again?', 'Play now!', payload);
    }
  }