Skip to content

Commit 7ab0b0a

Browse files
committed
Rename Action Menu tutorial, fix broken links and register webhook handler
1 parent 81f5ff2 commit 7ab0b0a

File tree

2 files changed

+70
-23
lines changed

2 files changed

+70
-23
lines changed

tutorials/aries-basic-controller/notebooks/alice/Part 8 - Action Menu.ipynb renamed to tutorials/aries-basic-controller/notebooks/alice/Part 9 - Action Menu.ipynb

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"\n",
1111
"In this notebook we'll be going through the Action Menu Protocol. For details on the protocol, please refer to the [RFC](https://github.com/hyperledger/aries-rfcs/tree/master/features/0509-action-menu).\n",
1212
"\n",
13-
"A requirement for this protocol to work is an active DIDComm communication channel between Alice and Bob. To achieve that, you should have completed the [Establishing a Connection](http://localhost:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial."
13+
"A requirement for this protocol to work is an active DIDComm communication channel between Alice and Bob. To achieve that, you should have completed the [Establishing a Connection](http://127.0.0.1:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial."
1414
]
1515
},
1616
{
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 20,
27+
"execution_count": 1,
2828
"metadata": {},
2929
"outputs": [
3030
{
@@ -74,7 +74,19 @@
7474
"loop = asyncio.get_event_loop()\n",
7575
"loop.create_task(agent_controller.listen_webhooks())\n",
7676
"\n",
77-
"agent_controller.register_listeners([], defaults=True)"
77+
"def action_menu_handler(payload):\n",
78+
" print(\"Action Menu Handler Called\")\n",
79+
" print(f\"Payload {payload}\")\n",
80+
" connection_id = payload[\"connection_id\"]\n",
81+
" state = payload[\"state\"]\n",
82+
" print(f\"Connection {connection_id} in State {state}\")\n",
83+
" \n",
84+
"action_menu_listener = {\n",
85+
" \"handler\": action_menu_handler,\n",
86+
" \"topic\": \"connections\"\n",
87+
"}\n",
88+
"\n",
89+
"agent_controller.register_listeners([action_menu_listener], defaults=True)"
7890
]
7991
},
8092
{
@@ -85,9 +97,8 @@
8597
"\n",
8698
"An active connection between Alice and Bob is required. You can either:\n",
8799
"\n",
88-
"- complete the [Establishing a Connection](http://localhost:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial, or\n",
89-
"- running the python script `create_connection.py` in the setup folder, or\n",
90-
"- complete the did-exchange tutorial ([Alice](http://localhost:8888/notebooks/did-exchange-inviter.ipynb) and [Bob](http://localhost:8889/notebooks/did-exchange-invitee.ipynb)) "
100+
"- complete the [Establishing a Connection](http://127.0.0.1:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial, or\n",
101+
"- running the python script `create_connection.py` in the setup folder"
91102
]
92103
},
93104
{
@@ -152,7 +163,7 @@
152163
"cell_type": "markdown",
153164
"metadata": {},
154165
"source": [
155-
"## 5. Continue with step 6 of [Bob's notebook](http://localhost:8889/notebooks/Part%208%20-%20Action%20Menu.ipynb)"
166+
"## 5. Continue with step 6 of [Bob's notebook](http://127.0.0.1:8889/notebooks/Part%209%20-%20Action%20Menu.ipynb)"
156167
]
157168
},
158169
{
@@ -250,21 +261,35 @@
250261
},
251262
{
252263
"cell_type": "code",
253-
"execution_count": 21,
264+
"execution_count": 6,
254265
"metadata": {},
255266
"outputs": [
256267
{
257-
"name": "stdout",
258-
"output_type": "stream",
259-
"text": [
260-
"None\n"
268+
"ename": "RuntimeError",
269+
"evalue": "Site <aiohttp.web_runner.TCPSite object at 0x7fee28bec250> is not registered in runner <aiohttp.web_runner.AppRunner object at 0x7fee28c25cb0>",
270+
"output_type": "error",
271+
"traceback": [
272+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
273+
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
274+
"\u001b[0;32m<ipython-input-6-5870155ffed5>\u001b[0m in \u001b[0;36masync-def-wrapper\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
275+
"\u001b[0;32m/aries_basic_controller/aries_controller.py\u001b[0m in \u001b[0;36mterminate\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 113\u001b[0m \u001b[0;32mawait\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclient_session\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 114\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwebhook_site\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 115\u001b[0;31m \u001b[0;32mawait\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwebhook_site\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 116\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 117\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
276+
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/aiohttp/web_runner.py\u001b[0m in \u001b[0;36mstop\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 54\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 55\u001b[0m \u001b[0;32masync\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mstop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 56\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_runner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_site\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 57\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_server\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_runner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_unreg_site\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
277+
"\u001b[0;32m/opt/conda/lib/python3.7/site-packages/aiohttp/web_runner.py\u001b[0m in \u001b[0;36m_check_site\u001b[0;34m(self, site)\u001b[0m\n\u001b[1;32m 276\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0msite\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sites\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 277\u001b[0m raise RuntimeError(\"Site {} is not registered in runner {}\"\n\u001b[0;32m--> 278\u001b[0;31m .format(site, self))\n\u001b[0m\u001b[1;32m 279\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 280\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_unreg_site\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msite\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mBaseSite\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
278+
"\u001b[0;31mRuntimeError\u001b[0m: Site <aiohttp.web_runner.TCPSite object at 0x7fee28bec250> is not registered in runner <aiohttp.web_runner.AppRunner object at 0x7fee28c25cb0>"
261279
]
262280
}
263281
],
264282
"source": [
265283
"response = await agent_controller.terminate()\n",
266284
"print(response)"
267285
]
286+
},
287+
{
288+
"cell_type": "code",
289+
"execution_count": null,
290+
"metadata": {},
291+
"outputs": [],
292+
"source": []
268293
}
269294
],
270295
"metadata": {

tutorials/aries-basic-controller/notebooks/bob/Part 8 - Action Menu.ipynb renamed to tutorials/aries-basic-controller/notebooks/bob/Part 9 - Action Menu.ipynb

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"\n",
1111
"In this notebook we'll be going through the Action Menu Protocol. For details on the protocol, please refer to the [RFC](https://github.com/hyperledger/aries-rfcs/tree/master/features/0509-action-menu). Specifically, we'll demonstrate how Bob acts as a Responder to respond to Action Menu related requests from Alice.\n",
1212
"\n",
13-
"A requirement for this protocol to work is an active DIDComm communication channel between Alice and Bob. To achieve that, you should have completed the [Establishing a Connection](http://localhost:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial."
13+
"A requirement for this protocol to work is an active DIDComm communication channel between Alice and Bob. To achieve that, you should have completed the [Establishing a Connection](http://127.0.0.1:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial."
1414
]
1515
},
1616
{
@@ -68,7 +68,19 @@
6868
"loop = asyncio.get_event_loop()\n",
6969
"loop.create_task(agent_controller.listen_webhooks())\n",
7070
"\n",
71-
"agent_controller.register_listeners([], defaults=True)"
71+
"def action_menu_handler(payload):\n",
72+
" print(\"Action Menu Handler Called\")\n",
73+
" print(f\"Payload {payload}\")\n",
74+
" connection_id = payload[\"connection_id\"]\n",
75+
" state = payload[\"state\"]\n",
76+
" print(f\"Connection {connection_id} in State {state}\")\n",
77+
" \n",
78+
"action_menu_listener = {\n",
79+
" \"handler\": action_menu_handler,\n",
80+
" \"topic\": \"connections\"\n",
81+
"}\n",
82+
"\n",
83+
"agent_controller.register_listeners([action_menu_handler], defaults=True)"
7284
]
7385
},
7486
{
@@ -79,9 +91,8 @@
7991
"\n",
8092
"An active connection between Alice and Bob is required. You can either:\n",
8193
"\n",
82-
"- complete the [Establishing a Connection](http://localhost:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial, or\n",
83-
"- running the python script `create_connection.py` in the setup folder, or\n",
84-
"- complete the did-exchange tutorial ([Alice](http://localhost:8888/notebooks/did-exchange-inviter.ipynb) and [Bob](http://localhost:8889/notebooks/did-exchange-invitee.ipynb)) "
94+
"- complete the [Establishing a Connection](http://127.0.0.1:8888/notebooks/Part%203%20-%20Establishing%20a%20Connection.ipynb) tutorial, or\n",
95+
"- running the python script `create_connection.py` in the setup folder"
8596
]
8697
},
8798
{
@@ -178,7 +189,7 @@
178189
"cell_type": "markdown",
179190
"metadata": {},
180191
"source": [
181-
"## 7. Continue with step 8 of [Alice's notebook](http://localhost:8889/notebooks/Part%208%20-%20Action%20Menu.ipynb)"
192+
"## 7. Continue with step 8 of [Alice's notebook](http://127.0.0.1:8889/notebooks/Part%209%20-%20Action%20Menu.ipynb)"
182193
]
183194
},
184195
{
@@ -192,21 +203,32 @@
192203
},
193204
{
194205
"cell_type": "code",
195-
"execution_count": 11,
206+
"execution_count": 1,
196207
"metadata": {},
197208
"outputs": [
198209
{
199-
"name": "stdout",
200-
"output_type": "stream",
201-
"text": [
202-
"None\n"
210+
"ename": "NameError",
211+
"evalue": "name 'agent_controller' is not defined",
212+
"output_type": "error",
213+
"traceback": [
214+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
215+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
216+
"\u001b[0;32m<ipython-input-1-5870155ffed5>\u001b[0m in \u001b[0;36masync-def-wrapper\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
217+
"\u001b[0;31mNameError\u001b[0m: name 'agent_controller' is not defined"
203218
]
204219
}
205220
],
206221
"source": [
207222
"response = await agent_controller.terminate()\n",
208223
"print(response)"
209224
]
225+
},
226+
{
227+
"cell_type": "code",
228+
"execution_count": null,
229+
"metadata": {},
230+
"outputs": [],
231+
"source": []
210232
}
211233
],
212234
"metadata": {

0 commit comments

Comments
 (0)