Skip to content

Commit

Permalink
Merge pull request #155 from busunkim96/use-google-cloud-dialogflow
Browse files Browse the repository at this point in the history
Use dialogflow types from 'google-cloud-dialogflow' package
  • Loading branch information
treethought committed Nov 10, 2021
2 parents db505ce + 9aa31db commit 0cb4f20
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Expand Up @@ -23,7 +23,7 @@ MarkupSafe = "*"
"ruamel.yaml" = "*"
Werkzeug = "*"
google-auth = "*"
dialogflow = "*"
google-cloud-dialogflow = "*"

[requires]
python_version = "3.7"
Expand Down
8 changes: 4 additions & 4 deletions flask_assistant/response/dialogflow.py
@@ -1,17 +1,17 @@
import dialogflow_v2beta1 as df
from google.cloud import dialogflow_v2 as df
from google.protobuf.json_format import MessageToDict


def build_card(
text, title, img_url=None, img_alt=None, subtitle=None, link=None, link_title=None,
):

button = df.types.intent_pb2.Intent.Message.Card.Button(
button = df.Intent.Message.Card.Button(
text=link_title, postback=link
)
card = df.types.intent_pb2.Intent.Message.Card(title=title, subtitle=text)
card = df.Intent.Message.Card(title=title, subtitle=text)
card.buttons.append(button)
payload = MessageToDict(card)
payload = df.Intent.Message.Card.to_dict(card)
return {"card": payload, "lang": "en"}
# card_payload = {"card": {"title": title, "subtitle": text, "formattedText": text}}
# return card_payload
9 changes: 4 additions & 5 deletions flask_assistant/response/hangouts.py
@@ -1,5 +1,4 @@
import dialogflow_v2beta1 as df
from google.protobuf.json_format import MessageToDict
from google.cloud import dialogflow_v2 as df
import logging


Expand All @@ -15,11 +14,11 @@ def build_card(
if link_title is None:
link_title = "Learn More"

button = df.types.intent_pb2.Intent.Message.Card.Button(
button = df.Intent.Message.Card.Button(
text=link_title, postback=link
)
card = df.types.intent_pb2.Intent.Message.Card(title=title, subtitle=text)
card = df.Intent.Message.Card(title=title, subtitle=text)
card.buttons.append(button)

payload = MessageToDict(card)
payload = df.Intent.Message.Card.to_dict(card)
return {"card": payload, "platform": "GOOGLE_HANGOUTS", "lang": "en"}
6 changes: 3 additions & 3 deletions requirements.txt
Expand Up @@ -4,10 +4,10 @@ cachetools==4.2.0
certifi==2020.12.5
chardet==4.0.0
click==8.0.0a1
dialogflow==1.1.0
google-cloud-dialogflow==2.9.1
flask==1.1.2
google-api-core[grpc]==1.24.1
google-auth==1.24.0
google-api-core[grpc]==1.28.0
google-auth==1.25.0
googleapis-common-protos==1.52.0
grpcio==1.34.0
idna==2.10
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -29,7 +29,7 @@
"ruamel.yaml",
"aniso8601",
"google-auth",
"dialogflow",
"google-cloud-dialogflow",
],
setup_requires=["pytest-runner"],
tests_require=["pytest"],
Expand Down

0 comments on commit 0cb4f20

Please sign in to comment.