Skip to content

Commit f54050b

Browse files
mathewcfabiocav
authored andcommitted
Adding Bot output binding
1 parent 34090bd commit f54050b

File tree

10 files changed

+118
-3
lines changed

10 files changed

+118
-3
lines changed

WebJobs.Script.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HttpTrigger-CustomRoute-Pos
391391
sample\HttpTrigger-CustomRoute-Post\index.js = sample\HttpTrigger-CustomRoute-Post\index.js
392392
EndProjectSection
393393
EndProject
394+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bot-CSharp", "Bot-CSharp", "{EF36E33B-646C-4EF4-B0E2-517E14F6DC38}"
395+
ProjectSection(SolutionItems) = preProject
396+
sample\Bot-CSharp\function.json = sample\Bot-CSharp\function.json
397+
sample\Bot-CSharp\run.csx = sample\Bot-CSharp\run.csx
398+
EndProjectSection
399+
EndProject
400+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bot", "Bot", "{98DBDE0D-364C-4865-9A4A-B17410D771F6}"
401+
ProjectSection(SolutionItems) = preProject
402+
sample\Bot\function.json = sample\Bot\function.json
403+
sample\Bot\run.js = sample\Bot\run.js
404+
EndProjectSection
405+
EndProject
394406
Global
395407
GlobalSection(SolutionConfigurationPlatforms) = preSolution
396408
Debug|Any CPU = Debug|Any CPU
@@ -492,5 +504,7 @@ Global
492504
{02FF2DFF-D7FA-4823-9E91-56C93FB2D447} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
493505
{5957100B-2FAA-4D67-8CB3-C30D30FD92F8} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
494506
{ADE3C399-6996-4677-89A8-60EDA27BF9C2} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
507+
{EF36E33B-646C-4EF4-B0E2-517E14F6DC38} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
508+
{98DBDE0D-364C-4865-9A4A-B17410D771F6} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
495509
EndGlobalSection
496510
EndGlobal

sample/Bot-CSharp/function.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"name": "input",
7+
"direction": "in",
8+
"methods": [ "post" ]
9+
},
10+
{
11+
"type": "bot",
12+
"name": "message",
13+
"direction": "out",
14+
"botId": "testbot"
15+
},
16+
{
17+
"type": "http",
18+
"name": "res",
19+
"direction": "out"
20+
}
21+
]
22+
}

sample/Bot-CSharp/run.csx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Net;
3+
using System.Net.Http;
4+
using Microsoft.Azure.WebJobs.Host;
5+
6+
public class BotMessage
7+
{
8+
public string Source { get; set; }
9+
public string Message { get; set; }
10+
}
11+
12+
public static HttpResponseMessage Run(string input, out BotMessage message, TraceWriter log)
13+
{
14+
log.Info($"Sending Bot message {input}");
15+
16+
message = new BotMessage
17+
{
18+
Source = "Azure Functions (C#)!",
19+
Message = input
20+
};
21+
22+
return new HttpResponseMessage(HttpStatusCode.OK);
23+
}

sample/Bot/function.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"name": "req",
7+
"direction": "in",
8+
"methods": [ "post" ]
9+
},
10+
{
11+
"type": "bot",
12+
"name": "$return",
13+
"direction": "out",
14+
"botId": "testbot"
15+
},
16+
{
17+
"type": "http",
18+
"name": "res",
19+
"direction": "out"
20+
}
21+
]
22+
}

sample/Bot/run.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = function (context, req) {
2+
context.log('Sending Bot message', req.body);
3+
4+
var message = {
5+
source: 'Azure Functions (Node.js)!',
6+
message: req.body
7+
};
8+
9+
context.done(null, message);
10+
}

sample/host.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
},
1010
"tracing": {
1111
"fileLoggingMode": "always"
12-
}
12+
},
13+
"functions": ["Bot", "Bot-CSharp"]
1314
}

src/WebJobs.Script.Extensibility/app.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</dependentAssembly>
99
<dependentAssembly>
1010
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
11-
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
11+
<bindingRedirect oldVersion="0.0.0.0-7.2.1.0" newVersion="7.2.1.0" />
1212
</dependentAssembly>
1313
<dependentAssembly>
1414
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />

src/WebJobs.Script/Host/ScriptHost.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.Azure.WebJobs.Extensions;
1717
using Microsoft.Azure.WebJobs.Extensions.ApiHub;
1818
using Microsoft.Azure.WebJobs.Extensions.Bindings;
19+
using Microsoft.Azure.WebJobs.Extensions.BotFramework.Bindings;
1920
using Microsoft.Azure.WebJobs.Extensions.DocumentDB;
2021
using Microsoft.Azure.WebJobs.Extensions.MobileApps;
2122
using Microsoft.Azure.WebJobs.Extensions.NotificationHubs;
@@ -523,7 +524,8 @@ private static Collection<ScriptBindingProvider> LoadBindingProviders(ScriptHost
523524
typeof(MobileAppsScriptBindingProvider),
524525
typeof(NotificationHubScriptBindingProvider),
525526
typeof(SendGridScriptBindingProvider),
526-
typeof(TwilioScriptBindingProvider)
527+
typeof(TwilioScriptBindingProvider),
528+
typeof(BotFrameworkScriptBindingProvider)
527529
};
528530

529531
// Create the binding providers

src/WebJobs.Script/WebJobs.Script.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.ApiHub.1.0.0-beta1-10383\lib\net45\Microsoft.Azure.WebJobs.Extensions.ApiHub.dll</HintPath>
8383
<Private>True</Private>
8484
</Reference>
85+
<Reference Include="Microsoft.Azure.WebJobs.Extensions.BotFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
86+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.BotFramework.1.0.0-beta\lib\net452\Microsoft.Azure.WebJobs.Extensions.BotFramework.dll</HintPath>
87+
<Private>True</Private>
88+
</Reference>
8589
<Reference Include="Microsoft.Azure.WebJobs.Extensions.DocumentDB, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
8690
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.DocumentDB.1.0.0-beta1-10383\lib\net45\Microsoft.Azure.WebJobs.Extensions.DocumentDB.dll</HintPath>
8791
<Private>True</Private>
@@ -114,6 +118,14 @@
114118
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.ServiceBus.2.0.0-beta1-10456\lib\net45\Microsoft.Azure.WebJobs.ServiceBus.dll</HintPath>
115119
<Private>True</Private>
116120
</Reference>
121+
<Reference Include="Microsoft.Bot.Connector.DirectLine, Version=3.0.0.18, Culture=neutral, processorArchitecture=MSIL">
122+
<HintPath>..\..\packages\Microsoft.Bot.Connector.DirectLine.3.0.0.18-alpha\lib\net45\Microsoft.Bot.Connector.DirectLine.dll</HintPath>
123+
<Private>True</Private>
124+
</Reference>
125+
<Reference Include="Microsoft.Bot.Connector.DirectLine.MicrosoftInternal, Version=3.0.1.14, Culture=neutral, processorArchitecture=MSIL">
126+
<HintPath>..\..\packages\Microsoft.Bot.Connector.DirectLine.MicrosoftInternal.3.0.1.14-alpha\lib\net452\Microsoft.Bot.Connector.DirectLine.MicrosoftInternal.dll</HintPath>
127+
<Private>True</Private>
128+
</Reference>
117129
<Reference Include="Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118130
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
119131
<Private>True</Private>
@@ -142,6 +154,10 @@
142154
<HintPath>..\..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
143155
<Private>True</Private>
144156
</Reference>
157+
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
158+
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
159+
<Private>True</Private>
160+
</Reference>
145161
<Reference Include="Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
146162
<HintPath>..\..\packages\WindowsAzure.ServiceBus.3.4.0\lib\net45-full\Microsoft.ServiceBus.dll</HintPath>
147163
<Private>True</Private>
@@ -239,6 +255,7 @@
239255
<SpecificVersion>False</SpecificVersion>
240256
<HintPath>..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</HintPath>
241257
</Reference>
258+
<Reference Include="System.Net" />
242259
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
243260
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
244261
<Private>True</Private>

src/WebJobs.Script/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<package id="Microsoft.Azure.WebJobs.Core" version="2.0.0-beta1-10456" targetFramework="net46" />
1616
<package id="Microsoft.Azure.WebJobs.Extensions" version="2.0.0-beta1-10383" targetFramework="net46" />
1717
<package id="Microsoft.Azure.WebJobs.Extensions.ApiHub" version="1.0.0-beta1-10383" targetFramework="net46" />
18+
<package id="Microsoft.Azure.WebJobs.Extensions.BotFramework" version="1.0.0-beta" targetFramework="net46" />
1819
<package id="Microsoft.Azure.WebJobs.Extensions.DocumentDB" version="1.0.0-beta1-10383" targetFramework="net46" />
1920
<package id="Microsoft.Azure.WebJobs.Extensions.MobileApps" version="1.0.0-beta1-10383" targetFramework="net46" />
2021
<package id="Microsoft.Azure.WebJobs.Extensions.NotificationHubs" version="1.0.0-beta1-10383" targetFramework="net46" />
@@ -24,6 +25,8 @@
2425
<package id="Microsoft.Azure.WebJobs.ServiceBus" version="2.0.0-beta1-10456" targetFramework="net46" />
2526
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net46" />
2627
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net46" />
28+
<package id="Microsoft.Bot.Connector.DirectLine" version="3.0.0.18-alpha" targetFramework="net46" />
29+
<package id="Microsoft.Bot.Connector.DirectLine.MicrosoftInternal" version="3.0.1.14-alpha" targetFramework="net46" />
2730
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net46" />
2831
<package id="Microsoft.CodeAnalysis.Common" version="1.3.2" targetFramework="net46" />
2932
<package id="Microsoft.CodeAnalysis.CSharp" version="1.3.2" targetFramework="net46" />
@@ -33,6 +36,7 @@
3336
<package id="Microsoft.Data.OData" version="5.7.0" targetFramework="net46" />
3437
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net46" />
3538
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net46" />
39+
<package id="Microsoft.Rest.ClientRuntime" version="2.3.2" targetFramework="net46" />
3640
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net45" />
3741
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net46" />
3842
<package id="ncrontab" version="3.2.0" targetFramework="net46" />

0 commit comments

Comments
 (0)