jgorset / facebook-messenger

Definitely the best way to make Bots on Facebook Messenger with Ruby
MIT License
962 stars 211 forks source link

not able to retrive postback title text from the object #184

Closed Manidavid closed 7 years ago

Manidavid commented 7 years ago

Need text of the title from the postback object.

<Facebook::Messenger::Incoming::Postback:0x0000000006416d00 @messaging={"recipient"=>{"id"=>"124495678232012"}, "timestamp"=>1510297448580, "sender"=>{"id"=>"1525496340849520"}, "postback"=>{"payload"=>"GET_STARTED_PAYLOAD", "title"=>"Get Started"}}>

something like - postback.text should return "Get Started"

navidemad commented 7 years ago

As you can see on lib/facebook/messenger/incoming/postback.rb

You should do: postback.payload["title"]

Manidavid commented 7 years ago

postback.payload["title"] - it returns 'nil' instead of the title sting - Get Started

on [lib/facebook/messenger/incoming/postback.rb]()

def payload
  @messaging['postback']['payload']
end
def title
  @messaging['postback']['title']
end

I guess need to add method something likedef titleto get the title text.

Manidavid commented 7 years ago

@navidemad any suggestion on my above code?

Manidavid commented 7 years ago

i able to get the title from the below code title = postback.messaging['postback']['title']