{"id":15524359,"url":"https://github.com/codeforequity-at/botium-connector-fbwebhook","last_synced_at":"2025-04-23T07:31:33.273Z","repository":{"id":52990883,"uuid":"214011203","full_name":"codeforequity-at/botium-connector-fbwebhook","owner":"codeforequity-at","description":"Botium Connector for Facebook Webhooks","archived":false,"fork":false,"pushed_at":"2021-04-10T18:15:29.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T22:41:20.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeforequity-at.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-09T19:55:07.000Z","updated_at":"2021-04-10T18:14:29.000Z","dependencies_parsed_at":"2022-08-28T12:14:05.167Z","dependency_job_id":null,"html_url":"https://github.com/codeforequity-at/botium-connector-fbwebhook","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforequity-at%2Fbotium-connector-fbwebhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforequity-at%2Fbotium-connector-fbwebhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforequity-at%2Fbotium-connector-fbwebhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforequity-at%2Fbotium-connector-fbwebhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeforequity-at","download_url":"https://codeload.github.com/codeforequity-at/botium-connector-fbwebhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391289,"owners_count":21422873,"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":[],"created_at":"2024-10-02T10:51:03.982Z","updated_at":"2025-04-23T07:31:33.235Z","avatar_url":"https://github.com/codeforequity-at.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Botium Connector for Facebook Webhooks\n\n[![NPM](https://nodei.co/npm/botium-connector-fbwebhook.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/botium-connector-fbwebhook/)\n\n[![Codeship Status for codeforequity-at/botium-connector-fbwebhook](https://app.codeship.com/projects/e0c1ab60-cd7e-0137-d7fc-36d20f9c8e15/status?branch=master)](https://app.codeship.com/projects/368651)\n[![npm version](https://badge.fury.io/js/botium-connector-fbwebhook.svg)](https://badge.fury.io/js/botium-connector-fbwebhook)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()\n\nThis is a [Botium](https://github.com/codeforequity-at/botium-core) connector for testing your [Facebook Messenger Platform Webhooks](https://developers.facebook.com/docs/messenger-platform/).\n\n__Did you read the [Botium in a Nutshell](https://medium.com/@floriantreml/botium-in-a-nutshell-part-1-overview-f8d0ceaf8fb4) articles ? Be warned, without prior knowledge of Botium you won't be able to properly use this library!__\n\n## How it works ?\nBotium emulates the [Facebook Messenger Platform](https://developers.facebook.com/docs/messenger-platform/)\n* It sends inbound messages to your webhook\n* It listens for outbound messages from your webhook\n\n__Redis__ is used to connect the webhook to Botium scripts: all messages received over the webhook are published to Redis, and Botium on the other end subscribes to those Redis channels before running a conversation. \n\nYou have to setup your webhook to send outbound messages to the endpoint started with `botium-cli inbound-proxy`\n instead of the real Facebook endpoint at https://graph.facebook.com. Depending on the technology you are using, there are several options to do this:\n\n* If your technology allows to simply change the endpoint url, then this is the preferred way\n* If you are using Node.js, there is a demo in _samples/botkit-bot_ how to use [Nock](https://github.com/nock/nock) to intercept network traffic to the original Facebook endpoint\n* You can try to configure a HTTP-Proxy for your technology\n\nIt can be used as any other Botium connector with all Botium Stack components:\n* [Botium CLI](https://github.com/codeforequity-at/botium-cli/)\n* [Botium Bindings](https://github.com/codeforequity-at/botium-bindings/)\n* [Botium Box](https://www.botium.at)\n\n## Requirements\n\n* __Node.js and NPM__\n* a __Facebook Messenger Platform Webhook__\n* a __Redis__ instance (Cloud hosted free tier for example from [redislabs](https://redislabs.com/) will do as a starter)\n* a __project directory__ on your workstation to hold test cases and Botium configuration\n\n## Install Botium and Facebook Webhook Connector\n\nWhen using __Botium CLI__:\n\n```\n\u003e npm install -g botium-cli\n\u003e npm install -g botium-connector-fbwebhook\n\u003e cd \u003cyour working dir\u003e\n\u003e botium-cli init\n\u003e botium-cli run\n```\n\nWhen using __Botium Bindings__:\n\n```\n\u003e npm install -g botium-bindings\n\u003e npm install -g botium-connector-fbwebhook\n\u003e botium-bindings init mocha\n\u003e npm install \u0026\u0026 npm run mocha\n```\n\nWhen using __Botium Box__:\n\n_Already integrated into Botium Box, no setup required_\n\n## Connecting your Facebook Webhook to Botium\n\nOpen the file _botium.json_ in your working directory and add the webhook url and Redis connection settings.\n\n```\n{\n  \"botium\": {\n    \"Capabilities\": {\n      \"PROJECTNAME\": \"\u003cwhatever\u003e\",\n      \"CONTAINERMODE\": \"fbwebhook\",\n      \"FBWEBHOOK_WEBHOOKURL\": \"...\",\n      \"SIMPLEREST_INBOUND_REDISURL\": \"redis://127.0.0.1:6379\"\n    }\n  }\n}\n```\nBotium setup is ready, you can begin to write your [BotiumScript](https://github.com/codeforequity-at/botium-core/wiki/Botium-Scripting) files.\n\n__Important: The `inbound-proxy` command has to be started with Botium CLI. Otherwise, Botium scripts will fail to receive any input or output messages from your chatbot!__\n\n### Facebook Referrals\n\nFor simulating referral parameters (see [Facebook Docs](https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_referrals)), the _UPDATE_CUSTOM_ logic hook can be used.\n\nSimulating an _m.me_-link with a referral parameter:\n\n    #me\n    UPDATE_CUSTOM SET_FB_REFERRAL_MME|some referral parameter\n\nSimulating another referral type by specifying JSON code:\n\n    #me\n    UPDATE_CUSTOM SET_FB_REFERRAL|{\"ref\": \"\u003cREF_DATA_IF_SPECIFIED_IN_THE_AD\u003e\", \"ad_id\": \"\u003cID_OF_THE_AD\u003e\", \"source\": \"ADS\", \"type\": \"OPEN_THREAD\", \"ads_context_data\": {\"ad_title\": \"\u003cTITLE_OF_THE_AD\u003e\", \"photo_url\": \"\u003cURL_OF_THE_IMAGE_FROM_AD_THE_USER_IS_INTERESTED_IN\u003e\", \"video_url\": \"\u003cTHUMBNAIL_URL_OF_THE_VIDEO_FROM_THE_AD\u003e\", \"post_id\": \"\u003cID_OF_THE_POST\u003e\"}}\n\n## Running the Samples\n\nInstall botium-core as peerDependency \n\n    \u003e npm install --no-save botium-core\n\nAfterward in the folder _samples/botkit-bot_ there is an example for a simple Facebook Webhook chatbot - it is one of the samples of [Botkit](https://github.com/howdyai/botkit). Start the webhook:\n\n    \u003e cd samples/botkit-bot \u0026\u0026 npm install \u0026\u0026 npm run start:botium\n\nFinally navigate into the samples/simple and run `npm install`, start the inbound proxy server \nand run the test itself with the following commands:\n\n     \u003e cd samples/simple\n     \u003e npm install\n     \u003e npm run inbound\n     \u003e npm test\n\n## Supported Capabilities\n\nSet the capability __CONTAINERMODE__ to __fbwebhook__ to activate this connector.\n\n### FBWEBHOOK_WEBHOOKURL\nThe URL of your Facebook Messenger Platform webhook\n\n### FBWEBHOOK_TIMEOUT\nWebhook timeout in milliseconds (default: 10000 = 10 seconds)\n\n### FBWEBHOOK_PAGEID\nIf your webhook expects a special Facebook Page ID to process messages, you can add one here (default: 123456)\n\nThe Facebook Page ID can also be set in the test case spec itself:\n\n    #begin\n    UPDATE_CUSTOM FBWEBHOOK_PAGEID|77777777\n\n### FBWEBHOOK_USERID\nIf your webhook expects a special Facebook User ID to process messages, you can add one here (default: 10 random digits)\n\nThe Facebook User ID can also be set in the test case spec itself:\n\n    #begin\n    UPDATE_CUSTOM FBWEBHOOK_USERID|66666666\n\n### FBWEBHOOK_APPSECRET\nIf your webhook is [validating](https://developers.facebook.com/docs/messenger-platform/webhook#security) the _X-Hub-Signature_-header (it should!), then you have to give the Facebook App Secret to Botium to be able to generate this signature (default: empty)\n\n## Open Issues and Restrictions\n\n* Currently only plain text, quick replies, buttons and cards are supported\n* Currently only individual receivers supported\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforequity-at%2Fbotium-connector-fbwebhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeforequity-at%2Fbotium-connector-fbwebhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforequity-at%2Fbotium-connector-fbwebhook/lists"}