Thanks, Mike!

My send_text_mesage method is just the code I posted in the article. It looks like this:

def send_text_message(sender, text)
body = {
recipient: {
id: sender
message: {
text: text

response ={page_access_token}",
body: body,
headers: { ‘Content-Type’ => ‘application/json’ }

It’s not a beauty, but it’s only a spike ;).

The `page_access_token` can be hardcoded (`page_access_token = “<paste_your_token_here>”` as the first line of this method, as long as this is just for playing. For a more serious application, you should get your page access token from ENV[‘PAGE_ACCESS_TOKEN’], so you don’t have to commit it to your repo (see If you want to make it easier for your development team, also use the secrets.yml to get the ENV variables into your application ( If you don’t know what the heck I’m talking about, just let me know and I’ll gladly do an article on the topic of ENV variables and secrets.yml :).

Written by

Agile Coach, Business Innovator, Software Engineer, Musician

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store