-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (28 loc) · 1.04 KB
/
main.py
File metadata and controls
40 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from juji_python_sdk import Chatbot
import time
# Create a chatbot instance
chatbot = Chatbot("<chatbot_url>")
participation = chatbot.start_chat()
# ########################################################
# # Asynchronous message handling
# ########################################################
# def handle_message(message: dict):
# if message["type"] == "normal":
# print(f"Juji: {message['text']}")
# elif message["type"] == "flowinfo":
# print(f"Juji is waiting for your response...")
# participation.add_message_callback(handle_message)
# time.sleep(10)
# print("You: Hello, how are you?")
# participation.send_chat_msg("Hello, how are you?")
# time.sleep(10)
# print("You: Bye!")
# participation.end()
########################################################
# Synchronous message handling
########################################################
messages = participation.get_messages()
print(messages)
print("You: Hello, how are you?")
messages = participation.send_chat_msg("Hello, how are you?")
print(messages)