Elixir client for Microsoft bot framework
Elixir
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
mix.exs
mix.lock

README.md

MIT licensed hex.pm version Build Status Inline docs Made with Spacemacs

Elixir Microsoft Bot Client

This library provides Elixir API wrapper for the Microsoft Bot Framework and handles authentication and token management.

Documentation

API documentation is available at https://hexdocs.pm/ex_microsofbot

Installation

  1. Add ex_microsoftbot to your list of dependencies in mix.exs:

        def deps do
          [{:ex_microsoftbot, "~> 2.0.0"}]
        end
  2. Add the registered bot app id and app password in your config:

        config :ex_microsoftbot,
          app_id: "BOT_APP_ID",
          app_password: "BOT_APP_PASSWORD"
  3. Start the ex_microsoftbot:

        def application do
          [applications: [:ex_microsoftbot]]
        end

Usage

The modules ExMicrosoftBot.Client.Attachments and ExMicrosoftBot.Client.Conversations contain the functions to call the corresponding API of Microsoft Bot Framework. For example

alias ExMicrosoftBot.Client.Conversations

def reply(activity = %Activity{}) do
  text = "Hello, world!"

  resp_activity =
    %Activity{
      type: "message",
      conversation: activity.conversation,
      recipient: activity.from,
      from: activity.recipient,
      replyToId: activity.id,
      text: text
    }

  Conversations.reply_to_activity(
    activity.serviceUrl,
    activity.conversation.id,
    activity.id,
    resp_activity
  )
end