►
From YouTube: Supercharging Slack with ChatGPT using Spin
Description
Don't miss out! Join us at our upcoming event: KubeCon + CloudNativeCon Europe in Amsterdam, The Netherlands from 18 - 21 April, 2023. Learn more at https://kubecon.io The conference features presentations from developers and end users of Kubernetes, Prometheus, Envoy, and all of the other CNCF-hosted projects.
A
A
A
Provides
an
ideal
architecture
to
develop
and
run
these
and
other
types
of
applications
spin
allows
you
to
build
applications
in
the
language
of
your
choice,
eliminates
boilerplate.
It
combines
the
performance
of
always
available
architectures
such
as
containers
or
virtual
machines,
with
a
density
and
cost
Savings
of
serverless
functions.
A
Webassembly
provides
a
highly
performant
natively,
secure
environment
which
supports
most
popular
languages.
It
can
be
compiled
into
byte
code,
but
that
can
be
run
anywhere
across
x86
arm
Windows
Linux
back
Etc
in
combination
with
a
bytecode
Alliance
we've
helped
to
develop
webassembly
systems,
interface
or
Wazi,
which
extends
webassembly
from
its
initial
design
of
client-side
usage
to
support
back-end
systems.
A
On
top
of
that,
we
developed
Spin
and
the
spin
sdks
to
manage
webassembly
aspects,
for
you
handle
the
complexities
around
things
like
HTTP
and
SSL
termination,
and
let
you
focus
on
just
writing
the
code
that
controls
what
your
function
does.
So
what's
this
look
like
in
our
example
today?
Well,
first,
we
need
to
create
a
slack
out.
A
There
are
multiple
ways:
apps
can
interface
with
slack
or
the
one
we're
going
to
use
today
are
slash
commands
this
lets
you
send
a
command
to
an
app,
have
a
process,
the
command
and
return
a
result
in
any
channel
or
direct
message
with
our
app.
We
need
to
find
our
Command
in
this
instance,
slash,
chat,
GPT
and
the
end
point
to
which
we'll
be
calling
out
to
spin
out.
A
A
When
a
user
type
slash
chat,
GPT
and
then
some
question
in
a
Channel
the
app
before
the
request
to
the
specified
endpoint,
this
is
where
our
spin
app
comes
into
play:
spin
handles
HTTP
and
SSL
termination
for
you
handing
their
function,
a
request
which
includes
the
entire
HTTP
request.
We
then
need
to
parse
that
to
do
a
few
things,
first
authenticate
the
slack
token
and
second
extract
the
query.
A
Once
we've
done
that
we
build
and
forward
the
request
to
the
open,
AI
API.
This
requires
another
token
to
authenticate
with
openai.
Now,
obviously,
we
don't
want
to
store
these
tokens
in
our
code.
So
where
do
we
store
them?
Spin
provides
a
couple
options,
including
passing
it
in
as
an
environmental
variable
configuring
it
in
your
spin.tomel.
In
this
instance,
we're
going
to
use
a
built-in
key
value,
storage.
A
This
provides
a
simple
way
for
us
to
separate
the
secrets
from
the
code
once
trap.
Gpt
has
processed
our
query.
It
returns
a
response
which
we
then
simply
extract
the
answer
from
and
entered
into
the
body
of
the
return
for
our
function.
Send
that
back
to
Slack
slack
will
then
enter
the
response
into
the
channel.
This
might
all
seem
simple
enough,
but
where
do
we
Host
this
spin
app
and
how
much
overhead
does
that
add?
We
have
several
choices
here
as
well:
locally
I
can
run
spin
up
and
to
launch
my
application
now.
A
Typically,
this
is
reserved
for
testing
and
in
this
instance,
we
really
don't
want
to
open
our
of
our
laptop
open
to
the
world
and
run
this
forever.
We
can
also
have
spin
apps
on
kubernetes
Via
shim.
This
shim
is
now
included
with
a
preview
feature
in
Azure
AKs
and
with
a
preview
version
of
Docker
desktop.
Alternatively,
you
can
install
it
into
any
cluster.
You
are
managing
with
either
custom
nodes
or
Daemon
set
in
this
instance,
though,
we're
going
for
a
third
option
for
me
on
cloud.
A
Our
goal
is
to
build
the
easiest
place
to
host
spin
applications
with
the
ability
to
go
from
blinking
cursor
to
in
an
empty
directory
to
a
deployed
application
in
less
than
two
minutes
with
Spin
and
fermian
clone,
you
two
should
be
able
to
get
a
slack,
GPT,
bot
or
other
workload
running
in
no
time.
Let's
go
take
a
look
at
the
code
and
see
this
all
in
action.
A
Great,
so,
let's
dig
into
it.
If
you're
following
along
and
you've
not
already
installed
spin
go
get
that
installed.
You
can
grab
that
from
releases
on
our
GitHub,
find
the
latest
version
and
the
appropriate
architecture
for
you
once
you've
got
that
downloaded
just
unpack
it
into
your
path.
Somewhere.
Now
you
can
see,
I've
got
an
user
local
bin
spin.
We
run
spin
spins
a
pretty
straightforward
command
line
utility.
We
can
see
the
help
here.
A
Spin
includes
a
bunch
of
templates
to
help
us
get
started
and
make
this
very
easy
and
fast.
So
I
can
do
spin
templates
list
and
I
see
the
various
templates.
We
have
see
a
lot
of
these
say
HTTP,
some
of
them
say
redis
and
there's
a
couple
other
ones
in
here.
Http
and
redis
are
talking
about
specific
handlers.
A
We
have
there
so
with
HP
we're
hand
taking
in
an
HTTP
request,
we're
listing
on
an
hdb
port,
we're
going
to
pass
that
request
to
the
function
that
you've
got
wait
for
your
return
response
and
we'll
return
that
redis.
Likewise
we're
gonna.
Do
this
with
redis
redirect
is
pretty
self-explanatory
and
then
static
file
server.
A
If
you
just
want
to
host
some
static
files,
you
don't
have
to
actually
go
write
your
own
Handler,
for
how
to
do
that,
but
to
return
those
we
have
already
created
one
for
you,
so
you
can
just
use
ours
and
configure
it
appropriately
to
point
wherever
your
files
are.
So,
let's
go
create
a
simple
one.
Here,
oh
I
should
mention.
A
We
actually
run
the
entirety
of
the
fermion
website
on
a
on
spin
using
a
project
called
Bartholomew
a
little
more
complicated
than
static
file
server,
but
you
can
host
any
kind
of
application
with
complexity
of
that
easily
this
way.
So
let's
do
some
new
applications.
Spin,
new
HTTP,
rust,
hello,
hello,
webinar
world
here
and
then
we've
created
this
new
URL
CD
into
there.
First
file
we
want
to
look
at
is
the
spin.tomel.
This
is
an
every
spin
application
and
it's
a
configuration
for
spin.
A
We
can
see
first,
the
trigger
and
the
bass
here,
so
we
have
to
have
some
kind
of
trigger.
That's
what
I
know
the
spin
app
is
being
triggered
again
we're
using
HTTP
in
this
configuration
and
we're
going
to
trigger
on
anything
off
of
the
base
URL.
If
you
hit
the
URL
that's
listening
onto
and
then
each
spin
app
can
have
multiple
components.
A
This
one
happens
to
only
have
one
but
we'll
see
an
example
later
that
has
more
than
one
you
can
see
first
here
the
web
assembly
right,
you
have
to
show,
tell
us
where
the
webassembly
is,
and
then
we
have
a
loud
host
webassembly
by
default.
Doesn't
allow
you
to
do
anything
so
or
at
least
externally,
so
we
have
to
go,
give
it
access.
We
need
to
go
talk
to
something
in
this
instance.
It's
hello
world
we
don't
need
to.
Then
we
have
the
trigger
route
just
like
the
base
trigger
here.
A
I
can
go
to
find
what
this
is
going
to
trigger
on.
In
this
instance,
it's
going
to
trigger
on
anything
go
with
a
triple
dot,
but
I
could
have
a
one
for
like
slash.
A
Api,
static
and
I
could
have
multiple
components
that
are
triggered
on
different
routes
and
then,
finally,
if
you're
not
using
a
pre-built
web
assembly
that
we
provided
like
setup
file
server,
you
need
to
tell
spin
how
to
go,
build
that
and
so
weave
in
each
of
these
templates
pre-populated,
whatever
the
command
is
for
that
particular
language
to
handle
the
build,
and
so
let's
actually
go
look
at
the
code
itself,
so
first
thing
to
pay
attention
to
spin
SDK.
This
is
again
one
of
our
big
advantages.
A
It
makes
us
so
much
more
simple
as
we
handle
all
of
this
stuff
outside
of
getting
like
handing
you
the
request
and
you
just
build
in
a
response,
so
that
really
allows
you
to
come
down
here
and
write
just
your
function
that
takes
in
the
request,
returns
a
response.
This
one's
super
simple,
it's
just
a
hello
world
example,
or
in
this
instance
hello,
webinar,
so
save
that
file
and
now
I
can
do
it's
been
built.
A
How
long
this
is
going
to
take
is
depend
on
the
language,
the
complexity
or
application
rust
tends
to
take
longer
to
compile,
because
you
get
better
performance
Python's.
Pretty
much
immediately
here
because
it
it's
just
adding
The
Interpreter.
So
now
we
can
go
spin
up
and
we
can
run
this
thing
locally
and
I
can
see
Hello
webinar
we're
running
great
now.
I
can
go
about
putting
this
into
these
ferment
cloud
and
hosting
this
on
the
internet.
A
A
And
we
wait,
you
know
a
few
seconds
here
and
then
this
thing
should
be
ready.
A
And
there
we
go
and
tell
us
the
route
and
we
can
see
Hello
webinar
we're
up
and
running
cool
all
right.
So
let's
go
talk
about
the
more
complicated
example.
The
reason
we're
here
today
in
the
first
place,
so
we've
got
the
slack
chat.
Gbt
again
previously
showed
you
the
URL
to
get
to
that
didn't
have
it
before
it
is
github.com
risk
management.
Slash
slack
GPT
I'll
also
provide
a
link
at
the
end
of
this
to
that
and
all
of
the
other
calls
to
actions
so
that
you
can
get
back
to
this.
A
If
you
need
to
so,
let's
go
look
through
this
application.
First
again,
let's
start
the
spin.covel
a
little
bit
more
complicated
here.
First
thing:
you're
going
to
notice
is
different.
I've
got
these
variables
defined
I
mentioned
in
the
lightboard
section
that
we're
going
to
be
using
KV
when
we
actually
deploy
this
out
of
the
cloud.
But
we
show
this
application
supports
as
well
using
configuration
here
and
then
passing
this
in
as
environmental
variables
to
configure
these,
which
we'll
have
to
show
here
in
a
second
and
then
I
have
my
first
component
here.
A
The
instead
of
using
rust
like
we
were
in
the
last
one
we're
using
some
JavaScript
here
to
build
this
application.
So
you
see
this
is
the
actual
application
that
gets
compiled
and
then
allowed
hosts,
because
this
thing
needs
to
reach
out
somewhere.
I
have
to
tell
it
that
it
has
access
to
reach
out
and
where
that
is
in
this
instance.
It's
the
AI
for
open8,
API,
open,
AI,
API
and
then
because
I
want
to
use
the
key
value
store.
I
have
to
give
it
access
to
that.
A
Just
because
I
defined
the
variable
up
top
doesn't
mean
that
it
has
access
at
the
codent
level,
so
I
have
to
go,
provide
it
here
in
the
configuration
and
then
decide
where
the
trip
it's
going
to
trigger
off
and
then
provide
the
appropriate
command
to
go.
Do
the
build
I
also
have
a
second
component
on
here,
which
is
our
KV
Explorer
I'll
show
you
what
that
is
here.
We
can
see.
A
This
is
something
pre-built
I'm
just
grabbing
this
off
of
Radu
our
ctOS
GitHub,
and
able
to
run
the
service
and
handed
access
to
the
KB
store
as
well.
A
So,
let's
look
at
the
code
itself
so
again
now
we're
in
yeah
JavaScript
instead
of
in
in
Rust,
but
you
can
or
typescript
instead
of
in
in
Rust.
We
can
kind
of
see
some
similar
ideas
here
right,
so
we're
pulling
in
the
spin
SDK
and
that's
where
a
lot
of
the
spin
magic
comes
from,
because
I
need
to
talk
about
the
AI
I'm
grabbing,
a
library
to
handle
that
for
me
and
then
again,
I
have
very
similar
I'm,
creating
a
function.
A
A
Try
to
find
those
somehow
first,
if
I
have
that
still
configured
to
the
default
value
of
and
for
in
there,
because
I
have
not
passed
something
as
a
configuration
through
the
configure
the
spin
configuration
then
I
want
to
go
open
the
KV
and
then
we're
gonna
go
grab
that
from
the
KV
right.
Otherwise,
we
will
use
the
configured
value
if
that
figured
value
does
exist.
Same
thing
for
Slack
after
I've
done
that,
for
slack
remember,
the
first
thing
I
want
to
do
is
slack
is
authenticate
that
there's
actually
my
slack
app.
A
That's
talking
to
us
I,
don't
want
to
go
put
this
out
on
the
internet
and
then
everyone's
using
my
openai
key,
and
then
you
know
you
charge
my
credit
card,
a
bajillion
dollars
for
all
of
the
requests.
So
let's
authenticate
this
appropriately
to
all
right,
slack
app,
so
we're
gonna
go
grab
the
body
out
of
the
request
and
out
of
that,
I
need
to
grab
the
token
and
I'm
going
to
validate
that
the
token
there
matches
the
token
that
I
have
configured
here
next
we're
going
to
configure
the
open
AI.
A
If
we
don't
have
any
text,
if
there
wasn't
a
request
or
something
so
I'm
going
to
throw
an
error
and
then
finally
we're
going
to
go,
create
the
chat
here
with
the
prompt
that
I
have
and
send
that
whole
thing
here
to
open
AI
to
ask
it
to
respond
to
us
we're
going
to
wait
for
that
response
to
handle
some
errors
if
it
doesn't
actually
work
and
then
once
I
get
the
response
back
I'm
going
to
return
the
response
here
and
then
ultimately
return
that
response
as
a
return
for
my
whole
function,
which
sends
it
back
to
slack,
which
will
then
put
that
into
the
channel
and
then,
of
course,
do
some
basic
error
handling
cool.
A
So
now,
what
do
I
need
to
do
to
run
this?
Well,
let's
get
into
that
directory
here,
because
we're
now
using
rust
or
we're
using
typescript
JavaScript
instead
of
rust,
I
need
a
plug-in
or
spin.
We
need
spin
plugins
list
and
you
see
the
plugins
I
have
js2
awesome
installed.
If
you
don't
have
this
installed
already,
we've
spin
plugins
install
js2
loss
up
here
and
make
sure
it's
zero
4.0
and
not
a
prior
version.
A
If
you
need
to
I
believe
it's
also
grade
yeah,
you
can
run
upgrade
if
you
have
to
get
to
a
newer
version
and
then
I
need
npm
for
this.
So
if
I
don't
have
npm
installed,
I
should
go.
Install
npm
I'll.
Let
you
Google
how
to
do
that.
If
I
do
have
npm
installed,
I
need
to
actually
run
an
npm
install
to
install
things
before
I
can
then
go
run
spin
build.
A
Cool
and
so
now
we've
created
the
web
assembly.
So
let's
spin
that
up
locally
and
so
now,
because
this
is
an
API,
that's
super
useful
to
go.
Look
at
it
right
here.
It's
just
throw
my
invalid
slack
token,
but
I
can
use
something
like
postband
to
send
my
request
too.
Here
again,
I
have
invalid
slack
token.
Well,
how
am
I
going
to
configure
the
slack
token
I
can
go
here
and
I
say
export
and
I
can
do
spin,
config
slack
token,
so
this
matches
what
we
had
in
the
spin.tomel
for
here.
A
And
send
that
it's
what
you
call
all
day,
kubernetes
workshop
an
event
container:
it's
not
that
so
hey.
How
did
this
work
without
the
open,
AI,
Key,
Well,
I,
cheated
and
I?
Don't
want
to
show
you
my
open,
Egg,
I
key,
so
I
already
pre-populated
that
same
way,
I
just
did
it
with
the
slack
token,
is
just
spin
config
open,
AI
key
as
an
environmental
variable,
so
cool.
Now
we
can
see
that
this
thing
is
working.
Let's
go
make
it
work
in
the
cloud
and
then
ultimately
make
it
work
in
Slack.
A
So
if
you've
not
done
it,
you're
gonna
need
an
open,
AI
key.
So
if
you
hopefully
have
an
open,
AI
account
create
an
account.
You
can
go
to
the
Keys,
create
a
new
key.
Don't
give
it
to.
Somebody
else,
use
that
and
populate
that
in
here
I
need
to
also
create
a
slack
app.
So
this
is
I've
started
to
create
the
app
already
see
you
could
create
new
app,
but
I've
got
Chad
GPT.
A
If
you
scroll
down
here
there
is
the
verification.
Token
that's
shown
here:
I'm
not
scrolling
down,
because
again
don't
want
to
expose
that.
But
you
can
go
and
make
sure
you
grab
that
verification
token,
because
that's
the
slack
token
we
need
then
we're
going
to
configure
our
slash
commands.
So
we
can
create
a
new
command.
You
know
chat
GPT
and
now
what
is
the
URL?
Well
I?
A
A
A
Now
before
we
skip
to
the
next
step,
we
should
be
able
to
actually
see
here
in
my
KB
Explorer.
So
this
is
the
other
component
that
I
have
running.
You
can
see
that
I've
got
these
two
keys
already
populated
in
here.
You
can
actually
use
this
to
go
populate
them
if
you
wanted,
but
ideally
in
a
deployment
step,
you'd
be
using
that
slash,
KB
command
and
then
I'm
going
to
hit,
stop
open
and
grab
here.
A
A
Several
things
that
you
know
previously,
if
you're
trying
to
do
this
in
something
like
Lambda,
would
require
a
bunch
of
different
AWS
services
to
provide
that
end-to-end
experience
where
it
actually
work
and
then
more
code
to
actually
handle
all
of
this,
and
then
we
were
able
to
deploy
that
out
and
have
that
hosted
in
the
cloud
with
farming
on
cloud
very
easily.
Very
simply
get
it
running.
A
So
hopefully
this
has
been
helpful
for
all
of
you.
If
you
want
to
learn
anything
more
here,
I
want
to
improve.
You
know
this
slide
here,
so
you
can.
Let's,
let's
go
boom
bunch
of
follow-up
information.
You
know.
Follow
us
on
Twitter
go
use
our
quick
start.
If
you
haven't
done
it
to
get
good
practice
with
spin.
You
can
see
more
of
this
project.
If
you
want
to
get
this
slide
here
and
you're
watching
the
video
I,
don't
know
what
happened
there.
A
No
you
want
to
give
that
slide.
You
can
just
grab
it
from
end
the
slideshow
here
you
can
grab
this
QR
code
and
grab
the
slide
here
and
they'll.
Take
you
to
all
these
links,
so
you
don't
have
to
try
to
type
them
out.
If
you
have
any
questions
out,
I'm
in
our
Discord
feel
free
to
reach
out.
I
would
love
to
to
chat
and
answer
any
questions,
and
here
you
know
people's
feedback
and
experiences
with
spin
and
with
premium
Cloud.