messages.js
// Send test message back as two cards
Send test message back as two cards
Send test message back as two cards
function sendGenericMessage(sender) {
    let messageData = {
        "attachment": {
            "type": "template",
            "payload": {
                "template_type": "generic",
                "elements": [{
                    "title": "First card",
                    "subtitle": "Element #1 of an hscroll",
                    "image_url": "http://messengerdemo.parseapp.com/img/rift.png",
                    "buttons": [{
                        "type": "web_url",
                        "url": "https://www.messenger.com",
                        "title": "web url"
                    }, {
                        "type": "postback",
                        "title": "Postback",
                        "payload": "Payload for first element in a generic bubble",
                    }],
                }, {
                    "title": "Second card",
                    "subtitle": "Element #2 of an hscroll",
                    "image_url": "http://messengerdemo.parseapp.com/img/gearvr.png",
                    "buttons": [{
                        "type": "postback",
                        "title": "Postback",
                        "payload": "Payload for second element in a generic bubble",
                    }],
                }]
            }
        }
    }
    request({
        url: 'https://graph.facebook.com/v2.6/me/messages',
        qs: {access_token:token},
        method: 'POST',
        json: {
            recipient: {id:sender},
            message: messageData,
        }
    }, function(error, response, body) {
        if (error) {
            console.log('Error sending messages: ', error)
        } else if (response.body.error) {
            console.log('Error: ', response.body.error)
        }
    })
}
function sendGenericMessage ( sender ) { let messageData = { "attachment" : { "type" : "template" , "payload" : { "template_type" : "generic" , "elements" : [ { "title" : "First card" , "subtitle" : "Element #1 of an hscroll" , "image_url" : "http://messengerdemo.parseapp.com/img/rift.png" , "buttons" : [ { "type" : "web_url" , "url" : "https://www.messenger.com" , "title" : "web url" } , { "type" : "postback" , "title" : "Postback" , "payload" : "Payload for first element in a generic bubble" , } ] , } , { "title" : "Second card" , "subtitle" : "Element #2 of an hscroll" , "image_url" : "http://messengerdemo.parseapp.com/img/gearvr.png" , "buttons" : [ { "type" : "postback" , "title" : "Postback" , "payload" : "Payload for second element in a generic bubble" , } ] , } ] } } } request ( { url : 'https://graph.facebook.com/v2.6/me/messages' , qs : { access_token : token } , method : 'POST' , json : { recipient : { id : sender } , message : messageData , } } , function ( error , response , body ) { if ( error ) { console . log ( 'Error sending messages: ' , error ) } else if ( response . body . error ) { console . log ( 'Error: ' , response . body . error ) } } ) }
Send test message back as two cards
Send test message back as two cards