Bot Framework v4 echo bot using facebook Adapter sample.
This bot has been created using Bot Framework, it shows how to create a simple echo bot that connects with Facebook to respond to messages.
-
.NET Core SDK version 3.1
# determine dotnet version dotnet --version
-
Clone the repository
git clone https://github.com/Microsoft/BotBuilder-Samples.git
-
Connect the bot with Facebook by following the instructions below.
-
Run the bot from a terminal or from Visual Studio:
A) From a terminal, navigate to
BotBuilder-Samples/samples/csharp_dotnetcore/61.facebook-adapter
# run the bot dotnet run
B) Or from Visual Studio
- Launch Visual Studio
- File -> Open -> Project/Solution
- Navigate to
BotBuilder-Samples/samples/csharp_dotnetcore/61.facebook-adapter
folder - Select
FacebookAdapterBot.csproj
file - Press F5 to run the project
Populate settings for Facebook App secret, Access Token and Verify Token in appsettings.json
file.
Instructions about how to create / configure a Facebook App for your bot and where to obtain the values for the settings can be found in the documentation covering connecting a bot to Facebook using the Facebook adapter.
{
"FacebookVerifyToken": "",
"FacebookAppSecret": "",
"FacebookAccessToken": ""
}
To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.
You can test your bot is connected to Facebook correctly by sending a message via the Facebook Page you associated with your new Facebook App.
-
Navigate to your Facebook Page.
-
Click Add a Button button.
- Select Contact You and Send Message and click Next.
- When asked Where would you like this button to send people to? select Messenger and click Finish.
- Hover over the new Send Message button that is now shown on your Facebook Page and clikc Test Button from the popup menu. This will start a new conversation with your app via Facebook Messenger, which you can use to test messaging your bot. Once the message is receieved by your bot it will send a message back to you, echoing the text from your message.