Esempio n. 1
0
def init():
    global page
    TABOT_ACCESS_TOKEN = "EAANbYW2bhcwBAHprKcgSrs86S3MFVdVv37auFZBAo4EPzAMTjKNDQuLj9227ai1Agbryvs2QXcHQgf7vHs2Xv0YynvT7XDo4wPAjSHabFyvbJVQfkUkZCJP7PZBRZBcLctaT7MG0aDSJDFZCBbnxcfR8KB48i9YAWLiIAmSmRevoiIfLGWUIY"
    page = Page(TABOT_ACCESS_TOKEN)
    page.show_starting_button("GET_START")
    page.greeting(
        "Hi {{user_first_name}}! TaBot is Messenger Bot to help you know more about Celcom Prepaid Package. Let's Get Started!"
    )
    page.show_persistent_menu([
        Template.ButtonPostBack("Available command ⚛️", 'COMMAND'),
        Template.ButtonWeb("Celcom website 📱", "https://www.celcom.com.my"),
        Template.ButtonPostBack("tabot", 'START')
    ])
Esempio n. 2
0
from src.helper import *

chatterbot = ChatBot("Training Example")
chatterbot.set_trainer(ChatterBotCorpusTrainer)

app = Flask(__name__)
ACCESS_TOKEN = os.environ['ACCESS_TOKEN']
VERIFY_TOKEN = os.environ['VERIFY_TOKEN']
page = Page(ACCESS_TOKEN)

raw_data, data, developers_data, team_udaan_data = prepare_data()
zipped = map_icon_list()
page.show_starting_button("START_PAYLOAD")

page.show_persistent_menu([
    Template.ButtonPostBack('Information', 'PMENU_' + 'Information'),
    Template.ButtonPostBack('Reach Us', 'PMENU_' + 'map')
])


@page.callback(['START_PAYLOAD'])
def start_callback(payload, event):
    page.send(
        event.sender_id,
        "Welcome to Udaan 2018! Write down info to get information about various events."
    )
    page.send(
        event.sender_id,
        "If you are new to this bot, type \'help\' to get instructions.")
    # page.send(event.sender_id, "Find details of individuals events: \"Give me details of Hardwizard \"")
    # page.send(event.sender_id, "Find list of events: \"tech events\"")
        page.send(sender_id, text, quick_replies=[{'title': '高額現金回饋', 'payload': 'cash'},
                                                  {'title': '旅遊交通', 'payload': 'traffic'},
                                                  {'title': '休閒娛樂', 'payload': 'entertain'},
                                                  {'title': '購物', 'payload': 'shopping'},
                                                  {'title': '電子支付功能(悠遊卡、一卡通)', 'payload': 'easycard'},
                                                  {'title': '宗教', 'payload': 'religion'}])
    ## 當使用者按下卡片中的'詳細資訊'時
    else:
        page.send(sender_id, card_detail(payload))

########################################################
## 設置起始按鈕與常駐選單
page.greeting('我們是一群致力於讓各位elite成為卡奴的學生,想變卡奴找我們準沒錯!')
page.show_starting_button('START')
page.show_persistent_menu([Template.ButtonPostBack('重新查詢', 'REFRESH'),
                           Template.ButtonWeb('前往此網頁以獲得更多資訊', 'https://money101.com.tw'),
                           Template.ButtonWeb('讓你看看我們的資料庫!', 'https://github.com/chrisyang-tw/PBC_Final/blob/master/data.csv')])

########################################################
## 訊息傳送與判斷
@page.handle_message
def message_handler(event):
    sender_id = event.sender_id
    message = event.message_text

    ## 讓機器人在使用者傳送訊息後立刻已讀訊息並開啟輸入指示器(點點點符號)
    page.mark_seen(sender_id)
    page.typing_on(sender_id)
    
    ## 子特色字典,等一下會用到
    sub_features = {'高額現金回饋': [{'title': '國內現金回饋', 'payload': 'in'},
Esempio n. 4
0
                  text,
                  quick_replies=[{
                      'title': '商品詢問',
                      'payload': 'Y'
                  }, {
                      'title': '訂購商品',
                      'payload': 'Y'
                  }])


########################################################
## 設置起始按鈕與常駐選單
page.greeting(
    '☆分享金龜婿と龜婦的台日生活\n★愛購物更ღ日貨的龜婦因此走上代購這條不歸路...\n★日本代購/網站代購(衣服.包包.帽子等)皆可私')
page.show_starting_button('START')
page.show_persistent_menu([Template.ButtonPostBack('重新查詢', 'REFRESH')])

########################################################
## 訊息傳送與判斷


@page.callback(['dealCart'], types=['POSTBACK'])
def callback_picked_genre(payload, event):
    global profile
    sender_id = event.sender_id
    count = 1
    cartSum = 0
    text = ''
    if len(profile[sender_id].orderDetail):
        for i in profile[sender_id].orderDetail:
            item = i.split(',')
Esempio n. 5
0
    page.typing_off(sender_id)

    # Conversation Starter
    quick_replies = [
        QuickReply(title="📦 Order Product", payload="PICK_ORDER"),
        QuickReply(title="💁 About Us", payload="PICK_ABOUT")
    ]

    page.send(sender_id,
              sender_name + ", here is some options for you.",
              quick_replies=quick_replies)


page.show_persistent_menu([
    Template.ButtonPostBack('👀 View Categories', 'MENU_CATEGORY'),
    Template.ButtonPostBack('🛍 View Cart', 'MENU_CART'),
    Template.ButtonWeb("🌐 Created by Softopian", "www.softopian.com")
])


@page.callback(['MENU_CATEGORY'])
def click_persistent_menu_cat(payload, event):
    print("Selected Category")
    page.send(event.sender_id, template_categories())


@page.callback(['MENU_CART'])
def click_persistent_menu_cart(payload, event):
    print("Selected Cart")

    response = template_cart_items(event.sender_id)
Esempio n. 6
0
VERIFY_TOKEN = "this is the veryfy token"
"""     End Of Constants    """
"""app instance setup"""
app = Flask(__name__)
app.config[
    "SQLALCHEMY_DATABASE_URI"] = "mysql://*****:*****@localhost/bot_db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.secret_key = "horhe borhes"
""" EOF """
""" Flask_Migrate instance """
migrate = Migrate(app, db)
""" page instance setup """
page = Page(PAGE_ACCESS_TOKEN)
page.show_starting_button("GET_STARTED")
page.show_persistent_menu([
    Template.ButtonPostBack('contact info', 'PERSISTENT_CONTACT_INFO'),
    Template.ButtonWeb("MOVEONCOMPANY", "www.google.com")
])
page.greeting("Hello!")
""" EOF """
"""for modularity"""
""" EOF """


@app.route('/', methods=['POST'])
def webhook():
    """the center of all """
    data = request.get_json()
    # pprint(data)  #FIXME: remove this line from production
    page.handle_webhook(request.get_data(as_text=True))
    return "ok", 200
Esempio n. 7
0
PAT= ''
page = Page(PAT)

#this is the welcome screen before you get started
page.greeting("Hi! I'm Todd! If you want to laugh or just need someone to make you happy, I'm the right person to talk to!")


#this will show the get started button
page.show_starting_button("START_PAYLOAD")
@page.callback(['START_PAYLOAD'])
def start_callback(payload, event):
    print("Let's start!")

#the different menus that are being shown
page.show_persistent_menu([Template.ButtonPostBack('What do I do?', 'MENU_PAYLOAD/1'),
                           Template.ButtonPostBack('Hotline', 'MENU_PAYLOAD/2'),
                           Template.ButtonWeb('Other Hotlines', 'http://www.pleaselive.org/hotlines/')]
                          )

@page.callback(['MENU_PAYLOAD/(.+)'])
def click_persistent_menu(payload, event):
    click_menu = payload.split('/')[1]
    print("you clicked %s menu" % click_menu)

#quick replies for the different selections the user can ask for
quick_replies_list = [{
                      "content_type":"text",
                      "title": emoji.emojize("Meme :thumbs_up:"),
                      "image_url": "https://emojipedia-us.s3.amazonaws.com/thumbs/144/facebook/65/grinning-face-with-smiling-eyes_1f601.png",
                      "payload": "meme",
                      },
                      {