botnaut
Version:
Facebook Messenger Chatbot Framework
1,470 lines (895 loc) • 48.1 kB
HTML
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Responder · Botnaut</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<meta name="author" content="David Menger">
<link rel="stylesheet" href="../gitbook/style.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="Router.html" />
<link rel="prev" href="Request.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Building a chat bot</li>
<li class="chapter " data-level="1.1" data-path="../">
<a href="../">
Getting Started
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../tutorial/buildingConversation.html">
<a href="../tutorial/buildingConversation.html">
Building a Conversation
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../tutorial/buildingConversation.html">
<a href="../tutorial/buildingConversation.html#asking-a-question">
Asking a question
</a>
</li>
<li class="chapter " data-level="1.2.2" data-path="../tutorial/buildingConversation.html">
<a href="../tutorial/buildingConversation.html#using-quick-replies-for-controlling-conversation">
Using quick replies
</a>
</li>
<li class="chapter " data-level="1.2.3" data-path="../tutorial/buildingConversation.html">
<a href="../tutorial/buildingConversation.html#post-back-is-also-an-action">
Postbacks
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../tutorial/conversationState.html">
<a href="../tutorial/conversationState.html">
Conversation State
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../tutorial/conversationState.html">
<a href="../tutorial/conversationState.html#accessing-user-profile">
User profile
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="../tutorial/conversationState.html">
<a href="../tutorial/conversationState.html#using-the-state-in-navigation">
Using state in navigation
</a>
</li>
<li class="chapter " data-level="1.3.3" data-path="../tutorial/conversationState.html">
<a href="../tutorial/conversationState.html#reading-and-modifiing-user-state">
Reading and writing state
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../tutorial/asyncActions.html">
<a href="../tutorial/asyncActions.html">
Asynchronous Actions
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../tutorial/asyncActions.html">
<a href="../tutorial/asyncActions.html#blocking-asynchronous-actions">
Blocking Actions
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="../tutorial/asyncActions.html">
<a href="../tutorial/asyncActions.html#non-blocking-asynchronous-actions">
Non Blocking Actions
</a>
</li>
<li class="chapter " data-level="1.4.3" data-path="../tutorial/asyncActions.html">
<a href="../tutorial/asyncActions.html#loading-attachments-to-buffer">
Loading Attachments
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="../tutorial/advancedRouting.html">
<a href="../tutorial/advancedRouting.html">
Advanced Routing
</a>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="../tutorial/advancedRouting.html">
<a href="../tutorial/advancedRouting.html#resolving-actions">
Resolving Actions
</a>
</li>
<li class="chapter " data-level="1.5.2" data-path="../tutorial/advancedRouting.html">
<a href="../tutorial/advancedRouting.html#simple-text-actions">
Text Actions
</a>
</li>
<li class="chapter " data-level="1.5.3" data-path="../tutorial/advancedRouting.html">
<a href="../tutorial/advancedRouting.html#integrating-with-ai-prediction">
Integrating AI
</a>
</li>
<li class="chapter " data-level="1.5.4" data-path="../tutorial/advancedRouting.html">
<a href="../tutorial/advancedRouting.html#redirecting-flow-with-post-back">
Redirecting with Postback
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6" data-path="../tutorial/nestingRouters.html">
<a href="../tutorial/nestingRouters.html">
Nesting - Reusable Blocks
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1" data-path="../tutorial/nestingRouters.html">
<a href="../tutorial/nestingRouters.html#basic-concept">
Concept
</a>
</li>
<li class="chapter " data-level="1.6.2" data-path="../tutorial/nestingRouters.html">
<a href="../tutorial/nestingRouters.html#example">
Example
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="../tutorial/templates.html">
<a href="../tutorial/templates.html">
Sending Templates
</a>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="../tutorial/templates.html">
<a href="../tutorial/templates.html#button-template">
Button Template
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="../tutorial/templates.html">
<a href="../tutorial/templates.html#generic-template">
Generic Template
</a>
</li>
<li class="chapter " data-level="1.7.3" data-path="../tutorial/templates.html">
<a href="../tutorial/templates.html#receipt-template">
Receipt Template
</a>
</li>
<li class="chapter " data-level="1.7.4" data-path="../tutorial/templates.html">
<a href="../tutorial/templates.html#working-with-webviews">
Webviews
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.8" data-path="../tutorial/testing.html">
<a href="../tutorial/testing.html">
Testing
</a>
</li>
<li class="chapter " data-level="1.9" data-path="../tutorial/analytics.html">
<a href="../tutorial/analytics.html">
Analytics
</a>
</li>
<li class="chapter " data-level="1.10" data-path="../tutorial/usingWithWingbot.html">
<a href="../tutorial/usingWithWingbot.html">
Using with Wingbot.ai
</a>
<ul class="articles">
<li class="chapter " data-level="1.10.1" data-path="../tutorial/usingWithWingbot.html">
<a href="../tutorial/usingWithWingbot.html#bot-configuration">
Bot configuration
</a>
</li>
<li class="chapter " data-level="1.10.2" data-path="../tutorial/usingWithWingbot.html">
<a href="../tutorial/usingWithWingbot.html#express-mongodb">
Express Mongodb
</a>
</li>
<li class="chapter " data-level="1.10.3" data-path="../tutorial/usingWithWingbot.html">
<a href="../tutorial/usingWithWingbot.html#serverless-aws-lambda">
Serverless AWS Lambda
</a>
</li>
</ul>
</li>
<li class="header">API</li>
<li class="chapter " data-level="2.1" data-path="Request.html">
<a href="Request.html">
Request
</a>
</li>
<li class="chapter active" data-level="2.2" data-path="Responder.html">
<a href="Responder.html">
Responder
</a>
</li>
<li class="chapter " data-level="2.3" data-path="Router.html">
<a href="Router.html">
Router
</a>
</li>
<li class="chapter " data-level="2.4" data-path="Tester.html">
<a href="Tester.html">
Tester
</a>
</li>
<li class="chapter " data-level="2.5" data-path="ButtonTemplate.html">
<a href="ButtonTemplate.html">
Template Builders
</a>
<ul class="articles">
<li class="chapter " data-level="2.5.1" data-path="ButtonTemplate.html">
<a href="ButtonTemplate.html#ButtonTemplate">
ButtonTemplate
</a>
</li>
<li class="chapter " data-level="2.5.2" data-path="ButtonTemplate.html">
<a href="ButtonTemplate.html#GenericTemplate">
GenericTemplate
</a>
</li>
<li class="chapter " data-level="2.5.3" data-path="ButtonTemplate.html">
<a href="ButtonTemplate.html#ReceiptTemplate">
ReceiptTemplate
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="2.6" data-path="Settings.html">
<a href="Settings.html">
Bot Settings
</a>
</li>
<li class="chapter " data-level="2.7" data-path="express.html">
<a href="express.html">
Express/MongoDb tools
</a>
</li>
<li class="chapter " data-level="2.8" data-path="bufferloader.html">
<a href="bufferloader.html">
Utils
</a>
</li>
<li class="chapter " data-level="2.9" data-path="Ai.html">
<a href="Ai.html">
Ai
</a>
</li>
<li class="chapter " data-level="2.10" data-path="serverlessAWS.html">
<a href="serverlessAWS.html">
Serverless
</a>
</li>
<li class="chapter " data-level="2.11" data-path="BuildRouter.html">
<a href="BuildRouter.html">
Wingbot.ai
</a>
</li>
<li class="chapter " data-level="2.12" data-path="callback.html">
<a href="callback.html">
Middlewares
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href=".." >Responder</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<div id="Responder"> </div>
<h2 id="responder"><a name="responder" class="plugin-anchor" href="#responder"><i class="fa fa-link" aria-hidden="true"></i></a>Responder</h2>
<p><strong>Kind</strong>: global class </p>
<ul>
<li><a href="#Responder">Responder</a><ul>
<li><a href="#new_Responder_new">new Responder()</a></li>
<li><a href="#Responder_data">.data</a> : <code>object</code></li>
<li><a href="#Responder_setMessgingType">.setMessgingType(messagingType, [tag])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_isResponseType">.isResponseType()</a> ⇒ <code>boolean</code></li>
<li><a href="#Responder_setData">.setData(data)</a> ⇒ <code>this</code></li>
<li><a href="#Responder_text">.text(text, [quickReplies])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_setState">.setState(object)</a> ⇒ <code>this</code></li>
<li><a href="#Responder_addQuickReply">.addQuickReply(action, title, [data], [prepend])</a></li>
<li><a href="#Responder_expected">.expected(action)</a> ⇒ <code>this</code></li>
<li><a href="#Responder_toAbsoluteAction">.toAbsoluteAction(action)</a> ⇒ <code>string</code></li>
<li><a href="#Responder_image">.image(imageUrl, [reusable])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_video">.video(videoUrl, [reusable])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_file">.file(fileUrl, [reusable])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_wait">.wait([ms])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_typingOn">.typingOn()</a> ⇒ <code>this</code></li>
<li><a href="#Responder_typingOff">.typingOff()</a> ⇒ <code>this</code></li>
<li><a href="#Responder_seen">.seen()</a> ⇒ <code>this</code></li>
<li><a href="#Responder_passThread">.passThread(targetAppId, [data])</a> ⇒ <code>this</code></li>
<li><a href="#Responder_receipt">.receipt(recipientName, [paymentMethod], [currency], [uniqueCode])</a> ⇒ <code>ReceiptTemplate</code></li>
<li><a href="#Responder_button">.button(text)</a> ⇒ <code>ButtonTemplate</code></li>
<li><a href="#Responder_genericTemplate">.genericTemplate([shareable], [isSquare])</a> ⇒ <code>GenericTemplate</code></li>
<li><a href="#Responder_list">.list([topElementStyle])</a> ⇒ <code>ListTemplate</code></li>
</ul>
</li>
</ul>
<div id="new_Responder_new"> </div>
<h3 id="new-responder"><a name="new-responder" class="plugin-anchor" href="#new-responder"><i class="fa fa-link" aria-hidden="true"></i></a>new Responder()</h3>
<p>Instance of responder is passed as second parameter of handler (res)</p>
<div id="Responder_data"> </div>
<h3 id="responderdata--object"><a name="responderdata--object" class="plugin-anchor" href="#responderdata--object"><i class="fa fa-link" aria-hidden="true"></i></a>responder.data : <code>object</code></h3>
<p><strong>Kind</strong>: instance property of <a href="#Responder"><code>Responder</code></a> </p>
<div id="Responder_setMessgingType"> </div>
<h3 id="respondersetmessgingtypemessagingtype-tag-⇒-this"><a name="respondersetmessgingtypemessagingtype-tag-⇒-this" class="plugin-anchor" href="#respondersetmessgingtypemessagingtype-tag-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.setMessgingType(messagingType, [tag]) ⇒ <code>this</code></h3>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>messagingType</td>
<td><code>string</code></td>
<td></td>
</tr>
<tr>
<td>[tag]</td>
<td><code>string</code></td>
<td><code>null</code></td>
</tr>
</tbody>
</table>
<div id="Responder_isResponseType"> </div>
<h3 id="responderisresponsetype-⇒-boolean"><a name="responderisresponsetype-⇒-boolean" class="plugin-anchor" href="#responderisresponsetype-⇒-boolean"><i class="fa fa-link" aria-hidden="true"></i></a>responder.isResponseType() ⇒ <code>boolean</code></h3>
<p>Returns true, when responder is not sending an update (notification) message</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<div id="Responder_setData"> </div>
<h3 id="respondersetdatadata-⇒-this"><a name="respondersetdatadata-⇒-this" class="plugin-anchor" href="#respondersetdatadata-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.setData(data) ⇒ <code>this</code></h3>
<p>Set temporary data to responder, which are persisted through single event</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
<td><code>object</code></td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">bot.use(<span class="hljs-string">'foo'</span>, (req, res, postBack) => {
res.setData({ a: <span class="hljs-number">1</span> });
postBack(<span class="hljs-string">'bar'</span>);
});
bot.use(<span class="hljs-string">'bar'</span>, (req, res) => {
res.data.a; <span class="hljs-comment">// === 1 from postback</span>
});
</code></pre>
<div id="Responder_text"> </div>
<h3 id="respondertexttext-quickreplies-⇒-this"><a name="respondertexttext-quickreplies-⇒-this" class="plugin-anchor" href="#respondertexttext-quickreplies-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.text(text, [quickReplies]) ⇒ <code>this</code></h3>
<p>Send text as a response</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>text</td>
<td><code>string</code></td>
<td>text to send to user, can contain placeholders (%s)</td>
</tr>
<tr>
<td>[quickReplies]</td>
<td><code>Object.<string, string></code> \</td>
<td><code>Array.<Object></code></td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// simply</span>
res.text(<span class="hljs-string">'Hello %s'</span>, name, {
action: <span class="hljs-string">'Quick reply'</span>,
another: <span class="hljs-string">'Another quick reply'</span>
});
<span class="hljs-comment">// complex</span>
res.text(<span class="hljs-string">'Hello %s'</span>, name, [
{ action: <span class="hljs-string">'action'</span>, title: <span class="hljs-string">'Quick reply'</span> },
{
action: <span class="hljs-string">'complexAction'</span>, <span class="hljs-comment">// required</span>
title: <span class="hljs-string">'Another quick reply'</span>, <span class="hljs-comment">// required</span>
match: <span class="hljs-string">'string'</span> || <span class="hljs-regexp">/regexp/</span>, <span class="hljs-comment">// optional</span>
someData: <span class="hljs-string">'Will be included in payload data'</span> <span class="hljs-comment">// optional</span>
}
]);
</code></pre>
<div id="Responder_setState"> </div>
<h3 id="respondersetstateobject-⇒-this"><a name="respondersetstateobject-⇒-this" class="plugin-anchor" href="#respondersetstateobject-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.setState(object) ⇒ <code>this</code></h3>
<p>Sets new attributes to state (with Object.assign())</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>object</td>
<td><code>object</code></td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">res.setState({ visited: <span class="hljs-literal">true</span> });
</code></pre>
<div id="Responder_addQuickReply"> </div>
<h3 id="responderaddquickreplyaction-title-data-prepend"><a name="responderaddquickreplyaction-title-data-prepend" class="plugin-anchor" href="#responderaddquickreplyaction-title-data-prepend"><i class="fa fa-link" aria-hidden="true"></i></a>responder.addQuickReply(action, title, [data], [prepend])</h3>
<p>Appends quick reply, to be sent with following text method</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td><code>string</code></td>
<td></td>
<td>relative or absolute action</td>
</tr>
<tr>
<td>title</td>
<td><code>string</code></td>
<td></td>
<td>quick reply title</td>
</tr>
<tr>
<td>[data]</td>
<td><code>Object</code></td>
<td></td>
<td>additional data</td>
</tr>
<tr>
<td>[prepend]</td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>set true to add reply at the beginning</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">bot.use((req, res) => {
res.addQuickReply(<span class="hljs-string">'barAction'</span>, <span class="hljs-string">'last action'</span>);
res.addQuickReply(<span class="hljs-string">'theAction'</span>, <span class="hljs-string">'first action'</span>, {}, <span class="hljs-literal">true</span>);
res.text(<span class="hljs-string">'Text'</span>, {
fooAction: <span class="hljs-string">'goto foo'</span>
}); <span class="hljs-comment">// will be merged and sent with previously added quick replies</span>
});
</code></pre>
<div id="Responder_expected"> </div>
<h3 id="responderexpectedaction-⇒-this"><a name="responderexpectedaction-⇒-this" class="plugin-anchor" href="#responderexpectedaction-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.expected(action) ⇒ <code>this</code></h3>
<p>When user writes some text as reply, it will be processed as action</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td><code>string</code></td>
<td>desired action</td>
</tr>
</tbody>
</table>
<div id="Responder_toAbsoluteAction"> </div>
<h3 id="respondertoabsoluteactionaction-⇒-string"><a name="respondertoabsoluteactionaction-⇒-string" class="plugin-anchor" href="#respondertoabsoluteactionaction-⇒-string"><i class="fa fa-link" aria-hidden="true"></i></a>responder.toAbsoluteAction(action) ⇒ <code>string</code></h3>
<p>Converts relative action to absolute action path</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a><br><strong>Returns</strong>: <code>string</code> - absolute action path </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td><code>string</code></td>
<td>relative action to covert to absolute</td>
</tr>
</tbody>
</table>
<div id="Responder_image"> </div>
<h3 id="responderimageimageurl-reusable-⇒-this"><a name="responderimageimageurl-reusable-⇒-this" class="plugin-anchor" href="#responderimageimageurl-reusable-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.image(imageUrl, [reusable]) ⇒ <code>this</code></h3>
<p>Sends image as response. Requires appUrl option to send images from server</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>imageUrl</td>
<td><code>string</code></td>
<td></td>
<td>relative or absolute url</td>
</tr>
<tr>
<td>[reusable]</td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>force facebook to cache image</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// image on same server (appUrl option)</span>
res.image(<span class="hljs-string">'/img/foo.png'</span>);
<span class="hljs-comment">// image at url</span>
res.image(<span class="hljs-string">'https://google.com/img/foo.png'</span>);
</code></pre>
<div id="Responder_video"> </div>
<h3 id="respondervideovideourl-reusable-⇒-this"><a name="respondervideovideourl-reusable-⇒-this" class="plugin-anchor" href="#respondervideovideourl-reusable-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.video(videoUrl, [reusable]) ⇒ <code>this</code></h3>
<p>Sends video as response. Requires appUrl option to send videos from server</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>videoUrl</td>
<td><code>string</code></td>
<td></td>
<td>relative or absolute url</td>
</tr>
<tr>
<td>[reusable]</td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>force facebook to cache asset</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// file on same server (appUrl option)</span>
res.video(<span class="hljs-string">'/img/foo.mp4'</span>);
<span class="hljs-comment">// file at url</span>
res.video(<span class="hljs-string">'https://google.com/img/foo.mp4'</span>);
</code></pre>
<div id="Responder_file"> </div>
<h3 id="responderfilefileurl-reusable-⇒-this"><a name="responderfilefileurl-reusable-⇒-this" class="plugin-anchor" href="#responderfilefileurl-reusable-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.file(fileUrl, [reusable]) ⇒ <code>this</code></h3>
<p>Sends file as response. Requires appUrl option to send files from server</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>fileUrl</td>
<td><code>string</code></td>
<td></td>
<td>relative or absolute url</td>
</tr>
<tr>
<td>[reusable]</td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>force facebook to cache asset</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// file on same server (appUrl option)</span>
res.file(<span class="hljs-string">'/img/foo.pdf'</span>);
<span class="hljs-comment">// file at url</span>
res.file(<span class="hljs-string">'https://google.com/img/foo.pdf'</span>);
</code></pre>
<div id="Responder_wait"> </div>
<h3 id="responderwaitms-⇒-this"><a name="responderwaitms-⇒-this" class="plugin-anchor" href="#responderwaitms-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.wait([ms]) ⇒ <code>this</code></h3>
<p>Sets delay between two responses</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>[ms]</td>
<td><code>number</code></td>
<td><code>600</code></td>
</tr>
</tbody>
</table>
<div id="Responder_typingOn"> </div>
<h3 id="respondertypingon-⇒-this"><a name="respondertypingon-⇒-this" class="plugin-anchor" href="#respondertypingon-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.typingOn() ⇒ <code>this</code></h3>
<p>Sends "typing..." information</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<div id="Responder_typingOff"> </div>
<h3 id="respondertypingoff-⇒-this"><a name="respondertypingoff-⇒-this" class="plugin-anchor" href="#respondertypingoff-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.typingOff() ⇒ <code>this</code></h3>
<p>Stops "typing..." information</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<div id="Responder_seen"> </div>
<h3 id="responderseen-⇒-this"><a name="responderseen-⇒-this" class="plugin-anchor" href="#responderseen-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.seen() ⇒ <code>this</code></h3>
<p>Reports last message from user as seen</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<div id="Responder_passThread"> </div>
<h3 id="responderpassthreadtargetappid-data-⇒-this"><a name="responderpassthreadtargetappid-data-⇒-this" class="plugin-anchor" href="#responderpassthreadtargetappid-data-⇒-this"><i class="fa fa-link" aria-hidden="true"></i></a>responder.passThread(targetAppId, [data]) ⇒ <code>this</code></h3>
<p>Pass thread to another app</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>targetAppId</td>
<td><code>string</code></td>
<td></td>
</tr>
<tr>
<td>[data]</td>
<td><code>string</code> \</td>
<td><code>object</code></td>
<td><code>null</code></td>
</tr>
</tbody>
</table>
<div id="Responder_receipt"> </div>
<h3 id="responderreceiptrecipientname-paymentmethod-currency-uniquecode-⇒-receipttemplate"><a name="responderreceiptrecipientname-paymentmethod-currency-uniquecode-⇒-receipttemplate" class="plugin-anchor" href="#responderreceiptrecipientname-paymentmethod-currency-uniquecode-⇒-receipttemplate"><i class="fa fa-link" aria-hidden="true"></i></a>responder.receipt(recipientName, [paymentMethod], [currency], [uniqueCode]) ⇒ <code>ReceiptTemplate</code></h3>
<p>Sends Receipt template</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>recipientName</td>
<td><code>string</code></td>
<td></td>
<td></td>
</tr>
<tr>
<td>[paymentMethod]</td>
<td><code>string</code></td>
<td><code>"'Cash'"</code></td>
<td>should not contain more then 4 numbers</td>
</tr>
<tr>
<td>[currency]</td>
<td><code>string</code></td>
<td><code>"'USD'"</code></td>
<td>sets right currency</td>
</tr>
<tr>
<td>[uniqueCode]</td>
<td><code>string</code></td>
<td><code>null</code></td>
<td>when omitted, will be generated randomly</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">res.receipt(<span class="hljs-string">'Name'</span>, <span class="hljs-string">'Cash'</span>, <span class="hljs-string">'CZK'</span>, <span class="hljs-string">'1'</span>)
.addElement(<span class="hljs-string">'Element name'</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-string">'/inside.png'</span>, <span class="hljs-string">'text'</span>)
.send();
</code></pre>
<div id="Responder_button"> </div>
<h3 id="responderbuttontext-⇒-buttontemplate"><a name="responderbuttontext-⇒-buttontemplate" class="plugin-anchor" href="#responderbuttontext-⇒-buttontemplate"><i class="fa fa-link" aria-hidden="true"></i></a>responder.button(text) ⇒ <code>ButtonTemplate</code></h3>
<p>Sends nice button template. It can redirect user to server with token in url</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>text</td>
<td><code>string</code></td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">res.button(<span class="hljs-string">'Hello'</span>)
.postBackButton(<span class="hljs-string">'Text'</span>, <span class="hljs-string">'action'</span>)
.urlButton(<span class="hljs-string">'Url button'</span>, <span class="hljs-string">'/internal'</span>, <span class="hljs-literal">true</span>) <span class="hljs-comment">// opens webview with token</span>
.urlButton(<span class="hljs-string">'Other button'</span>, <span class="hljs-string">'https://goo.gl'</span>) <span class="hljs-comment">// opens in internal browser</span>
.send();
</code></pre>
<div id="Responder_genericTemplate"> </div>
<h3 id="respondergenerictemplateshareable-issquare-⇒-generictemplate"><a name="respondergenerictemplateshareable-issquare-⇒-generictemplate" class="plugin-anchor" href="#respondergenerictemplateshareable-issquare-⇒-generictemplate"><i class="fa fa-link" aria-hidden="true"></i></a>responder.genericTemplate([shareable], [isSquare]) ⇒ <code>GenericTemplate</code></h3>
<p>Creates a generic template</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>[shareable]</td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>ability to share template</td>
</tr>
<tr>
<td>[isSquare]</td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>use square aspect ratio for images</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">res.genericTemplate()
.addElement(<span class="hljs-string">'title'</span>, <span class="hljs-string">'subtitle'</span>)
.setElementImage(<span class="hljs-string">'/local.png'</span>)
.setElementUrl(<span class="hljs-string">'https://www.seznam.cz'</span>)
.postBackButton(<span class="hljs-string">'Button title'</span>, <span class="hljs-string">'action'</span>, { actionData: <span class="hljs-number">1</span> })
.addElement(<span class="hljs-string">'another'</span>, <span class="hljs-string">'subtitle'</span>)
.setElementImage(<span class="hljs-string">'https://goo.gl/image.png'</span>)
.setElementAction(<span class="hljs-string">'action'</span>, { actionData: <span class="hljs-number">1</span> })
.urlButton(<span class="hljs-string">'Local link with extension'</span>, <span class="hljs-string">'/local/path'</span>, <span class="hljs-literal">true</span>, <span class="hljs-string">'compact'</span>)
.send();
</code></pre>
<div id="Responder_list"> </div>
<h3 id="responderlisttopelementstyle-⇒-listtemplate"><a name="responderlisttopelementstyle-⇒-listtemplate" class="plugin-anchor" href="#responderlisttopelementstyle-⇒-listtemplate"><i class="fa fa-link" aria-hidden="true"></i></a>responder.list([topElementStyle]) ⇒ <code>ListTemplate</code></h3>
<p>Creates a generic template</p>
<p><strong>Kind</strong>: instance method of <a href="#Responder"><code>Responder</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>[topElementStyle]</td>
<td><code>'large'</code> \</td>
<td><code>'compact'</code></td>
<td><code>'large'</code></td>
</tr>
</tbody>
</table>
<p><strong>Example</strong> </p>
<pre><code class="lang-javascript">res.list(<span class="hljs-string">'compact'</span>)
.postBackButton(<span class="hljs-string">'Main button'</span>, <span class="hljs-string">'action'</span>, { actionData: <span class="hljs-number">1</span> })
.addElement(<span class="hljs-string">'title'</span>, <span class="hljs-string">'subtitle'</span>)
.setElementImage(<span class="hljs-string">'/local.png'</span>)
.setElementUrl(<span class="hljs-string">'https://www.seznam.cz'</span>)
.postBackButton(<span class="hljs-string">'Button title'</span>, <span class="hljs-string">'action'</span>, { actionData: <span class="hljs-number">1</span> })
.addElement(<span class="hljs-string">'another'</span>, <span class="hljs-string">'subtitle'</span>)
.setElementImage(<span class="hljs-string">'https://goo.gl/image.png'</span>)
.setElementAction(<span class="hljs-string">'action'</span>, { actionData: <span class="hljs-number">1</span> })
.urlButton(<span class="hljs-string">'Local link with extension'</span>, <span class="hljs-string">'/local/path'</span>, <span class="hljs-literal">true</span>, <span class="hljs-string">'compact'</span>)
.send();
</code></pre>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="Request.html" class="navigation navigation-prev " aria-label="Previous page: Request">
<i class="fa fa-angle-left"></i>
</a>
<a href="Router.html" class="navigation navigation-next " aria-label="Next page: Router">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Responder","level":"2.2","depth":1,"next":{"title":"Router","level":"2.3","depth":1,"path":"api/Router.md","ref":"api/Router.md","articles":[]},"previous":{"title":"Request","level":"2.1","depth":1,"path":"api/Request.md","ref":"api/Request.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-default","collapsible-menu","anchors"],"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"},"pluginsConfig":{"collapsible-menu":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-api":{"theme":"dark","languages":[{"lang":"js","name":"JavaScript","default":true}]},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"showLevel":false,"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}},"anchors":{}},"theme":"default","author":"David Menger","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"twitter":"https://twitter.com/davidmenger"},"title":"Botnaut","gitbook":"*","description":"Facebook Messenger framework for Node.js"},"file":{"path":"api/Responder.md","mtime":"2018-05-23T15:31:55.027Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-05-23T15:31:59.833Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.js"></script>
<script src="../gitbook/gitbook-plugin-collapsible-menu/plugin.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>