Learn how to build a sophisticated and user-configurable Slack Bot which gives customized trade reports to financial analysts using Serverless technologies on Azure. Learn the patterns we used and the architectural decisions we made from an experienced Serverless Enterprise developer and author.
4. Trade Awareness
Fund Manager places order
for assets, which then get
bought or sold
Analyst that covers assets
may be unaware
Fund Managers team and
support team may be
unaware
5. My Customer
• Analyst working for one of our Private Credit teams
• Constructed manual report every morning
7. Durable Functions
Define Workflows
using real code
Execution is reliably
saved and can last for
hours, months or
indefinitely
Operation is entirely
Serverless
Hand off calculations
and data retrieval to
Azure Functions
15. Automated Regular Notifications
Fund Manager places order
for assets, which then get
bought or sold
Analyst receives a
notification the next
morning for any assets they
cover
Fund Managers team and
support team receives
notification an hour later
16. Customer
• No longer needs to construct his manual report
• Can tweak and configure however much he wants
• Total reliability and earlier execution
18. Problem
Users began to report slow loading times
• Application Insights indicated these incidents were approximately 12 seconds in length
• They didn’t occur over 20 minutes after the hourly notification went off
• They were always accompanied by ‘startup’ traces that Durable Functions always does
when it starts and checks the state of all outstanding orchestrators
21. Solution
Rewrite code to remove
need for dependencies
Introduce build tool that ‘Tree-
shakes’ dependencies
Add Keep Alive function to
Function App
24. Bolt on Azure Functions
• Slack model is event-based – when a user interacts with your bot they issue a message
describing that event to your registered publically available url
• Slack have produced a convenient developer framework that uses Express on Node.js
called Bolt which will set up everything required to receive these events and validate
they are actually from Slack
• This previously did not place nice with Azure Functions, as the runtime handles
requests, not a framework like express
• There are other issues, like Slack requiring a response within 3 seconds, which
terminates an Azure Functions execution
25. Bolt on Azure Functions
• I have released an open source npm library called ‘bolt-azure-functions-receiver' which
implements the logic you need to replace the built in Express method and use Bolt
• You can then kick off a Durable Functions orchestrator and respond within 3 seconds
easily
26. Durable Orchestrator
Azure Function
invokes library
and starts Bolt
framework to
help with
handling the
request
Orchestrator
continues as
background
process and
completes
action
Slack User
clicks on your
message and
Slack sends
you an event
to HTTP
triggered
function
Starts
Orchestrator
and returns
200 OK