Spaces:
Runtime error
Runtime error
Greg Thompson
commited on
Commit
•
43f7f8e
1
Parent(s):
a81ed16
Separate prompt from other messages
Browse files
mathtext_fastapi/conversation_manager.py
CHANGED
@@ -159,9 +159,11 @@ def return_next_conversational_state(context_data, user_message, contact_uuid):
|
|
159 |
else:
|
160 |
state_label = 'addition-question-sequence'
|
161 |
|
|
|
|
|
162 |
message_package = {
|
163 |
'messages': messages,
|
164 |
-
'input_prompt':
|
165 |
'state': state_label
|
166 |
}
|
167 |
elif user_message == 'subtract':
|
@@ -224,6 +226,8 @@ def manage_conversation_response(data_json):
|
|
224 |
contact_uuid
|
225 |
)
|
226 |
|
|
|
|
|
227 |
|
228 |
headers = {
|
229 |
'Authorization': f"Bearer {os.environ.get('TURN_AUTHENTICATION_TOKEN')}",
|
@@ -233,6 +237,10 @@ def manage_conversation_response(data_json):
|
|
233 |
# Send all messages for the current state before a user input prompt (text/button input request)
|
234 |
for message in message_package['messages']:
|
235 |
data = create_text_message(message, whatsapp_id)
|
|
|
|
|
|
|
|
|
236 |
r = requests.post(
|
237 |
f'https://whatsapp.turn.io/v1/messages',
|
238 |
data=json.dumps(data),
|
|
|
159 |
else:
|
160 |
state_label = 'addition-question-sequence'
|
161 |
|
162 |
+
input_prompt = messages.pop()
|
163 |
+
|
164 |
message_package = {
|
165 |
'messages': messages,
|
166 |
+
'input_prompt': input_prompt,
|
167 |
'state': state_label
|
168 |
}
|
169 |
elif user_message == 'subtract':
|
|
|
226 |
contact_uuid
|
227 |
)
|
228 |
|
229 |
+
print("MESSAGE PACKAGE")
|
230 |
+
print(message_package)
|
231 |
|
232 |
headers = {
|
233 |
'Authorization': f"Bearer {os.environ.get('TURN_AUTHENTICATION_TOKEN')}",
|
|
|
237 |
# Send all messages for the current state before a user input prompt (text/button input request)
|
238 |
for message in message_package['messages']:
|
239 |
data = create_text_message(message, whatsapp_id)
|
240 |
+
|
241 |
+
print("data")
|
242 |
+
print(data)
|
243 |
+
|
244 |
r = requests.post(
|
245 |
f'https://whatsapp.turn.io/v1/messages',
|
246 |
data=json.dumps(data),
|