Spaces:
Sleeping
Sleeping
williamagyapong
commited on
Update main.py
Browse files
main.py
CHANGED
@@ -45,12 +45,14 @@ client = openai.OpenAI(
|
|
45 |
base_url="https://api.sambanova.ai/v1",
|
46 |
)
|
47 |
|
48 |
-
|
|
|
|
|
49 |
messenger.send_button(
|
50 |
recipient_id=recipient_phone,
|
51 |
button={
|
52 |
"header": f"{header}",
|
53 |
-
"body": f"{
|
54 |
"footer": f"{footer}",
|
55 |
"action": {
|
56 |
"button": f"{btn_name}",
|
@@ -71,6 +73,34 @@ def messenger_button(recipient_phone, ai_response, header='Transaction Confirmat
|
|
71 |
},
|
72 |
)
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
def respond(query_str:str):
|
76 |
response = "hello, I don't have a brain yet"
|
@@ -117,7 +147,8 @@ def hook():
|
|
117 |
logging.info(f"\nAnswer: {response}\n")
|
118 |
|
119 |
# Send confirmation button
|
120 |
-
messenger_button(mobile, response)
|
|
|
121 |
|
122 |
intent = parsed_trans_data[0]['intent'].lower()
|
123 |
trans_type = parsed_trans_data[0]['transaction_type'].lower()
|
|
|
45 |
base_url="https://api.sambanova.ai/v1",
|
46 |
)
|
47 |
|
48 |
+
# Interactive button
|
49 |
+
# Returned message type: interactive
|
50 |
+
def messenger_button(recipient_phone, message, header='Transaction Confirmation', footer='', btn_name='Confirm Details'):
|
51 |
messenger.send_button(
|
52 |
recipient_id=recipient_phone,
|
53 |
button={
|
54 |
"header": f"{header}",
|
55 |
+
"body": f"{message}",
|
56 |
"footer": f"{footer}",
|
57 |
"action": {
|
58 |
"button": f"{btn_name}",
|
|
|
73 |
},
|
74 |
)
|
75 |
|
76 |
+
def messenger_reply_button(recipient_phone, message):
|
77 |
+
messenger.send_reply_button(
|
78 |
+
recipient_id=f"{recipient_phone}",
|
79 |
+
button={
|
80 |
+
"type": "button",
|
81 |
+
"body": {
|
82 |
+
"text": f"{message}"
|
83 |
+
},
|
84 |
+
"action": {
|
85 |
+
"buttons": [
|
86 |
+
{
|
87 |
+
"type": "reply",
|
88 |
+
"reply": {
|
89 |
+
"id": "confirm",
|
90 |
+
"title": "Record Transaction"
|
91 |
+
}
|
92 |
+
},
|
93 |
+
{
|
94 |
+
"type": "reply",
|
95 |
+
"reply": {
|
96 |
+
"id": "cancel",
|
97 |
+
"title": "Cancel"
|
98 |
+
}
|
99 |
+
}
|
100 |
+
]
|
101 |
+
}
|
102 |
+
},
|
103 |
+
)
|
104 |
|
105 |
def respond(query_str:str):
|
106 |
response = "hello, I don't have a brain yet"
|
|
|
147 |
logging.info(f"\nAnswer: {response}\n")
|
148 |
|
149 |
# Send confirmation button
|
150 |
+
# messenger_button(mobile, response)
|
151 |
+
messenger_reply_button(mobile, response)
|
152 |
|
153 |
intent = parsed_trans_data[0]['intent'].lower()
|
154 |
trans_type = parsed_trans_data[0]['transaction_type'].lower()
|