def handle_current_vendor(page_id):
    current_vendor = Vendor.find_by_page_id(page_id)
    catalog = Catalog.find_by_page_id(page_id)
    if not catalog:
        catalog = Catalog(page_id)
        catalog.save()
        print(catalog)
    return current_vendor, catalog
Beispiel #2
0
def itemDetail():
    catalog = Catalog()

    if request.method == 'GET':
        item = request.args.get('item', '')
        print(type(item))
        print(item)
    else:
        item = "Placeholder"

    for index in range(len(catalog.items)):
        for key in catalog.items[index]:
            if catalog.items[index][key] == item:
                item = catalog.items[index]
                print(item)

    #item = request.args.get('item')
    #itemj = jsonify(item)
    #print(type(item))
    #pp = pprint.PrettyPrinter(indent=4)
    #pp.pprint(itemj)
    return render_template('itemDetail.html',
                           title='Product Detail',
                           item=item,
                           catalog=catalog)
def handle_first_time_vendor(page_id):
    new_vendor = Vendor.find_by_page_id(page_id)
    bot = Bot(new_vendor.page_access_token)
    catalog = Catalog(page_id)
    catalog.save()
    knowledge = catalog.knowledge
    bot.set_get_started({
        'get_started': {
            'payload': 'get_started'
        }
    })
    bot.set_persistent_menu({
        'persistent_menu': [
            {
                'locale': 'default',
                'composer_input_disabled': False,
                'call_to_actions': [
                    {
                        'type': 'postback',
                        'title': knowledge['persistant_menut']['values'][0]['value']
                    },
                    {
                        'type': 'postback',
                        'title': knowledge['persistant_menut']['values'][1]['value']
                    },
                    {
                        'type': 'web_url',
                        'title': 'Powered By Sentri',
                        'url': 'https://www.sentri.io/',
                    }
                ]
            }
        ]
    })
    new_vendor.is_setup = True
    new_vendor.save()
    return new_vendor, catalog
def ask_wit(msg, page_id):
    client = Wit('GQ4J2DTDIZSTOFHZ744JOP5MWXKWQCX2')
    response = client.message(msg)
    print(response)
    if response['intents'] == []:
        return False
    intent = response['intents'][0]
    knowledge = Catalog.find_by_page_id(
        page_id).knowledge['comments']['values']
    print(msg)
    print(knowledge)
    print(intent)
    if intent['confidence'] > 0.55:
        for q in knowledge:
            if q['key'] == intent['name']:
                print(q)
                return q['value']
    return False
Beispiel #5
0
def products():
    catalog = Catalog()
    return render_template('products.html',
                           title='Product List',
                           catalog=catalog)
Beispiel #6
0
def catalog():
    catalog = Catalog()
    return render_template('catalog.html',
                           title='Product Catalog',
                           catalog=catalog)