after adding " "
NameError is gone, but now I got the other error.
My code is like this,
class ActionSessionStart(Action):
def name(self) -> Text:
return "action_session_start"
async def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
client = Client(url='opc.tcp://141.82.166.100:4840/freeopcua/server/')
client.connect()
node = client.get_node("ns=2;i=2")
print('#########################initial value=', node.get_value(),'###############################')
handler = SubscriptionHandler(dispatcher)
# We create a Client Subscription.
subscription = client.create_subscription(500, handler)
nodes = [
node,
]
# We subscribe to data changes for two nodes (variables).
subscription.subscribe_data_change(nodes)
return []
class SubscriptionHandler():
def __init__(self, dispatcher) -> None:
self._dispatcher = dispatcher
def datachange_notification(self, node: Node, val, data):
print('@@@@@@@@@@@@@@@@@datachange_notification %r %s' %(node, val),'@@@@@@@@@@@@@@@@@')
self._dispatcher.utter_message(text=('datachange_notification %r %s' %(node, val)))
data = {
"sender_id": "default",
"next_action": "action_notify_data_changed",
}
res = requests.post('http://localhost:5055/webhook/', data=json.dumps(data))
print(str(res.status_code) + " | " + res.text)
class AtionNotifyDataChanged(Action):
def name(self) -> Text:
return "action_notify_data_changed"
async def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text=("🛑Warning! test value is 0!"))
And I got an error like this:
Exception occurred while handling uri: 'http://localhost:5055/webhook/'
Traceback (most recent call last):
File "c:\users\je991\anaconda3\lib\site-packages\sanic\app.py", line 939, in handle_request
response = await response
File "c:\users\je991\anaconda3\lib\site-packages\rasa_sdk\endpoint.py", line 104, in webhook
result = await executor.run(action_call)
File "c:\users\je991\anaconda3\lib\site-packages\rasa_sdk\executor.py", line 392, in run
tracker_json = action_call["tracker"]
KeyError: 'tracker'
500 | <!DOCTYPE html><html lang=en><meta charset=UTF-8><title>⚠️ 500 — Internal Server Error</title>
<style>
html { font-family: sans-serif }
h2 { color: #888; }
.tb-wrapper p { margin: 0 }
.frame-border { margin: 1rem }
.frame-line > * { padding: 0.3rem 0.6rem }
.frame-line { margin-bottom: 0.3rem }
.frame-code { font-size: 16px; padding-left: 4ch }
.tb-wrapper { border: 1px solid #eee }
.tb-header { background: #eee; padding: 0.3rem; font-weight: bold }
.frame-descriptor { background: #e2eafb; font-size: 14px }
</style>
<h1>⚠️ 500 — Internal Server Error</h1><p>The server encountered an internal error and cannot complete your request.
Yes, I also tried in Postman, but it also have an error like this:
Cloud Agent Error: Can not send requests to localhost. Select a different agent.