Skip to content

Commit 5495af3

Browse files
authored
chore: update dialogflow_cx_v3_webhook_configure_session_parameters snippet (#411)
1 parent b20018d commit 5495af3

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

Dialogflow-CX/webhook_configure_session_parameters.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,25 @@
1414

1515
""" DialogFlow CX: webhook to configure new session parameters."""
1616

17-
# [START dialogflow_v3beta1_webhook_configure_session_parameters]
17+
# [START dialogflow_cx_v3_webhook_configure_session_parameters]
1818

1919
# TODO (developer): change entry point to configure_session_params in Cloud Function
2020

2121

2222
def configure_session_params(request):
2323
"""Webhook to validate or configure new session parameters."""
2424

25-
request_dict = request.get_json()
26-
tag = request_dict["fulfillmentInfo"]["tag"]
27-
28-
new_session_parameter = "Hi, I am new!"
29-
text = f"{new_session_parameter}. I'm a session parameter configured by the webhook. The webhook's tag is {tag}."
25+
order_number = 123
3026

3127
json_response = {
32-
"fulfillment_response": {
33-
"messages": [
34-
{
35-
"text": {
36-
"text": [
37-
# fulfillment text response to be sent to the agent
38-
text
39-
],
40-
},
41-
},
42-
],
43-
},
4428
"sessionInfo": {
4529
"parameters": {
46-
"newSessionParameter": new_session_parameter,
30+
"orderNumber": order_number,
4731
},
4832
},
4933
}
5034

5135
return json_response
5236

5337

54-
# [END dialogflow_v3beta1_webhook_configure_session_parameters]
38+
# [END dialogflow_cx_v3_webhook_configure_session_parameters]

Dialogflow-CX/webhook_configure_session_parameters_test.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,8 @@ def fixture_app():
2828
def test_validate_parameter(app):
2929
"""Test for configure new session parameters."""
3030

31-
request = {"fulfillmentInfo": {"tag": "MOCK_TAG"}}
31+
request = {"fulfillmentInfo": {"tag": "configure-session-parameter"}}
3232

3333
with app.test_request_context(json=request):
3434
res = configure_session_params(flask.request)
35-
assert (
36-
res["fulfillment_response"]["messages"][0]["text"]["text"][0]
37-
== (
38-
"Hi, I am new!. I'm a session parameter configured by the webhook. "
39-
"The webhook's tag is MOCK_TAG."
40-
)
41-
)
35+
assert "orderNumber" in res["sessionInfo"]["parameters"]

0 commit comments

Comments
 (0)