feedbot-azure-function
v1.8.0-alpha.3
Published
Template for deploying Feedbot platform instance (botbuilder bot + designer) into Azure Functions environment.
Downloads
44
Readme
Feedbot Azure Function
This repo is skeleton used for development of Feedbot and its deployment into the Azure Function environment. Its split into three separate functions, each of them with its own API:
messages
is the mainbotbuilder
messaging endpoint which is wrapped by thefeedbot-node-sdk
(it is bootstrapped and configured using env variables inmessages/index.js
file)management
is custom API determined for non-messaging calls of Feedbot (mainly from Designer), for example:- get current version of bot tree
- push new version of bot tree
- get users handoff state
- trigger some user's handoff
file-upload
is custom API for uploading images (encoded to base64) to azure blob storage.- optional parameters:
http://localhost:7071/api/file-upload/{filename?}/{thumbnail?}/{thumbnailHeight?}
- if
BlobAccountUrl
environment variable is set, then POST response will return image url based on this variable. - if
BlobAccountUrl
is not set, thenAzureWebJobsStorage
will be automatically parsed forAccountName
parameter and custom image url returned.
don't forget to set AzureWebJobsStorage in
local.settings.json
file too- optional parameters:
proactive-messages
is default botbuilder Proactive template's function for proactive messaging (when bot wants to send message to user by its own using Azure Storage Queue - for example when some long duration processing is finished)
Setup
Following setup includes preparing your workspace for working with Azure Functions in production environment. Development environment works without this step.
- create
local.settings.json
file and paste the following:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node",
"NODE_OPTIONS": "--inspect=5858"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
},
"ConnectionStrings": {
"SQLConnectionString": "Value"
}
}
Development
There are two ways how to run azure-function locally:
npm start
- usests-node
andnodemon
to runmessages/index.js
endpoint only in a development environment with automatic restart on source file changes.npm run func
- uses a simulated Azure Functions environment to run all functions in parallel in a production environment- install azure-functions-core-tools (guide) globally first (on Mac need to force version using
npm i -g [email protected]
) - update Node.js to the new version. You can use
nvm
- Node Version Manager (Installer) ornode.js
(Installer). For nvm usenvm ls
to see installed node versions on your machine andnvm use <version>
to switch to a newest version. Guide - in case of
Missing value for AzureWebJobsStorage in local.settings.json
error, change extension of fileproactive-messages/function.json
to something else temporarily OR just addAzureWebJobsStorage
value inpackages/azure-storage/local.settings.json
.
- install azure-functions-core-tools (guide) globally first (on Mac need to force version using
Both of these scripts start bot instance on
localhost:7071/api/messages
and you can use Bot Framework Emulator to test it's behavior which is loaded frommessages/tree/default.json
(or"FeedbotTreeFile"
environment variable).
To emulate Azure Storage environment, .env
file needs to configure one setting:
create
.env
file at the root of the azure-functions folder and insert the following:AzureWebJobsStorage="UseDevelopmentStorage=true"
Deployment
Deploying new Feedbot instance is described in wearefeedyou/feedbot wiki
Configuration
You can configure the behaviour of chatbot with several environment variables, defined in .env
file:
NODE_ENV="development" //options: [ "development", "production" ]
FeedbotTreeFile="default" //points to azure-function/messages/tree/default.json
port=7071 //port for express to listen to
AzureWebJobsStorage="UseDevelopmentStorage=true" //azure-storage account string
FeedbotTestModeEmailRecipient="[email protected]" //email address to send emails to
// result storage related items:
ResultStorageExcelSpreadsheetId="1234567890"
ResultStorageExcelSheetName="List1"
ResultStorageClientId="1234567890"
ResultStorageClientSecret="abcd1234"
ResultStorageRefreshToken="abcdefghij1234567890"
ResultStorageSuccessFactorsCompanyUsername="User"
ResultStorageSuccessFactorsCompanyPassword="Password"
ResultStorageSuccessFactorsCompanyId="Company"
// www.Amio.io related items:
AmioChannelId1="1234567890"
AmioSecret1="abcd1234"
amioAccessToken="abcdefghij1234567890"
QuickReplyImageUrl="http://tny.im/i4e" //image for QuickReply button for Facebook
// www.Teamio.com related items:
TeamioLogin="User"
TeamioPassword="Password"
Tools
Insomnia
Insomnia is used for making requests to REST APIs: Insomnia REST Client
Microsoft Azure Storage Explorer
Microsoft Azure Storage Explorer is used for tracking table/blob/queue storage values in the azure-storage database: Microsoft Azure Storage Explorer
Microsoft Bot Framework Emulator
Microsoft Bot Framework Emulator simulates user-side interaction environment with Feedbot: Bot Framework Emulator