Git Product home page Git Product logo

messenger's Introduction

See github.com/sSimuSs/messenger for an up-to-date fork of this repo.

Messenger GoDoc Build Status

This is a Go library for making bots to be used on Facebook messenger. It is built on the Messenger Platform. One of the main goals of the project is to implement it in an idiomatic and easy to use fashion.

You can find examples for this library here.

We tag our releases Semver style.

Tips

  • Follow the quickstart guide for getting everything set up!
  • You need a Facebook development app, and a Facebook page in order to build things.
  • Use ngrok to tunnel your locally running bot so that Facebook can reach the webhook.

Breaking Changes

In January 2019 we began tagging releases so that the package could be used properly with Go modules. Prior to that we simply maintained the following list to help users migrate between versions, it's staying here for legacy reasons. From now on, however, you should find breaking changes in the notes of a new release.

paked/messenger is a pretty stable library, however, changes will be made which might break backwards compatibility. For the convenience of its users, these are documented here.

  • 06/2/18: Added messaging_type field for message send API request as it is required by FB
  • 23/1/17: Updating timezone type to float64 in profile struct
  • 12/9/16: Removing unused parameter text string from function (r *Response) GenericTemplate.
  • 20/5/16: Leaving the WebhookURL field blank in Options will yield a URL of "/" instead of a panic.
  • 4/5/16: The URL to use for the webhook is changable in the Options struct.

Inspiration

Messenger takes design cues from:

Projects

This is a list of projects use messenger. If you would like to add your own, submit a Pull Request adding it below.

  • meme-maker by @paked: A bot which, given a photo and a caption, will create a macro meme.
  • drone-facebook by @appleboy: Drone.io plugin which sends Facebook notifications

messenger's People

Contributors

ahmdaeyz avatar albttx avatar appleboy avatar bwooce avatar depado avatar dezidermesko avatar dfischer avatar dgellow avatar dynbit avatar jbugman avatar kapsteur avatar machiel avatar mangalaman93 avatar micku avatar muxx avatar oayomide avatar opiuman avatar paked avatar panichmaxim avatar pranas avatar ramin0 avatar runivn avatar xuefeng-huang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

messenger's Issues

Default profile fields

According to the messenger docs, the default fields have changed and to access the other fields, one has to ask for access.

From my usage of other bots building libraries/software and also bare development without one, this will throw permission error and we'd have to change the default fields.

I am working on a simple PR to change these --the default fields.

Testing

I think it should be relatively easy to get some basic tests going, however it looks like it will be a pain to get any full blown integration tests happening.

Structured Responses

One of the cool features of the Facebook Messenger Platform is that it is possible to send "structured messages" like the following:

https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xta1/t39.2178-6/12679454_228093174215421_635988637_n.png

Currently we do not provide access to this section of the API. Obviously this functionality would be built into the Response structure.

I'm not quite sure what it would look like at the moment, but a start would be just to mirror to JSON structures for everything:

{
  "recipient":{
    "id":"USER_ID"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"What do you want to do next?",
        "buttons":[
          {
            "type":"web_url",
            "url":"https://petersapparel.parseapp.com",
            "title":"Show Website"
          },
          {
            "type":"postback",
            "title":"Start Chatting",
            "payload":"USER_DEFINED_PAYLOAD"
          }
        ]
      }
    }
  }
}

Then eventually we could add some sort of "API sugar", like Response.AddButton, Response.AddElement, etc.

Add send message without first receiving a message

At the moment it is impossible to send a message to a user out of the blue without some voodoo.

I'd suggest adding a Send(r Recipient, m string, replies []QuickReply) function onto the Messenger struct.

Debug mode

Hey there,

With some functions, like CallToActionsSetting sometimes Facebook rejects it, but no error is returned by the function. So I'm thinking of adding a debug mode to your package, would that be suitable to you ?
For example, simply by outputting the result of the request, I was able to see that I was doing something wrong :
{"error":{"message":"(#105) Number of call to actions exceeds the maximum allowed number"...}

Or maybe parse the response and check for that error field ?

Allow use of a config file

I think it is a good idea to allow people to use a config file. This allows separation of concern and you can be guaranteed that the configurations are in a separate file and can be changed at will.

Makes good for better dev experience. I have a PR for this ๐Ÿ™ƒ

IDs from webhooks are strings and not numbers.

I don't know if they were numbers before, but at least now, user IDs from webhooks are numbers in strings. i.e. the json would be like:

{"sender":{"id":"1259905410705036"},"recipient":{"id":"1175644529126109"}, "..." }

This can be fixed by changing the structs to use strings instead of int64, or use something during decoding to convert it to an int64.

Remove dependency on testify/assert

Looking at our mod file, we currently depend on testify/assert (and then it depends on another library) -- it seems we only actually use testify for some deep-equal checks in messenger_test.go.

I'd prefer it if we just wrote our own functions for this behavior in order to eliminate any dependencies we don't actually need.

Handling multiple pages

Is it possible, if so - how to handle multiple pages with the same endpoint?

Something like Chatfuel? When you connect your page and bot serves that page.

Dump way:

for i := 0; i < n; i++ {
   client := messenger.New(...)
   http.Handle("/messenger", client.Handler())
}

This throws error that "/messenger" already registered. Is there a smarter way to this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.