typeform-to-facebook-messenger

1.0.4 • Public • Published

Typeform To Facebook Messenger

A library to transform typeform questions to responses for Facebook messenger

Usage

  • npm i to install dependencies
  • npm t to run the tests

To see the library in action:

  • Set up a facebook page.
  • Obtain the recipient PSID/ ADMIN_ID, this would be the ID of your facebook account, not the ID of the bot.
  • Use postman to simulate a request as described here

Function available

The library translates several Typeform questions in a way that Facebook's Messenger can understand. The functions available are:

  translateWelcomeScreen,
  translateThankYouScreen,
  translateShortText,
  translateLongText,
  translateNumber,
  translateStatement,
  translateYesNo,
  translateMultipleChoice,
  translateDropDown,
  translateEmail,
  translateOpinionScale,
  translateRatings,
  translatePictureChoice,
  translateDate,
  translateLegal,

Import them into your code:

const { translateShortText } = require('typeform-to-facebook-messenger')

To send a request to facebook messenger:

function callSendAPI(sender_psid, response) {
  // Construct the message body
  let request_body = {
    "recipient": {
      "id": sender_psid
    },
    "message": translateShortText(typeform.fields[0]) //e.g. if the first question from your Typeform form is of type "short_text"
  }
}

Contributions

If there is any typeform question type I have missed, or if you think there is a better way to representa Typeform question type in Facebook Messenger than the way I've done it, contributions welcomed!

Readme

Keywords

none

Package Sidebar

Install

npm i typeform-to-facebook-messenger

Weekly Downloads

2

Version

1.0.4

License

ISC

Unpacked Size

27.5 kB

Total Files

9

Last publish

Collaborators

  • isabellachen