Giter VIP home page Giter VIP logo

arbiturbot's Introduction

ARBITRURBOT

A service oriented intelligent engine to provide a chat interface to costumer management.

Setup

  • Install docker and docker-compose
  • Create environment file .env
SPREAD_URL={if this is to connect to a spreadsheet, insert url here}
GPT_URL=https://transformer.huggingface.co/autocomplete/gpt
ARBITRUR_PHONE={phone number format: 8111231234}
ARBITRUR_MONGO_URL={from cluster url https://www.mongodb.com/, make sure to setup networking access and username}
CHAT_TOKEN={from chat-api.com}
CLI_ON=0 // 1 for CLI Mode
LUIS_AI_ID={from luis.ai, setup intelligence with two modes: report/sale}
LUIS_AI_KEY={from luis.ai}

root directory should also include credentials.json file (https://cran.r-project.org/web/packages/gargle/vignettes/get-api-credentials.html follow "OAuth client ID and secret" guide in that site for that)

  • run docker-compose build

Start server

  • Run ngrok locally (https://ngrok.com/) using ngrok http 5000
  • Setup ngrok manually using a function of type, using a function like:
def set_webhook():
    meta_chat = {
        "set": True,
        "webhookUrl": '(local ngrok url)'
    }
    return requests.post('https://api.chat-api.com/instance99459/webhook?token=(chat_api_token)', data=meta_chat).json()
  • run docker-compose up (-d if daemon)

Run terminal client

  • run docker-compose run web python3 cli.py

This will run the terminal client. It will ask if the database should be clear after using the client. Keep in mind that if you use the configuration given that points to atlas, this could delete all information stored.

Run tests

docker-compose run web pytest

Example objects on database

Example conversation object

{'_id': ObjectId('5e938eee9b41d7afbc3d4cd4'),
 'user_id': '[email protected]',
 'messages': [{'sender': 'user',
   'message': {'created_at': datetime.datetime(2020, 4, 12, 16, 58, 3, 234000),
    'user_id': '[email protected]',
    'text': 'Hola'},
   'type': 'user_utterance',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 3, 234000),
   'interaction_name': 'initial_user_message'},
  {'sender': 'bot',
   'message': {'created_at': datetime.datetime(2020, 4, 12, 16, 58, 3, 234000),
    'user_id': '[email protected]',
    'text': 'Hola'},
   'type': 'bot_response',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 8, 275000),
   'interaction_name': 'start'},
  {'sender': 'bot',
   'message': {'created_at': datetime.datetime(2020, 4, 12, 16, 58, 3, 234000),
    'user_id': '[email protected]',
    'text': 'Hola'},
   'type': 'bot_response',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 9, 554000),
   'interaction_name': 'what_name'},
  {'sender': 'bot',
   'message': {'created_at': datetime.datetime(2020, 4, 12, 16, 58, 13, 439000),
    'user_id': '[email protected]',
    'text': 'Ric'},
   'type': 'bot_response',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 16, 458000),
   'interaction_name': 'finish_conversation'},
  {'sender': 'bot',
   'message': {'created_at': datetime.datetime(2020, 4, 12, 16, 58, 13, 439000),
    'user_id': '[email protected]',
    'text': 'Ric'},
   'type': 'bot_response',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 25, 484000),
   'interaction_name': 'alert_conversation'}],
 'canonical_conversation': [{'sender_type': 'user',
   'sender_id': '[email protected]',
   'reciever_id': '[email protected]',
   'text': 'Hola',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 6, 969000)},
  {'sender_type': 'bot',
   'sender_id': '[email protected]',
   'reciever_id': '[email protected]',
   'text': 'Bienvenid@!',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 8, 223000)},
  {'sender_type': 'bot',
   'sender_id': '[email protected]',
   'reciever_id': '[email protected]',
   'text': 'Cuál es tu nombre?',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 9, 504000)},
  {'sender_type': 'user',
   'sender_id': '[email protected]',
   'reciever_id': '[email protected]',
   'text': 'Ric',
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 13, 579000)},
  {'sender_type': 'bot',
   'sender_id': '[email protected]',
   'reciever_id': '[email protected]',
   'text': "Ok, dame un segundo...'",
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 16, 398000)}],
 'context': {},
 'finished': 'true'}

Example User object

{'_id': ObjectId('5e938eee9b41d7afbc3d4cd3'),
 'id': '[email protected]',
 'source': 'inbound',
 'type': 'user',
 'name': 'Ric',
 'uuid': 'inbound_61502',
 'phone': '5218186861502',
 'country': '🇲🇽MX',
 'created_at': datetime.datetime(2020, 4, 12, 16, 58, 6, 102000),
 'owners': [],
 'threads': [{'label': None,
   'first_canonical_message_id': None,
   'last_canonical_message_id': 4,
   'solved': False,
   'created_at': datetime.datetime(2020, 4, 12, 16, 58, 25, 629000),
   'updated_at': datetime.datetime(2020, 4, 12, 16, 58, 25, 629000)}]}

Example Notification Object

[{'_id': ObjectId('5e93e56ccf39f61f8b2bf0e9'),
  'agent_id': '[email protected]',
  'user_id': '[email protected]',
  'thread_id': 0,
  'created_at': datetime.datetime(2020, 4, 12, 23, 7, 8, 639000),
  'last_notification_at': datetime.datetime(2020, 4, 13, 4, 18, 54, 449000),
  'type': 'interval',
  'settings': {'minutes': 30}}]

arbiturbot's People

Contributors

ricalanis avatar

Stargazers

 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.