New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate dialogflow over to the new webhook component #17804
Changes from 3 commits
9096c6d
8423b8f
4dba687
7443c7a
40da115
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"config": { | ||
"title": "Dialogflow", | ||
"step": { | ||
"user": { | ||
"title": "Set up the Dialogflow Webhook", | ||
"description": "Are you sure you want to set up Dialogflow?" | ||
} | ||
}, | ||
"abort": { | ||
"one_instance_allowed": "Only a single instance is necessary.", | ||
"not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive Dialogflow messages." | ||
}, | ||
"create_entry": { | ||
"default": "To send events to Home Assistant, you will need to setup [webhook integration of Dialogflow]({dialogflow_url}).\n\nFill in the following info:\n\n- URL: `{webhook_url}`\n- Method: POST\n- Content Type: application/json\n\nSee [the documentation]({docs_url}) for further details." | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"config": { | ||
"title": "Dialogflow", | ||
"step": { | ||
"user": { | ||
"title": "Set up the Dialogflow Webhook", | ||
"description": "Are you sure you want to set up Dialogflow?" | ||
} | ||
}, | ||
"abort": { | ||
"one_instance_allowed": "Only a single instance is necessary.", | ||
"not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive Dialogflow messages." | ||
}, | ||
"create_entry": { | ||
"default": "To send events to Home Assistant, you will need to setup [webhook integration of Dialogflow]({dialogflow_url}).\n\nFill in the following info:\n\n- URL: `{webhook_url}`\n- Method: POST\n- Content Type: application/json\n\nSee [the documentation]({docs_url}) for further details." | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,8 @@ def context(self, request): | |
|
||
return Context(user_id=user.id) | ||
|
||
def json(self, result, status_code=200, headers=None): | ||
@staticmethod | ||
def json(result, status_code=200, headers=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to expose this and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not do this. This is conflation of concerns. Webhooks should work without any |
||
"""Return a JSON response.""" | ||
try: | ||
msg = json.dumps( | ||
|
@@ -54,13 +55,14 @@ def json(self, result, status_code=200, headers=None): | |
response.enable_compression() | ||
return response | ||
|
||
def json_message(self, message, status_code=200, message_code=None, | ||
@staticmethod | ||
def json_message(message, status_code=200, message_code=None, | ||
headers=None): | ||
"""Return a JSON message response.""" | ||
data = {'message': message} | ||
if message_code is not None: | ||
data['code'] = message_code | ||
return self.json(data, status_code, headers=headers) | ||
return HomeAssistantView.json(data, status_code, headers=headers) | ||
|
||
def register(self, app, router): | ||
"""Register the view with a router.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Tests for the Dialogflow component.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that it's a webhook when the caller expects a response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forget about the comment above.
However, we should not use
HomeAssistantView
but instead use aiohttp directly.Docs