treethought / flask-assistant

Framework for Building Virtual Assistants with Dialogflow and python
Apache License 2.0
380 stars 100 forks source link

NameError: error with making a card with button - SOLUTION #117

Closed mmohades closed 5 years ago

mmohades commented 5 years ago

This is my code for creating a card:

resp.card(text="card text", title="Title",
                  img_url="https://media.giphy.com/media/U7LNQ8qOv329r1y8aH/giphy.gif",
                  link="https://google.com", link_title="I Did!")

However, I received the following error, and the problem is with creating the link.

 File "/usr/local/lib/python3.7/site-packages/flask_assistant/response.py", line 148, in card
    btn_payload = [{"title": link_tmagnet_illustration.xmlitle, "openUriAction": {"uri": link}}]
NameError: name 'link_tmagnet_illustration' is not defined

The simple fix is changing the flask_assistant code. Open flask_assistant/response.py Look for (probably line 147):

if link and link_title:
            btn_payload = [{"title": link_tmagnet_illustration.xmlitle, "openUriAction": {"uri": link}}]
            card_payload["buttons"] = btn_payload

and change it to this:

if link and link_title:
            btn_payload = [{"title": link_title, "openUriAction": {"uri": link}}]
            card_payload["buttons"] = btn_payload

It should work then.

treethought commented 5 years ago

hi @mmohades. I think you may have accidentally added that variable to the response.py file. Notice that the file in the repo looks like your proposed solution https://github.com/treethought/flask-assistant/blob/9331b9796644dfa987bcd97a13e78e9ab62923d3/flask_assistant/response.py#L148

mmohades commented 5 years ago

@treethought You’re right! I'm pretty sure that I didn't modify the file myself, but it has to be with my code/computer not the library. I don't know how did that code get there! =)) Thank you for clarifying.

treethought commented 5 years ago

no problem!