GithubHelp home page GithubHelp logo

aida's People

Contributors

aeatencio avatar juanboca avatar lmatayoshi avatar macoca avatar matiasgarciaisaia avatar nditada avatar nekron avatar vtiffenberg avatar waj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ayarulin

aida's Issues

Basic Facebook channel

Create a basic Facebook channel capable of echo back every message received.

Let's hardcode the parameters for the Facebook channel for now ("page_id", "verify_token" and "access_token") and use those parameters to verify the callback received from Facebook Messenger API and reply with a message to the same user with the same content.

Return confidence for language detector skill

We can asume for now that if the only word in a message is a perfect match with the name of a language, we have 100% confidence that the user wants to change the language.

If not, for now we can just return 0 and let the other skills take over.

Parse manifest

Manifests must be parsed to create a Bot structure instance when new bots are pushed or when the system starts. Create a BotParser module capable of parse the bot manifest and return a Bot structure with skills and channels.

Validate survey responses

Add "constraint" and "constraint_message" to the json schema for survey steps.

If the step has a "constraint" expression, evaluate it over the given answer and reply with "constraint_message" if the evaluation is "false".

Also, use the "constraint_message" for invalid answers.

Skill relevance

Each skill can specify an xpath expression that determines if the skill applies or not for a user at the moment of receiving a message or a skill is activated.

Bot supervisor

After the system starts, the bot supervisor must create one BotServer (GenServer) for each bot.

Whenever a bot is updated, a message is sent to the corresponding server so it can reload the configuration.

Add "Confidence Distance Threshold" in manifest and use in Frontdesk

  • Parse value in manifest
  • Trigger clarification for all Skills that fall within the "confidence distance" from the confidence upper bound.
  • If only one skill responded with a confidence higher than 0%, then handle message with that Skill only if it's confidence = Confidence distance threshold

Add `Message.words` function and use it on the skills

Instead of splitting, converting and removing unwanted characters on every skill, add a function to the Message module that returns a list with the words present in the content.

Something like this:

Regex.scan(~r/\w+/u, str) |> Enum.map(&hd/1)

Then replace existing calls to String.split and similar on the skills by calling to this new function.

Allow interpolations within messages

Message strings can contain interpolation of variables like this: "Hello ${name}!"

Variable values must be extracted from the session taking into account the last portion of the variable name after splitting by "/".

[RFC] Name and IDs per skill in manifest

1- Skills will be renamed by users in the UI.
2- Stats of Skill usage need to be persistent across renames.
3- Therefore we need an ID for a skill in the manifest.
4- We might also want to have the name of the skill in the manifest for logging purposes.
5- It might be good to not be strict about the type of the IDs to allow for manual creation or other tools to emit manifests. Maybe just a unique (not repeated in the manifest) string?

Support pictures content from respondents

Currently, only text is supported as content. Let's add support for pictures.

  • Change Message.content so it's either a TextContent or a ImageContent. The ImageContent will contain the URL received by the channel
  • Fix all the skills expecting text from the content (most of the time, skills will return a confidence = 0 when the content is an image)
  • Support image questions in the survey. When the question is executed, download and store the image sent by the user in a new images table. Store the URL to retrieve the image in the session value.

Skip logic for surveys

When the steps has a "relevant" attribute, evaluate the condition and skip if the result is "false"

Invalid stats for empty state

message received and message sent are returned as null instead of 0
active users does return 0 when the bot has just been published.

Bot CRUD

Store bots with a simple db schema with the fields:

  • id
  • guid
  • manifest (JSON)

Store all conversation messages

For audit purposes, store all the incoming and outgoing messages in a new table (message_logs) with the following fields:

  • id (autonumeric)
  • bot_id
  • session_id
  • direction (incoming/outgoing)
  • content
  • timestamp

Add channels into manifest definition

Add the "channels" section into the JSON schema definition. Each channel will be an object with a "type" identifier. For now, only "facebook" channels are allowed with the following structure:

{
  "type": "facebook",
  "page_id": "152279268715860",
  "verify_token": "eSAM6WbxaLSc4GNBGnEfA4mgH9rvXQjdhNetYnMt",
  "access_token": "2XUFvv8JJbB9sQW3gWneKkY7kYpV4u7whNkcwLbd"
}

Basic structure to store bot configuration in memory

We decided to store bots configuration in a ETS table. Let's define two modules:

  • Bot: holds the entire bot configuration and serves as the entry point to reply messages
  • BotConfig: manages the active bots in memory. It will keep the ETS table up to date and lookup for bots by id. It provides functions like start/stop/reload to respond to configuration changes.

Scheduled messages - inactivity check

Support in manifest something like the sketch below. Delay is in minutes. Messages get triggered after the user has not sent any message for that time.

"type": "scheduled_messages",
"id": "inactivity_check",
"name": "Inactivity Check",

Messages:
schedule_type: since_last_message
Delay: 2880
Message:
En: “Hey, I didn’t hear from you for the last 2 days, is there anything I can help with?”

Solve connection of channels by FB to Aida

If channel is created in the UI and the user goes to FB to setup the tokens before "publishing", the challenge sent to the Bot Engine from FB will not match any existing channel nor verification token.

Maybe just a note with a "you have to publish the bot before entering these data in FB".

[tech-debt] Remove special treatments for language_detector skill

Make language_detector a skill without special treatments (specially on bot.ex).
Every skill should have a function where it defines what pre-conditions needs to be 'activated'.
Every skill that is not a language_detector should ask at least for a language to be defined before allowing its use. This way, the only active skill when there is no language selected will be the language_detector.
If there is only one language available, maybe the bot should be the one that sets it on the session.

Capture and expose total number of messages per period

  • Keep a table with day, received messages, sent messages
  • For each message sent, increment the sent message for the current day.
  • For each message received, increment the received message for the current day.
  • Expose totals of both values via API for "today", "this_week" and "this_month"

Capture and expose Skill usage per period

  • Keep a table with respondent_id, skill_id, last_usage_datetime
  • For each skill that handles a response, update the corresponding row with the current datetime.
  • Expose count of unique respondes per skill via API for "today", "this_week" and "this_month". Return counts for all skills for a period in a single request.

Add "language_detector" to manifest schema

Example definition for this skill:

{
  "type": "language_detector",
  "explanation": "To chat in english say 'english'. Para hablar en español escribe 'español'",
  "languages": {
    "en": ["english"],
    "es": ["español"]
  }
}

Facebook channels

Connect the existing basic Facebook channel with the Bot. For this, lookup the channel configuration by page_id calling Facebook.find_channel_for_page_id. Then obtain the bot by calling BotManager.find and execute the message through the Bot instance.

Parser for xpath expressions

We need to support:

  • and, or, not
  • <, >, <=, >=, =
  • function calls: foo(...)
  • variables: ${foo}
  • . (current value)
  • literals: integers, strings, booleans

Handle errors on Facebook channel

Now if the chatbot fails Facebook will stop working.
The user should receive an error message.
We should log the error in Sentry.

Capture and expose unique respondent per period

  • Keep a table with respondent_id and last_incoming_message_datetime
  • For each incoming message from a respondent, update the last_..._datetime for that respondent
  • Expose count of unique respondents for Today, This Week (Sun to Sat?), This Month.
  • All periods start and end in UTC
  • via an endpoint with something like "/api/stats/unique_respondents?period=[today|this_week|this month]

Bot variables with overrides

Allow definitions of variables in the manifest with overrides depending on the session variables. For example:

{
  "variables": [
    {
      "name": "food_options",
      "values": {
        "en": "barbecue and pasta",
        "es": "parrilla y pasta"
      },
      "overrides": [
        {
          "relevant": "${age} >= 18",
          "values": {
            "en": "barbecue and pasta",
            "es": "parrilla y pasta"
          }
        }
      ]
    }
  ]
}

Temporary bots

Add an optional flag "temporary" to the bots. These bots will be automatically deleted after some time of inactivity.

  • Accept a "temp" parameter in the query string while publishing a new bot
  • Add a "temp" column to the bots table and set it to "true" if a temp=true was passed while creating

Endpoints to list sessions and get session logs

Add the following endpoints to the SessionController:

Session index

GET /api/bots/<bot_id>/sessions

This endpoint should return the existing sessions for the bot:

{
  "data": [
    {"id": "", "first_message": "2017-01-01T01:23:45Z", "last_message": "2017-01-01T01:23:45Z"}
  ]
}

Session log

GET /api/bots/<bot_id>/sessions/<session_id>/log

{
  "data": [
    {"timestamp": "", "direction": "incoming | outgoing", "content": ""}
  ]
}

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.