import logging
from flask import Flask
from flask_assistant import Assistant, ask, card, carousel, list_selector, simple, suggest, context_manager as manager


app = Flask(__name__)
assist = Assistant(app)
logging.getLogger('flask_assistant').setLevel(logging.DEBUG)


@assist.action('Default Welcome Intent')
def welcome():
    speech = 'Welcome to Flask-Assistant on the Google Assistant! Wanna see what I can do?'
    return simple(speech)




@assist.action('Default Welcome Intent - yes')
def action_func():
    speech = """This is just a simple text to speech message, not too impressive.
                Ask to see a card!"""
    return simple(speech)

@assist.action('ShowCard')
def show_card():
    title = 'A Simple Card'
    img_url = "http://flask-assistant.readthedocs.io/en/latest/_static/logo-xs.png"

    text = """Flask-Assistant allows you to focus on building the core business logic
                of conversational user interfaces while utilizing API.AI’s
                Natural Language Processing to interact with users."""

    speech = 'Now ask to see a list...'

    return card(speech, text, title, img_url)


@assist.action('ShowList')
def action_func():
    mylist = list_selector(speech='Here is a list', title='My Sample List')
    mylist.add_item('Option A', 'Key1', img_url="http://flask-assistant.readthedocs.io/en/latest/_static/logo-xs.png")
    mylist.add_item('Option B', 'Key2')
    return mylist

@assist.action('ShowCarousel')
def action_func():
    mycarousel = carousel(speech='Here is a carousel', title='A sample carousel')
    mycarousel.add_item('Option A', 'Key1', img_url="http://flask-assistant.readthedocs.io/en/latest/_static/logo-xs.png")
    mycarousel.add_item('Option B', 'Key2')
    return mycarousel

@assist.action('ShowSuggestion')
def action_func():
    speech = 'Try these sugeestions'
    return suggest(speech, ['a', 'b', 'c'])


if __name__ == '__main__':
    app.run(debug=True)

@@ -80,82 +80,24 @@
 sk, 
-card, carousel, list_selector, simple, suggest, context_manager as manager
+tell, build_item
 %0A%0A%0Aa
@@ -200,24 +200,77 @@
 ng.DEBUG)%0A%0A%0A
+app.config%5B'INTEGRATIONS'%5D = %5B'ACTIONS_ON_GOOGLE'%5D%0A%0A%0A
 @assist.acti
@@ -416,30 +416,27 @@
  return 
-simple
+ask
 (speech)
 %0A%0A%0A%0A%0A@as
@@ -431,13 +431,57 @@
 ech)
-%0A
+.reprompt('Do you want to see some examples?')
 %0A%0A%0A
-%0A
 @ass
@@ -662,16 +662,17 @@
 ard!%22%22%22%0A
+%0A
     retu
@@ -678,22 +678,19 @@
 urn 
-simple
+ask
 (speech)
 %0A%0A@a
@@ -685,16 +685,51 @@
 (speech)
+.suggest('Show card', 'Show List')%0A
 %0A%0A@assis
@@ -1163,47 +1163,107 @@
   re
-turn card(speech, text, title, img_url)
+sp = ask(speech)%0A    resp.card(text, title, img_url)%0A    resp.suggest('Show List')%0A%0A    return resp
 %0A%0A%0A@
@@ -1311,260 +1311,1047 @@
 ():%0A
+%0A
     
-mylist = list_selector(speech='Here is a list', title='My Sample List')%0A    mylist.add_item('Option A', 'Key1', img_url=%22http://flask-assistant.readthedocs.io/en/latest/_static/logo-xs.png%22)%0A    mylist.add_item('Option B', 'Key2')%0A    return mylist
+#Build items independent of list%0A    items = %5B%5D%0A    for i in range(4,10):%0A        title = 'Item %7B%7D'.format(i)%0A        key = str(i)%0A        items.append(build_item(title, key))%0A%0A    resp = ask(%22Here's an example of a list selector%22)%0A    mylist = resp.build_list('Cool Projects')  # passes the speech paramter to new class%0A%0A%0A    mylist.add_item('Flask-Assistant', key='flask_assistant', img_url=%22http://flask-assistant.readthedocs.io/en/latest/_static/logo-xs.png%22)%0A    mylist.add_item('Flask-Ask', key='flask_ask')%0A    mylist.add_item('Alphabets', key='alphabets')%0A%0A    # include built items in list%0A    mylist.include_items(items).link_out('GitHub Repo', 'https://github.com/treethought/flask-assistant')%0A%0A    return mylist%0A%0A%0A@assist.action('FlaskAssistantCarousel')%0Adef action_func():%0A    resp = tell('Heres some info on Flask-Assistant').build_carousel()%0A    resp.add_item('Title', key='title', description='Here is a Description')%0A    resp.add_item('Title2', key='title2', description='Here is another descriotion')%0A    return resp
 %0A%0A@a
@@ -2452,16 +2452,42 @@
 rousel',
+%0A                         
  title='
@@ -2522,32 +2522,41 @@
 rousel.add_item(
+%0A        
 'Option A', 'Key
@@ -2705,16 +2705,17 @@
 rousel%0A%0A
+%0A
 @assist.

use build_items (independent of response instannce) for ShowList