Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introducing Juvet: Building Bots in Elixir

Introducing Juvet: Building Bots in Elixir

There is another massive shift happening in how we interact with companies through software. Users feel comfortable naturally talking with their applications through chatbots. Chat is the next generation of the user interface.

Companies like Slack, Facebook, WhatsApp, and WeChat have some of the most popular apps in the world, and they are all betting on a messaging interface.

Elixir is the perfect language and ecosystem for building bots and for conversational interfaces. In this session, we will see how we can build scalable, realtime web applications (or “bots”) using a new library Juvet and the Slack API. We will see what a good bot architecture looks like and how we can integrate with existing artificial intelligence services to make our bots smarter.

Jamie Wright
PRO

July 14, 2018
Tweet

More Decks by Jamie Wright

Other Decks in Programming

Transcript

  1. Introducing Juvet
    Building Bots In Elixir

    View Slide

  2. serial #
    R2-D2

    View Slide

  3. emoji-bot

    View Slide

  4. emoji-bot

    View Slide

  5. But I was going
    to go into Tosche
    Station to pick up
    some power
    converters…
    "
    emoji-bot

    View Slide

  6. a long time ago…

    View Slide

  7. a long time ago…
    1950

    View Slide

  8. a long time ago…
    1965
    1950

    View Slide

  9. a long time ago…
    1965
    1950

    View Slide

  10. a long time ago…

    View Slide

  11. a long time ago…
    1995

    View Slide

  12. a long time ago…
    1995

    View Slide

  13. a long time ago…
    1995 1997

    View Slide

  14. a long time ago…
    1995 1997

    View Slide

  15. a long time ago…

    View Slide

  16. a long time ago…
    2000

    View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. a long time ago…
    2000

    View Slide

  21. a long time ago…
    2000 2007

    View Slide

  22. a long time ago…
    2000 2007

    View Slide

  23. View Slide

  24. 2018

    View Slide

  25. caring
    module
    #D5e7r6

    View Slide

  26. 3Apps

    View Slide

  27. familiar
    1.

    View Slide

  28. familiar
    1.
    2. < barriers

    View Slide

  29. UBER

    View Slide

  30. UBER

    View Slide

  31. UBER

    View Slide

  32. UBER

    View Slide

  33. UBER

    View Slide

  34. Bewhere
    users
    the
    are

    View Slide

  35. ‘86

    View Slide

  36. ‘86

    View Slide

  37. ‘86
    ‘96

    View Slide

  38. ‘86
    ‘96
    ‘06

    View Slide

  39. ‘16
    ‘86
    ‘96
    ‘06

    View Slide

  40. speaking
    module
    #S40926

    View Slide

  41. UI
    the
    design

    View Slide

  42. Can you schedule a meeting
    for tomorrow with Jim and
    Tim?
    Which Jim do you want me to
    schedule a meeting with?
    1. Jim F.
    2. Jim P.
    Sure. It looks like the
    afternoon is best. Do you
    want me to schedule this for
    then?
    Meeting invite went out for
    2PM tomorrow to everyone. I
    will follow up to confirm
    everyone is booked.
    Ok. There is no more free
    time tomorrow. Do you want
    me to try for Wednesday?
    Multiple contacts
    "Yes"
    "No"

    View Slide

  43. R.A.N
    random access navigation
    Can you schedule a meeting?

    View Slide

  44. R.A.N
    random access navigation
    Can you schedule a meeting? I sure can. With whom?

    View Slide

  45. R.A.N
    random access navigation
    Can you schedule a meeting? I sure can. With whom?
    With Tim

    View Slide

  46. R.A.N
    random access navigation
    Can you schedule a meeting? I sure can. With whom?
    With Tim
    Got it. When?

    View Slide

  47. R.A.N
    random access navigation
    Can you schedule a meeting? I sure can. With whom?
    With Tim
    Got it. When?
    Tomorrow at 2

    View Slide

  48. R.A.N
    random access navigation
    Can you schedule a meeting? I sure can. With whom?
    With Tim
    Got it. When?
    Tomorrow at 2
    Done. I scheduled your
    meeting with Tim for
    tomorrow at 2.

    View Slide

  49. R.A.N
    random access navigation
    Can you schedule a meeting
    with Tim for tomorrow at 2?

    View Slide

  50. R.A.N
    random access navigation
    Can you schedule a meeting
    with Tim for tomorrow at 2?
    Done. I scheduled your
    meeting with Tim for
    tomorrow at 2.

    View Slide

  51. R.A.N
    random access navigation
    Can you schedule a meeting
    with Tim for tomorrow at 2?
    Done. I scheduled your
    meeting with Tim for
    tomorrow at 2.
    Actually can you make it for
    3?

    View Slide

  52. R.A.N
    random access navigation
    Can you schedule a meeting
    with Tim for tomorrow at 2?
    Done. I scheduled your
    meeting with Tim for
    tomorrow at 2.
    Actually can you make it for
    3?
    Done. I re-scheduled it with
    Tim for 3 tomorrow.

    View Slide

  53. R.A.N
    random access navigation
    Detect parameters
    1.

    View Slide

  54. R.A.N
    random access navigation
    Detect parameters
    1.
    2. Allow change

    View Slide

  55. Design
    Challenges

    View Slide

  56. Discoverability

    View Slide

  57. Discoverability
    Are you ready to
    have that
    meeting? You
    can reply with
    "yes" or "no".
    yes

    View Slide

  58. Discoverability

    View Slide

  59. Discoverability
    Meeting scheduled!
    Did you know you can
    reschedule by just saying
    "reschedule meeting with
    Dave"?

    View Slide

  60. Validation

    View Slide

  61. Validation
    Andy wants to
    meet with you
    today at 2PM.
    Are you
    available?
    blerg

    View Slide

  62. Validation

    View Slide

  63. Validation
    I'm sorry, "blerg" is not an
    answer.
    You can say "yes" or "no".
    Are you available to meet
    with Andy today at 2PM?

    View Slide

  64. Selection

    View Slide

  65. Selection
    Where do you want to meet
    tonight with MacKenzie?
    1. Coffee Shop
    2. Restaurant for dinner
    3. Local bar
    1

    View Slide

  66. Selection

    View Slide

  67. Selection
    Ok. Which coffee shop?
    1. Starbucks on Central
    2. Cup 'o Joe Downtown

    View Slide

  68. Best
    Practices

    View Slide

  69. Gender Neutral

    View Slide

  70. Gender Neutral
    are you a boy
    or a girl?
    Neither.
    Those X-Wing
    pods are skinny.
    I would not fit
    with any extra
    parts.

    View Slide

  71. Beer Test

    View Slide

  72. Beer Test
    Just keep me
    away from those
    Jawas and we'll
    be cool.

    you are my
    best friend

    View Slide

  73. Different Responses

    View Slide

  74. Different Responses
    how come you had
    rocket feet early on
    but then you didn't
    after episode 3?
    They were using
    potatoes for
    special effects in
    the first 3 movies.
    How would they
    pull off rocket
    feet?

    View Slide

  75. Different Responses

    View Slide

  76. Different Responses
    Yeah, but how do
    you explain Jabba
    the Hutt in the
    special edition?
    They were using
    potatoes for
    special effects in
    the first 3.
    How would they
    pull off rocket
    feet?

    View Slide

  77. Use Their Surroundings

    View Slide

  78. Use Their Surroundings
    Dagobah did not
    look like a pleasant
    place!
    It's 70 degrees in
    February where
    you're at.
    Global warming
    is affecting all
    systems.

    View Slide

  79. Fallback

    View Slide

  80. Fallback
    Can you
    blerg?
    I'm sorry, that oil
    bath got into
    some of my
    circuits.
    What were you
    saying?

    View Slide

  81. power
    module
    #63wrqy

    View Slide

  82. power
    module
    #63wrqy

    View Slide

  83. speaking
    module
    #S40926

    View Slide

  84. speaking
    module
    #S40926

    View Slide

  85. listen
    module
    #aaYg5

    View Slide

  86. listen
    module
    #aaYg5

    View Slide

  87. process
    module
    #9862sw

    View Slide

  88. process
    module
    #9862sw

    View Slide

  89. View Slide

  90. View Slide

  91. Slack App Directory

    View Slide

  92. Slack App Directory

    View Slide

  93. Add to Slack

    View Slide

  94. Add to Slack

    View Slide

  95. Authorize app

    View Slide

  96. Authorize app

    View Slide

  97. Authorize app

    View Slide

  98. new bot user

    View Slide

  99. new bot user

    View Slide

  100. chat!

    View Slide

  101. power
    module
    #63wrqy

    View Slide

  102. Why
    Elixir?

    View Slide

  103. Processes

    View Slide

  104. process
    #621772
    Processes
    process
    #382901
    process
    #639011
    process
    #235671

    View Slide

  105. Fast

    View Slide

  106. Fast

    View Slide

  107. Create Slack App
    http://api.slack.com/applications/new

    View Slide

  108. Create Slack App
    http://api.slack.com/applications/new

    View Slide

  109. ngrok

    View Slide

  110. Create Slack App
    http://api.slack.com/applications/new

    View Slide

  111. Web Component

    View Slide

  112. Web Component

    View Slide

  113. Web Component

    View Slide

  114. OAuth

    View Slide

  115. OAuth

    View Slide

  116. OAuth

    View Slide

  117. OAuth

    View Slide

  118. OAuth

    View Slide

  119. routes

    View Slide

  120. controller

    View Slide

  121. controller

    View Slide

  122. controller

    View Slide

  123. oauth response
    {"provider"=>"slack",
    "uid"=>"UXXXXXXX",
    "info"=>
    {"nickname"=>"jwright",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX",
    "name"=>nil,
    "email"=>nil,
    "first_name"=>nil,
    # …
    },
    "credentials"=>
    {"token"=>"xoxp-XXXXX-XXXXXXX-XXXXXX",
    "expires"=>false},
    "extra"=>
    {"raw_info"=>
    {"ok"=>true,
    "url"=>"https://bf.slack.com/",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX"},
    "web_hook_info"=>{},
    "bot_info"=>
    {"bot_user_id"=>"UXXXXXX",
    "bot_access_token"=>"xoxb-XXXXXX-XXXXXXXX"}}}}

    View Slide

  124. oauth response
    {"provider"=>"slack",
    "uid"=>"UXXXXXXX",
    "info"=>
    {"nickname"=>"jwright",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX",
    "name"=>nil,
    "email"=>nil,
    "first_name"=>nil,
    # …
    },
    "credentials"=>
    {"token"=>"xoxp-XXXXX-XXXXXXX-XXXXXX",
    "expires"=>false},
    "extra"=>
    {"raw_info"=>
    {"ok"=>true,
    "url"=>"https://bf.slack.com/",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX"},
    "web_hook_info"=>{},
    "bot_info"=>
    {"bot_user_id"=>"UXXXXXX",
    "bot_access_token"=>"xoxb-XXXXXX-XXXXXXXX"}}}}

    View Slide

  125. oauth response
    {"provider"=>"slack",
    "uid"=>"UXXXXXXX",
    "info"=>
    {"nickname"=>"jwright",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX",
    "name"=>nil,
    "email"=>nil,
    "first_name"=>nil,
    # …
    },
    "credentials"=>
    {"token"=>"xoxp-XXXXX-XXXXXXX-XXXXXX",
    "expires"=>false},
    "extra"=>
    {"raw_info"=>
    {"ok"=>true,
    "url"=>"https://bf.slack.com/",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX"},
    "web_hook_info"=>{},
    "bot_info"=>
    {"bot_user_id"=>"UXXXXXX",
    "bot_access_token"=>"xoxb-XXXXXX-XXXXXXXX"}}}}

    View Slide

  126. oauth response
    {"provider"=>"slack",
    "uid"=>"UXXXXXXX",
    "info"=>
    {"nickname"=>"jwright",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX",
    "name"=>nil,
    "email"=>nil,
    "first_name"=>nil,
    # …
    },
    "credentials"=>
    {"token"=>"xoxp-XXXXX-XXXXXXX-XXXXXX",
    "expires"=>false},
    "extra"=>
    {"raw_info"=>
    {"ok"=>true,
    "url"=>"https://bf.slack.com/",
    "team"=>"Brilliant Fantastic",
    "user"=>"jwright",
    "team_id"=>"TXXXXXX",
    "user_id"=>"UXXXXXX"},
    "web_hook_info"=>{},
    "bot_info"=>
    {"bot_user_id"=>"UXXXXXX",
    "bot_access_token"=>"xoxb-XXXXXX-XXXXXXXX"}}}}

    View Slide

  127. View Slide

  128. Start Bot

    View Slide

  129. Start Bot

    View Slide

  130. Start Bot

    View Slide

  131. Start Bot

    View Slide

  132. Start Bot

    View Slide

  133. Start Bot

    View Slide

  134. Start Bot
    http://api.slack.com/rtm

    View Slide

  135. Start Bot

    View Slide

  136. speaking
    module
    #S40926

    View Slide

  137. Introduce Bot
    http://api.slack.com/chat.postMessage

    View Slide

  138. listen
    module
    #aaYg5

    View Slide

  139. Event listening
    http://api.slack.com/events

    View Slide

  140. process
    module
    #9862sw

    View Slide

  141. Natural language processing

    View Slide

  142. Natural language processing
    Is BB8 ready to
    go?

    View Slide

  143. Natural language processing
    Is BB8 ready to
    go?
    intent: charge_status

    View Slide

  144. Natural language processing
    Is BB8 ready to
    go?
    intent:
    entities:
    charge_status
    target: "BB8"
    status: "ready"

    View Slide

  145. Natural language processing
    Is BB8 ready to
    go?
    intent:
    entities:
    confidence:
    charge_status
    target: "BB8"
    status: "ready"
    0.82

    View Slide

  146. nlp as a service

    View Slide

  147. nlp as a service

    View Slide

  148. nlp as a service
    http://api.wit.ai/message

    View Slide

  149. nlp as a service

    View Slide

  150. go and build bots

    View Slide

  151. Thank you for learning
    about how to build me.
    go and build bots

    View Slide

  152. go and build bots

    View Slide

  153. I know I'm not as difficult to
    build as that pain in the ass
    gold-plated primadonna.
    go and build bots

    View Slide

  154. go and build bots

    View Slide

  155. …and it took Anakin 7
    years to build that useless
    translator.
    go and build bots

    View Slide

  156. Resources
    http://github.com/juvet/juvet

    View Slide

  157. Resources
    http://dev4slack.xoxco.com

    View Slide

  158. Resources
    http://api.slack.com

    View Slide

  159. Resources
    http://twitter.com/slackapi

    View Slide

  160. Resources
    http://medium.com/@slackapi

    View Slide

  161. Resources
    http://botweekly.com

    View Slide

  162. Tatsu
    http://tatsu.io/middevcon

    View Slide

  163. Tatsu
    http://tatsu.io/middevcon

    View Slide

  164. @jwright

    View Slide

  165. Thanks for
    listening…
    …to a human?
    @jwright

    View Slide