254 lines
15 KiB
HTML
254 lines
15 KiB
HTML
<!doctype html>
|
||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||
<title>Dialogflow - Home Assistant</title>
|
||
<meta name="author" content="Home Assistant">
|
||
<meta name="description" content="Instructions how integrate Dialogflow with Home Assistant.">
|
||
<meta name="viewport" content="width=device-width">
|
||
<link rel="canonical" href="https://home-assistant.io/components/dialogflow/">
|
||
<meta property="fb:app_id" content="338291289691179">
|
||
<meta property="og:title" content="Dialogflow">
|
||
<meta property="og:site_name" content="Home Assistant">
|
||
<meta property="og:url" content="https://home-assistant.io/components/dialogflow/">
|
||
<meta property="og:type" content="article">
|
||
<meta property="og:description" content="Instructions how integrate Dialogflow with Home Assistant.">
|
||
<meta property="og:image" content="https://home-assistant.io/images/default-social.png">
|
||
<meta name="twitter:card" content="summary_large_image">
|
||
<meta name="twitter:site" content="@home_assistant">
|
||
<meta name="twitter:title" content="Dialogflow">
|
||
<meta name="twitter:description" content="Instructions how integrate Dialogflow with Home Assistant.">
|
||
<meta name="twitter:image" content="https://home-assistant.io/images/default-social.png">
|
||
<link href="/stylesheets/screen.css" media="screen, projection, print" rel="stylesheet">
|
||
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
|
||
<link rel='shortcut icon' href='/images/favicon.ico' />
|
||
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
|
||
</head>
|
||
<body >
|
||
<header class='site-header'>
|
||
<div class="grid-wrapper">
|
||
<div class="grid">
|
||
<div class="grid__item three-tenths lap-two-sixths palm-one-whole ha-title">
|
||
<a href="/" class="site-title">
|
||
<img width='40' src='/demo/favicon-192x192.png'>
|
||
<span>Home Assistant</span>
|
||
</a>
|
||
</div>
|
||
<div class="grid__item seven-tenths lap-four-sixths palm-one-whole">
|
||
<nav>
|
||
<input type="checkbox" id="toggle">
|
||
<label for="toggle" class="toggle" data-open="Main Menu" data-close="Close Menu"></label>
|
||
<ul class="menu pull-right">
|
||
<li><a href="/getting-started/">Getting started</a></li>
|
||
<li><a href="/components/">Components</a></li>
|
||
<li><a href="/docs/">Docs</a></li>
|
||
<li><a href="/cookbook/">Examples</a></li>
|
||
<li><a href="/developers/">Developers</a></li>
|
||
<li><a href="/blog/">Blog</a></li>
|
||
<li><a href="/help/">Need help?</a></li>
|
||
<li><a href='#' class='show-search'><i class="icon-search"></i></a></li>
|
||
</ul>
|
||
</nav>
|
||
<div class='search-container' style='display: none'>
|
||
<div class='search'>
|
||
<i class="icon-search"></i>
|
||
<input id='search' placeholder='Search the docs…'>
|
||
<a href='#' class='close'><i class="icon-remove-sign"></i></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
<div class="grid-wrapper">
|
||
<div class="grid grid-center">
|
||
<div class="grid__item two-thirds lap-one-whole palm-one-whole">
|
||
<article class="page">
|
||
<header>
|
||
<h1 class="title indent">
|
||
Dialogflow
|
||
</h1>
|
||
</header>
|
||
<hr class="divider">
|
||
<p class="note">
|
||
Before 0.56 this component was named <code class="highlighter-rouge">apiai</code>.
|
||
</p>
|
||
<p>The <code class="highlighter-rouge">dialogflow</code> component is designed to be used with the <a href="https://dialogflow.com/docs/fulfillment#webhook">webhook</a> integration of <a href="https://dialogflow.com/">Dialogflow</a>. When a conversation ends with a user, Dialogflow sends an action and parameters to the webhook.</p>
|
||
<p>Dialogflow requires a public endpoint (HTTPS recommended), so your Home Assistant should be exposed to the Internet. Dialogflow will return fallback answers if your server does not answer or takes too long (more than 5 seconds).</p>
|
||
<p>Dialogflow could be <a href="https://dialogflow.com/docs/integrations/">integrated</a> with many popular messaging, virtual assistant and IoT platforms.</p>
|
||
<p>Using Dialogflow will be easy to create conversations like:</p>
|
||
<blockquote>
|
||
<p>User: What is the temperature at home?</p>
|
||
<p>Bot: The temperature is 34 degrees</p>
|
||
</blockquote>
|
||
<blockquote>
|
||
<p>User: Turn on the light</p>
|
||
<p>Bot: In which room?</p>
|
||
<p>User: In the kitchen</p>
|
||
<p>Bot: Turning on kitchen light</p>
|
||
</blockquote>
|
||
<p>To use this integration, you should define a conversation (intent) in Dialogflow, configure Home Assistant with the speech to return and, optionally, the action to execute.</p>
|
||
<h3><a class="title-link" name="configuring-your-dialogflow-account" href="#configuring-your-dialogflow-account"></a> Configuring your Dialogflow account</h3>
|
||
<ul>
|
||
<li><a href="https://console.dialogflow.com/">Login</a> with your Google account</li>
|
||
<li>Click on “Create Agent”</li>
|
||
<li>Select name, language (if you are planning to use Google Actions check their <a href="https://support.google.com/assistant/answer/7108196?hl=en">supported languages</a>) and time zone</li>
|
||
<li>Click “Save”</li>
|
||
<li>Go to “Fulfillment” (in the left menu)</li>
|
||
<li>Enable Webhook and set your Home Assistant URL with the Dialogflow endpoint, e.g. <code class="highlighter-rouge">https://myhome.duckdns.org/api/dialogflow?api_password=HA_PASSWORD</code></li>
|
||
<li>Click “Save”</li>
|
||
<li>Create a new intent</li>
|
||
<li>Below “User says” write one phrase that you, the user, will tell Dialogflow, e.g. <code class="highlighter-rouge">What is the temperature at home?</code></li>
|
||
<li>In “Action” set some key (this will be the bind with Home Assistant configuration), eg.: GetTemperature</li>
|
||
<li>In “Response” set “Cannot connect to Home Assistant or it is taking to long” (fall back response)</li>
|
||
<li>At the end of the page, click on “Fulfillment” and check “Use webhook”</li>
|
||
<li>Click “Save”</li>
|
||
<li>On the top right, where is written “Try it now…”, write, or say, the phrase you have previously defined and hit enter</li>
|
||
<li>Dialogflow has send a request to your Home Assistant server</li>
|
||
</ul>
|
||
<p>Take a look to “Integrations”, in the left menu, to configure third parties.</p>
|
||
<h3><a class="title-link" name="configuring-home-assistant" href="#configuring-home-assistant"></a> Configuring Home Assistant</h3>
|
||
<p>When activated, the <a href="/components/alexa/"><code class="highlighter-rouge">alexa</code> component</a> will have Home Assistant’s native intent support handle the incoming intents. If you want to run actions based on intents, use the <a href="/components/intent_script"><code class="highlighter-rouge">intent_script</code></a> component.</p>
|
||
<h2><a class="title-link" name="examples" href="#examples"></a> Examples</h2>
|
||
<p>Download <a href="https://github.com/home-assistant/home-assistant.github.io/blob/next/source/assets/HomeAssistant_APIAI.zip">this zip</a> and load it in your Dialogflow agent (<strong>Settings</strong> -> <strong>Export and Import</strong>) for examples intents to use with this configuration:</p>
|
||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||
<span class="s">dialogflow</span><span class="pi">:</span>
|
||
|
||
<span class="s">intent_script</span><span class="pi">:</span>
|
||
<span class="s">Temperature</span><span class="pi">:</span>
|
||
<span class="s">speech</span><span class="pi">:</span>
|
||
<span class="s">text</span><span class="pi">:</span> <span class="s">The temperature at home is {{ states('sensor.home_temp') }} degrees</span>
|
||
<span class="s">LocateIntent</span><span class="pi">:</span>
|
||
<span class="s">speech</span><span class="pi">:</span>
|
||
<span class="s">text</span><span class="pi">:</span> <span class="pi">></span>
|
||
<span class="no">{%- for state in states.device_tracker -%}</span>
|
||
<span class="no">{%- if state.name.lower() == User.lower() -%}</span>
|
||
<span class="no">{{ state.name }} is at {{ state.state }}</span>
|
||
<span class="no">{%- elif loop.last -%}</span>
|
||
<span class="no">I am sorry, I do not know where {{ User }} is.</span>
|
||
<span class="no">{%- endif -%}</span>
|
||
<span class="no">{%- else -%}</span>
|
||
<span class="no">Sorry, I don't have any trackers registered.</span>
|
||
<span class="no">{%- endfor -%}</span>
|
||
<span class="s">WhereAreWeIntent</span><span class="pi">:</span>
|
||
<span class="s">speech</span><span class="pi">:</span>
|
||
<span class="s">text</span><span class="pi">:</span> <span class="pi">></span>
|
||
<span class="no">{%- if is_state('device_tracker.adri', 'home') and</span>
|
||
<span class="no">is_state('device_tracker.bea', 'home') -%}</span>
|
||
<span class="no">You are both home, you silly</span>
|
||
<span class="no">{%- else -%}</span>
|
||
<span class="no">Bea is at {{ states("device_tracker.bea") }}</span>
|
||
<span class="no">and Adri is at {{ states("device_tracker.adri") }}</span>
|
||
<span class="no">{% endif %}</span>
|
||
<span class="s">TurnLights</span><span class="pi">:</span>
|
||
<span class="s">speech</span><span class="pi">:</span>
|
||
<span class="s">text</span><span class="pi">:</span> <span class="s">Turning {{ Room }} lights {{ OnOff }}</span>
|
||
<span class="s">action</span><span class="pi">:</span>
|
||
<span class="pi">-</span> <span class="s">service</span><span class="pi">:</span> <span class="s">notify.pushbullet</span>
|
||
<span class="s">data_template</span><span class="pi">:</span>
|
||
<span class="s">message</span><span class="pi">:</span> <span class="s">Someone asked via apiai to turn {{ Room }} lights {{ OnOff }}</span>
|
||
<span class="pi">-</span> <span class="s">service_template</span><span class="pi">:</span> <span class="pi">></span>
|
||
<span class="no">{%- if OnOff == "on" -%}</span>
|
||
<span class="no">switch.turn_on</span>
|
||
<span class="no">{%- else -%}</span>
|
||
<span class="no">switch.turn_off</span>
|
||
<span class="no">{%- endif -%}</span>
|
||
<span class="s">data_template</span><span class="pi">:</span>
|
||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s2">"</span><span class="s">switch.light_{{</span><span class="nv"> </span><span class="s">Room</span><span class="nv"> </span><span class="s">|</span><span class="nv"> </span><span class="s">replace('</span><span class="nv"> </span><span class="s">',</span><span class="nv"> </span><span class="s">'_')</span><span class="nv"> </span><span class="s">}}"</span>
|
||
</code></pre>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
<aside id="sidebar" class="grid__item one-third lap-one-whole palm-one-whole">
|
||
<div class="grid">
|
||
<section class="aside-module grid__item one-whole lap-one-half">
|
||
<div class='edit-github'><a href='https://github.com/home-assistant/home-assistant.github.io/tree/current/source/_components/dialogflow.markdown'>Edit this page on GitHub</a></div>
|
||
<div class='brand-logo-container section'>
|
||
<img src='/images/supported_brands/dialogflow.png' />
|
||
</div>
|
||
<div class='section'>
|
||
Introduced in release: 0.56
|
||
</div>
|
||
<div class='section'>
|
||
<h1 class="title delta">Category Voice</h1>
|
||
<ul class='divided'>
|
||
<li>
|
||
<a href='/components/alexa/'>Alexa / Amazon Echo</a>
|
||
</li>
|
||
<li>
|
||
<a href='/components/conversation/'>Conversation</a>
|
||
</li>
|
||
<li>
|
||
Dialogflow
|
||
</li>
|
||
<li>
|
||
<a href='/components/google_assistant/'>Google Assistant</a>
|
||
</li>
|
||
<li>
|
||
<a href='/components/cloud/'>Home Assistant Cloud</a>
|
||
</li>
|
||
<li>
|
||
<a href='/components/mycroft/'>Mycroft</a>
|
||
</li>
|
||
<li>
|
||
<a href='/components/snips/'>Snips</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</aside>
|
||
</div>
|
||
</div>
|
||
<footer>
|
||
<div class="grid-wrapper">
|
||
<div class="grid">
|
||
<div class="grid__item">
|
||
<div class="copyright">
|
||
<a rel="me" href='https://twitter.com/home_assistant'><i class="icon-twitter"></i></a>
|
||
<a rel="me" href='https://facebook.com/homeassistantio'><i class="icon-facebook"></i></a>
|
||
<a rel="me" href='https://plus.google.com/110560654828510104551'><i class="icon-google-plus"></i></a>
|
||
<a rel="me" href='https://github.com/home-assistant/home-assistant'><i class="icon-github"></i></a>
|
||
<div class="credit">
|
||
Contact us at <a href='mailto:hello@home-assistant.io'>hello@home-assistant.io</a> (no support!).<br>
|
||
Website powered by <a href='http://jekyllrb.com/'>Jekyll</a> and the <a href='https://github.com/coogie/oscailte'>Oscalite theme</a>.<br />
|
||
Hosted by <a href='https://pages.github.com/'>GitHub</a> and served by <a href='https://cloudflare.com'>CloudFlare</a>.
|
||
</div>
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">home-assistant.io</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
<script>
|
||
var _gaq=[['_setAccount','UA-57927901-1'],['_trackPageview']];
|
||
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
||
s.parentNode.insertBefore(g,s)}(document,'script'));
|
||
</script>
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" />
|
||
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
|
||
<script type="text/javascript">
|
||
docsearch({
|
||
apiKey: 'ae96d94b201c5444c8a443093edf3efb',
|
||
indexName: 'home-assistant',
|
||
inputSelector: '#search',
|
||
debug: false // Set debug to true if you want to inspect the dropdown
|
||
});
|
||
document.querySelector('.search .close').addEventListener('click', function(ev) {
|
||
ev.preventDefault();
|
||
document.querySelector('.search-container').style.display = 'none';
|
||
});
|
||
document.querySelector('.show-search').addEventListener('click', function(ev) {
|
||
ev.preventDefault();
|
||
document.querySelector('.search-container').style.display = 'block';
|
||
document.getElementById('toggle').checked = false;
|
||
document.querySelector('.search-container input').focus();
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|