https://github.com/nbransby/dialogue-builder-example
Example of using https://github.com/nbransby/dialogue-builder
https://github.com/nbransby/dialogue-builder-example
bot-builder dialogue-builder facebook-messenger messenger-bot typescript
Last synced: 20 days ago
JSON representation
Example of using https://github.com/nbransby/dialogue-builder
- Host: GitHub
- URL: https://github.com/nbransby/dialogue-builder-example
- Owner: nbransby
- Created: 2017-01-26T01:44:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T23:53:26.000Z (about 9 years ago)
- Last Synced: 2025-03-02T05:28:57.538Z (over 1 year ago)
- Topics: bot-builder, dialogue-builder, facebook-messenger, messenger-bot, typescript
- Language: TypeScript
- Homepage:
- Size: 23.4 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dialogue-builder-example
A working example of a bot utilising dialogue-builder including persistence of dialogue state.
This example is written in TypeScript and consists of two files `bot.ts` and `onboarding.ts`, (`bot.js` and `onboarding.js` contain the transpiled TypeScript - not a pretty sight).
There is also `bot.esnext.js` and `onboarding.esnext.js` which is my attempt to implement the example without TypeScript but still using all the advanced JS syntax such as async/await and object destructuring. Although I haven't tried it myself, by using babel it should be possible to compile this down to es5 which is necessary to run on AWS Lambda.
Dialogue Builder depends on [bot-builder](https://github.com/claudiajs/claudia-bot-builder) by [claudia.js](https://claudiajs.com/) who's [command line tool](https://claudiajs.com/documentation.html#args) supports deploying to AWS Lambda. But in this example we use the [Serverless Framework](https://serverless.com/) for deployment as it also supports automated provisioning of DynamoDB instances which is used in this example to store the dialog state.
#### To deploy this example so you can test it in Facebook Messenger you will need to do the following:
* #####Create a Facebook App
> Create a new [Facebook App](https://developers.facebook.com/apps) or use an existing one. In the `serverless.yml` file, replace `REPLACE_WITH_APP_SECRET` with your Facebook App Secret
* #####Create a Facebook Page
> Create a new [Page](https://www.facebook.com/pages/create) or use an existing one, then go to the App Dashboard and under Product Settings click "Add Product" and select "Messenger."
>

>
In the Token Generation section, select your Page. A Page Access Token will be generated for you.
>

>
In the `serverless.yml` file, replace`REPLACE_WITH_PAGE_ACCESS_TOKEN` with your Page Access Token
* #####Install serverless and setup your AWS account credentials on your machine
> https://serverless.com/framework/docs/providers/aws/guide/installation/
>
Make sure to also follow [these instructions](https://serverless.com/framework/docs/providers/aws/guide/credentials) on setting up AWS credentials
* #####Run the following in the root of this directory and, once complete, copy the URL returned
npm install
serverless deploy
* #####Setup the Webhook on Facebook with the URL as the Callback URL and `SOMETHING_RANDOM` as the verify token
> In the Webhooks section, click "Setup Webhooks."
>

>
Enter a URL for a webhook, enter a Verify Token and select `messages` and `messaging_postbacks` under Subscription Fields.
>

* #####Subscribe the App to the Page on Facebook
> In the Webhooks section, you can subscribe the webhook for a specific page.
>
> 
* #####Try your new bot
>Go to your Facebook Page and send a message to it. The bot should respond!
>
