Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel
Ezequiel Jadib 6b3df2c0b3
Update documentation links to point to new docs (#118)
7 years ago
..
cb2098bf02
Rename ChannelData sample folder
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
764b4f820b
[CSharp] Update screenshots emulator on all samples
7 years ago
1cac51aaa5
Merge pull request #119
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
30905a12ed
[CSharp-ChannelData] Update to Microsoft.Bot.Builder v3.5.0
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
6b3df2c0b3
Update documentation links to point to new docs (#118)
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
30905a12ed
[CSharp-ChannelData] Update to Microsoft.Bot.Builder v3.5.0
7 years ago
3f9060c84f
[ChannelData] Update path on azuredeploy.json and Deploy button
7 years ago
cb2098bf02
Rename ChannelData sample folder
7 years ago
1cac51aaa5
Merge pull request #119
7 years ago

README.md

You have to be logged in to leave a comment. Sign In

ChannelData Bot Sample

A sample bot sending native metadata to Facebook using ChannelData.

Deploy to Azure

Prerequisites

The minimum prerequisites to run this sample are:

Code Highlights

If you want to be able to take advantage of special features or concepts for a channel we provide a way for you to send native metadata to that channel giving you much deeper control over how your bot interacts on a channel. The way you do this is to pass extra properties via the ChannelData property.

NOTE: You do not need to use this feature unless you feel the need to access functionality not provided by the normal Activity.

The Facebook adapter supports sending full attachments via the ChannelData field. This allows you to do anything natively that Facebook supports via the attachment schema, such as Send a check-in reminder message. Check out the ChannelDataDialog class where a new FacebookAttachment instance is send to the Facebook API using the ChannelData property.

private static FacebookAttachment GetFlightAttachment()
{
    return new FacebookAttachment()
    {
        Payload = new AirlineCheckIn()
        {
            IntroMessage = "Check-in is available now",
            Locale = "en_US",
            PnrNumber = "ABCDEF",
            CheckInUrl = "http://www.airline.com/check_in",
            FlightInfo = new[]
            {
                new FlightInfo()
                {
                    FlightNumber = "F001",
                    DepartureAirport = new Airport()
                    {
                        AirportCode = "SFO",
                        City = "San Francisco",
                        Terminal = "T4",
                        Gate = "G8"
                    },
                    ArrivalAirport = new Airport()
                    {
                        AirportCode = "EZE",
                        City = "Buenos Aires",
                        Terminal = "C",
                        Gate = "A2"
                    },
                    FlightSchedule = new FlightSchedule()
                    {
                        BoardingTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-ddTH:mm"),
                        DepartureTime = DateTime.Now.AddDays(1).AddHours(1.5).ToString("yyy-MM-ddTH:mm"),
                        ArrivalTime = DateTime.Now.AddDays(2).ToString("yyyy-MM-ddTH:mm")
                    }
                }
            }
        }
    };
}

Because the ChannelData is a dynamic property, it will hold any custom model class. In this sample, all Models classes were built to match the "attachment" JSON Schema described in the Facebook's Send API Reference. Check out the ChannelDataDialog class using the ChannelData property to send the Airline Checkin Reminder. Additionally, the sample includes very little logic to render the attachment appropriately for different channels.

if (message.ChannelId != "facebook")
{
    reply.Text = flightAttachment.ToString();
}
else
{
    reply.ChannelData = new FacebookChannelData()
    {
        Attachment = flightAttachment
    };
}

Outcome

You will see the following in the Bot Framework Emulator when opening and running the sample solution.

Sample Outcome Emulator

On the other hand, you will see the following in your Facebook Messenger.

Sample Outcome Facebook

More Information

To get more information about how to get started in Bot Builder for .NET and ChannelData please review the following resources:

Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...