From f70a344a957e48094f7e813cbc84ce118aff99a1 Mon Sep 17 00:00:00 2001
From: "Matt Shim (TEKsystems)"
Date: Thu, 30 Mar 2017 10:48:12 -0700
Subject: [PATCH] added blog examples to Node and Csharp
---
CSharp/Blog-CustomChannelData/.gitattributes | 63 +++++
CSharp/Blog-CustomChannelData/.gitignore | 245 ++++++++++++++++++
.../App_Start/WebApiConfig.cs | 36 +++
.../Azure_Bot_Generic_CSharp.csproj | 181 +++++++++++++
.../Azure_Bot_Generic_CSharp.sln | 22 ++
.../Controllers/MessagesController.cs | 89 +++++++
.../Dialogs/ShareButtonDialog.cs | 54 ++++
CSharp/Blog-CustomChannelData/Global.asax | 1 +
CSharp/Blog-CustomChannelData/Global.asax.cs | 17 ++
.../Models/FacebookAttachment.cs | 24 ++
.../Models/FacebookButton.cs | 36 +++
.../Models/FacebookButtonTemplate.cs | 32 +++
.../Models/FacebookChannelData.cs | 14 +
.../Models/FacebookGenericTemplate.cs | 18 ++
.../Models/FacebookGenericTemplateContent.cs | 26 ++
.../Models/FacebookShareButton.cs | 21 ++
.../Properties/AssemblyInfo.cs | 35 +++
.../Blog-CustomChannelData/Web.Debug.config | 30 +++
.../Blog-CustomChannelData/Web.Release.config | 31 +++
CSharp/Blog-CustomChannelData/Web.config | 68 +++++
CSharp/Blog-CustomChannelData/default.htm | 12 +
CSharp/Blog-CustomChannelData/packages.config | 15 ++
.../node_custom_channel.js | 80 ++++++
Node/blog-customChannelData/package.json | 35 +++
24 files changed, 1185 insertions(+)
create mode 100644 CSharp/Blog-CustomChannelData/.gitattributes
create mode 100644 CSharp/Blog-CustomChannelData/.gitignore
create mode 100644 CSharp/Blog-CustomChannelData/App_Start/WebApiConfig.cs
create mode 100644 CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.csproj
create mode 100644 CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.sln
create mode 100644 CSharp/Blog-CustomChannelData/Controllers/MessagesController.cs
create mode 100644 CSharp/Blog-CustomChannelData/Dialogs/ShareButtonDialog.cs
create mode 100644 CSharp/Blog-CustomChannelData/Global.asax
create mode 100644 CSharp/Blog-CustomChannelData/Global.asax.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookAttachment.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookButton.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookButtonTemplate.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookChannelData.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookGenericTemplate.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookGenericTemplateContent.cs
create mode 100644 CSharp/Blog-CustomChannelData/Models/FacebookShareButton.cs
create mode 100644 CSharp/Blog-CustomChannelData/Properties/AssemblyInfo.cs
create mode 100644 CSharp/Blog-CustomChannelData/Web.Debug.config
create mode 100644 CSharp/Blog-CustomChannelData/Web.Release.config
create mode 100644 CSharp/Blog-CustomChannelData/Web.config
create mode 100644 CSharp/Blog-CustomChannelData/default.htm
create mode 100644 CSharp/Blog-CustomChannelData/packages.config
create mode 100644 Node/blog-customChannelData/node_custom_channel.js
create mode 100644 Node/blog-customChannelData/package.json
diff --git a/CSharp/Blog-CustomChannelData/.gitattributes b/CSharp/Blog-CustomChannelData/.gitattributes
new file mode 100644
index 0000000000..1ff0c42304
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/CSharp/Blog-CustomChannelData/.gitignore b/CSharp/Blog-CustomChannelData/.gitignore
new file mode 100644
index 0000000000..3a2238d6bf
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/.gitignore
@@ -0,0 +1,245 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+[Xx]64/
+[Xx]86/
+[Bb]uild/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+
+# TODO: Un-comment the next line if you do not want to checkin
+# your web deploy settings because they may include unencrypted
+# passwords
+#*.pubxml
+*.publishproj
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Microsoft Azure ApplicationInsights config file
+ApplicationInsights.config
+
+# Windows Store app package directory
+AppPackages/
+BundleArtifacts/
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# LightSwitch generated files
+GeneratedArtifacts/
+ModelManifest.xml
+
+# Paket dependency manager
+.paket/paket.exe
+
+# FAKE - F# Make
+.fake/
\ No newline at end of file
diff --git a/CSharp/Blog-CustomChannelData/App_Start/WebApiConfig.cs b/CSharp/Blog-CustomChannelData/App_Start/WebApiConfig.cs
new file mode 100644
index 0000000000..530014ffa8
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/App_Start/WebApiConfig.cs
@@ -0,0 +1,36 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using System;
+using System.Collections.Generic;
+using System.Web.Http;
+
+namespace Azure_Bot_Generic_CSharp
+{
+ public static class WebApiConfig
+ {
+ public static void Register(HttpConfiguration config)
+ {
+ // Json settings
+ config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
+ config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
+ config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
+ JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver(),
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ NullValueHandling = NullValueHandling.Ignore,
+ };
+
+ // Web API configuration and services
+
+ // Web API routes
+ config.MapHttpAttributeRoutes();
+
+ config.Routes.MapHttpRoute(
+ name: "DefaultApi",
+ routeTemplate: "api/{controller}/{id}",
+ defaults: new { id = RouteParameter.Optional }
+ );
+ }
+ }
+}
diff --git a/CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.csproj b/CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.csproj
new file mode 100644
index 0000000000..cf22f26f86
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.csproj
@@ -0,0 +1,181 @@
+
+
+
+
+ Debug
+ AnyCPU
+
+
+ 2.0
+ {A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}
+ {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ Azure_Bot_Generic_CSharp
+ Bot Application1
+ v4.6
+ true
+
+
+
+
+
+
+
+
+
+
+ true
+ full
+ false
+ bin\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll
+ True
+
+
+ ..\packages\Chronic.Signed.0.3.2\lib\net40\Chronic.dll
+ True
+
+
+ ..\packages\Microsoft.Bot.Builder.3.0.0\lib\net46\Microsoft.Bot.Builder.dll
+ True
+
+
+ ..\packages\Microsoft.Bot.Builder.3.0.0\lib\net46\Microsoft.Bot.Connector.dll
+ True
+
+
+
+ ..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.2.206221351\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll
+ True
+
+
+ ..\packages\Microsoft.Rest.ClientRuntime.1.8.2\lib\net45\Microsoft.Rest.ClientRuntime.dll
+ True
+
+
+ ..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.1.0\lib\net40\Microsoft.WindowsAzure.Configuration.dll
+ True
+
+
+ ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+
+ ..\packages\System.IdentityModel.Tokens.Jwt.4.0.2.206221351\lib\net45\System.IdentityModel.Tokens.Jwt.dll
+ True
+
+
+
+
+ ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll
+ True
+
+
+ ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+ Global.asax
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Web.config
+
+
+ Web.config
+
+
+
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+ true
+
+
+
+
+
+
+
+
+ True
+ True
+ 3979
+ /
+ http://localhost:3979/
+ False
+ False
+
+
+ False
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.sln b/CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.sln
new file mode 100644
index 0000000000..b8b1d06dfe
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/Azure_Bot_Generic_CSharp.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25123.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure_Bot_Generic_CSharp", "Azure_Bot_Generic_CSharp\Azure_Bot_Generic_CSharp.csproj", "{A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/CSharp/Blog-CustomChannelData/Controllers/MessagesController.cs b/CSharp/Blog-CustomChannelData/Controllers/MessagesController.cs
new file mode 100644
index 0000000000..c5f2f1f344
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/Controllers/MessagesController.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using System.Web.Http;
+using System.Diagnostics;
+using System.Web.Http.Description;
+using Microsoft.Bot.Connector;
+using Microsoft.Bot.Builder.Dialogs;
+using Newtonsoft.Json;
+//get facebook channel data models
+using Azure_Bot_Generic_CSharp.Models;
+
+namespace Azure_Bot_Generic_CSharp
+{
+ [BotAuthentication]
+ public class MessagesController : ApiController
+ {
+ ///
+ /// POST: api/Messages
+ /// Receive a message from a user and reply to it
+ ///
+ public async Task Post([FromBody]Activity activity)
+ {
+ if (activity.Type == ActivityTypes.Message)
+ {
+ Trace.WriteLine("Got Message");
+ Trace.WriteLine(activity.ToString());
+ //create connector service
+ ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
+ //check for a Facebook message here
+ if (activity.ChannelId == "facebook")
+ {
+ //send acknowledgement
+ Activity reply = activity.CreateReply("Facebook Messenger message detected! Beep boop. [o o]");
+ await connector.Conversations.ReplyToActivityAsync(reply);
+
+ //send to the share button dialog
+ await Conversation.SendAsync(activity, () => new ShareButtonDialog());
+ }
+ else
+ {
+ // calculate something for us to return
+ int length = (activity.Text ?? string.Empty).Length;
+
+ // return our reply to the user
+ Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters");
+ await connector.Conversations.ReplyToActivityAsync(reply);
+ }
+ }
+ else
+ {
+ HandleSystemMessage(activity);
+ }
+ var response = Request.CreateResponse(HttpStatusCode.OK);
+ return response;
+ }
+
+ private Activity HandleSystemMessage(Activity message)
+ {
+ if (message.Type == ActivityTypes.DeleteUserData)
+ {
+ // Implement user deletion here
+ // If we handle user deletion, return a real message
+ }
+ else if (message.Type == ActivityTypes.ConversationUpdate)
+ {
+ // Handle conversation state changes, like members being added and removed
+ // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
+ // Not available in all channels
+ }
+ else if (message.Type == ActivityTypes.ContactRelationUpdate)
+ {
+ // Handle add/remove from contact lists
+ // Activity.From + Activity.Action represent what happened
+ }
+ else if (message.Type == ActivityTypes.Typing)
+ {
+ // Handle knowing tha the user is typing
+ }
+ else if (message.Type == ActivityTypes.Ping)
+ {
+ }
+
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CSharp/Blog-CustomChannelData/Dialogs/ShareButtonDialog.cs b/CSharp/Blog-CustomChannelData/Dialogs/ShareButtonDialog.cs
new file mode 100644
index 0000000000..e51b37dfd8
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/Dialogs/ShareButtonDialog.cs
@@ -0,0 +1,54 @@
+namespace Azure_Bot_Generic_CSharp
+{
+ using System;
+ using System.Diagnostics;
+ using System.Threading.Tasks;
+ using Microsoft.Bot.Connector;
+ using Microsoft.Bot.Builder.Dialogs;
+ using Models;
+
+ [Serializable]
+ public class ShareButtonDialog : IDialog
+
+
diff --git a/CSharp/Blog-CustomChannelData/packages.config b/CSharp/Blog-CustomChannelData/packages.config
new file mode 100644
index 0000000000..9aa73aca2e
--- /dev/null
+++ b/CSharp/Blog-CustomChannelData/packages.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Node/blog-customChannelData/node_custom_channel.js b/Node/blog-customChannelData/node_custom_channel.js
new file mode 100644
index 0000000000..68def93ff1
--- /dev/null
+++ b/Node/blog-customChannelData/node_custom_channel.js
@@ -0,0 +1,80 @@
+//loading modules
+var express = require("express");
+var restify = require("restify");
+var botbuilder = require("botbuilder");
+var request = require("request-promise");
+
+//load environment variables here
+const MSFT_APP_ID = process.env.MSFT_APP_ID;
+const MSFT_APP_PW = process.env.MSFT_APP_PW;
+
+//create an express server
+var app = express();
+app.listen( process.env.PORT || 3000, function(){
+ console.log("Express app listening on port: " + process.env.PORT || 3000);
+});
+
+//create a chat connector for the bot
+var connector = new botbuilder.ChatConnector({
+ appId: MSFT_APP_ID,
+ appPassword: MSFT_APP_PW
+});
+
+//load the botbuilder classes and build a unversal bot using the chat connector
+var bot = new botbuilder.UniversalBot(connector);
+
+//hook up bot endpoint
+app.post("/messages/receive", connector.listen());
+
+//root dialog
+bot.dialog("/", function(session){
+
+ console.log("-------------------------------------------------");
+ console.log("Bot Received Message at '/' dialogue endpoint: ");
+
+ //detect Facebook Messenger message here
+ if(session.message.address.channelId == "facebook"){
+ session.send("Facebook message recognized!");
+ session.beginDialog("/send_share_button");
+ } else session.send("Channel other than Facebook recognized.");
+
+});
+
+//where we create a facebook share button using sourceEvent
+bot.dialog("/send_share_button", function(session){
+ //construct a new message with the current session context
+ var msg = new botbuilder.Message(session).sourceEvent({
+ //specify the channel
+ facebook: {
+ //format according to channel's requirements
+ //(in our case, the above JSON required by Facebook)
+ attachment: {
+ type: "template",
+ payload: {
+ template_type: "generic",
+ elements: [
+ {
+ title: "Microsoft Bot Framework",
+ subtitle: "Check it out!",
+ buttons: [
+ {
+ type: "web_url",
+ url: "https://dev.botframework.com",
+ title: "Go to Dev Portal"
+ },
+ {
+ //this is our share button
+ type: "element_share"
+ }
+ ]
+ }
+ ]
+ }
+ } //end of attachment
+ }
+ });
+
+ //send message
+ session.send(msg);
+ session.endDialog("Show your friends!");
+});
diff --git a/Node/blog-customChannelData/package.json b/Node/blog-customChannelData/package.json
new file mode 100644
index 0000000000..c9516e5d29
--- /dev/null
+++ b/Node/blog-customChannelData/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "azure_node_bot",
+ "version": "1.0.0",
+ "description": "Microsoft Bot Framework bot written in NodeJS to test issues.",
+ "main": "node_bot.js",
+ "dependencies": {
+ "botbuilder": "^3.7.0",
+ "express": "^4.14.1",
+ "request-promise": "^4.1.1",
+ "restify": "^4.3.0"
+ },
+ "devDependencies": {},
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "start": "node node_bot.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/Fignewton5/AzureNodeBot.git"
+ },
+ "keywords": [
+ "Microsoft",
+ "Bot",
+ "Framework",
+ "Chatbot",
+ "Chat",
+ "Bot"
+ ],
+ "author": "Tony Anziano",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/Fignewton5/AzureNodeBot/issues"
+ },
+ "homepage": "https://github.com/Fignewton5/AzureNodeBot#readme"
+}