Git Product home page Git Product logo

ex_microsoftbot's Introduction

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.2"}]
end
  1. 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"
  1. 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

Config

In addition to the required auth configs mentioned in Installation, there are a few more options available to customize this lib:

config :ex_microsoftbot
  using_bot_emulator: false,
  scope: "https://api.botframework.com/.default",
  http_timeout: nil

using_bot_emulator

Default false. Set this to true to disable the auth token manager, and instead use a fake auth token in all requests.

scope

Default "https://api.botframework.com/.default". This sets the scope used when authorizing with the BotFramework.

http_timeout

In milliseconds, defaults to the underlying lib (currently HTTPotion)'s default. Change this to set the timeout for each request to the Bot Framework.

ex_microsoftbot's People

Contributors

deybhayden avatar zabirauf avatar jmnsf avatar yondermon avatar dashenok avatar gavrilenco avatar hauntedhost avatar gfrivolt avatar fooqri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.