{"id":18785571,"url":"https://github.com/d-exclaimation/gomplifier-fb","last_synced_at":"2025-08-10T12:21:27.023Z","repository":{"id":103062344,"uuid":"335308186","full_name":"d-exclaimation/gomplifier-fb","owner":"d-exclaimation","description":"Go Facebook Messenger Bot ","archived":false,"fork":false,"pushed_at":"2021-02-03T12:18:25.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T12:39:16.873Z","etag":null,"topics":["bot","chatbot","facebook-api","facebook-graph-api","facebook-messenger-bot","facebook-messenger-chatbot","game","messenger","webservices","wrapper-library"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d-exclaimation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-02T14:03:50.000Z","updated_at":"2021-08-11T22:18:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7995504-4173-4d5a-950e-dcac35e47715","html_url":"https://github.com/d-exclaimation/gomplifier-fb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-exclaimation%2Fgomplifier-fb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-exclaimation%2Fgomplifier-fb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-exclaimation%2Fgomplifier-fb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-exclaimation%2Fgomplifier-fb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-exclaimation","download_url":"https://codeload.github.com/d-exclaimation/gomplifier-fb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239701801,"owners_count":19682975,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","chatbot","facebook-api","facebook-graph-api","facebook-messenger-bot","facebook-messenger-chatbot","game","messenger","webservices","wrapper-library"],"created_at":"2024-11-07T20:48:49.252Z","updated_at":"2025-02-19T17:25:48.923Z","avatar_url":"https://github.com/d-exclaimation.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gomplifier-fb\n A bot for Facebook Messanger Graph API\n\n## Overview\nThis is another piece of a project I am building, the project is related to bots and servers as services.\n\nThis is the code to create a bot using [`Gin`](https://github.com/gin-gonic/gin) for Web Server and my implementation of Facebook API Library/Wrapper/Thing idk for Golang,\n\n## Facebook Graph API for Messnger\nThe Facebook API for Messenger is a lot more involved since their API focuses on being language-agnostic and thus, not provide a single library / way to communicate back and forward\n\nI'm using Gin to setup a simple web server to take the POST and GET Request Required, to be fair any http libraries would work. The difficult part is to parse the json given.\n\nI'm taking the approach of creating full struct with all the optionals for each JSON and have `omitempty` with `pointer` create `nil` for value not given to deal with the dynamic nature of the JSON given back.\n\n```go\ntype MessagingEvent struct {\n\tSender    FbUser    `json:\"sender\"`\n\tRecipient FbUser    `json:\"recipient\"`\n\tTimestamp int64     `json:\"timestamp\"`\n\tMessage   *Message  `json:\"message,omitempty\"`\n\tPostback  *Postback `json:\"postback,omitempty\"`\n}\n```\n\u003e This example of mine only ask for `messages` and `messages_postback` events. Facebook allows you to customize what event you want to listen to\n\nFor sending one back, I'm using empty implementation interfaces to differs one type from another with no custom Marshalling or Unmarshalling.\n\nNote that a dynamic language like Javascript would probably be more easier to use. However, I worry that when things got complex, I might struggle with the dynamic nature\n\n```go\n// Setup HTTP Server for receiving requests from LINE platform\napp.POST(\"/webhook\", func(context *gin.Context) {\n\tvar body models.FbPostHook\n\n\tif err := context.BindJSON(\u0026body); err != nil {\n\t\tlog.Println(err)\n\t\tcontext.String(http.StatusOK, \"Cannot parse JSON so lol\")\n\t\treturn\n\t}\n\n\tif body.Object == \"page\" {\n\t\tfor i := 0; i \u003c len(body.Entry); i++ {\n\t\t\tvar webhookEvent = body.Entry[i].Messaging[0]\n\t\t\tif webhookEvent.Message != nil {\n\n\t\t\t\t// Handle message events\n\t\t\t\tevents.HandleMessageEvent(webhookEvent.Sender.ID, webhookEvent.Message, gameDocument)\n\n\t\t\t} else if webhookEvent.Postback != nil {\n\n\t\t\t\t// Handle Postback events\n\t\t\t\tevents.HandlePostBackEvent(webhookEvent.Sender.ID, webhookEvent.Postback)\n\t\t\t}\n\t\t}\n\t\tcontext.String(http.StatusOK, \"\")\n\t\treturn\n\t}\n\n\tcontext.String(http.StatusNotFound, \"Wrong item\")\n})\n```\n\n## Bot functionalities\n\n### Commands:\n\u003e 1. Play Sokoban `!start =\u003e w, a, s, d`\n\nI haven't added all the commands I wanted but since I already made a Go chatbot, the logic can be reimplemented relatively easily here as well. \n\nThis is one of the reason I am using Go for this project instead of Javascript, Typescript or Rust\n\n### Connecting to other bots\n\n`Again, No info here yet, I am keeping this for myself atm sorry :)`\n\n\n### Facebook API Library Wrapper for Go\nSince I implemented my own structs to parse and send back JSON to the API, I am thinking of making that part of the code as its own libraries to be re-used by me or anyone else\n\nHopefully, this part of code will live as its own libraries which I will link here:\n#### Facebook Messenger API Library / Wrapper / stuff\n[`not yet`](https://github.com/d-exclaimation/gomplifier-fb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-exclaimation%2Fgomplifier-fb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-exclaimation%2Fgomplifier-fb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-exclaimation%2Fgomplifier-fb/lists"}