<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Erika Agostinelli on Medium]]></title>
        <description><![CDATA[Stories by Erika Agostinelli on Medium]]></description>
        <link>https://medium.com/@erika.agostinelli13?source=rss-c40b81d1c699------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*z0F1eHW5fHIfEIea-aQ2KA.png</url>
            <title>Stories by Erika Agostinelli on Medium</title>
            <link>https://medium.com/@erika.agostinelli13?source=rss-c40b81d1c699------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 15:31:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erika.agostinelli13/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Chatting with Watson to Hook any Tweets: Webhook Tutorial]]></title>
            <link>https://medium.com/ibm-watson/chatting-with-watson-to-hook-any-tweets-webhook-tutorial-bf0fac67d604?source=rss-c40b81d1c699------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf0fac67d604</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[webhooks]]></category>
            <category><![CDATA[watson-assistant]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Erika Agostinelli]]></dc:creator>
            <pubDate>Thu, 29 Aug 2019 15:13:59 GMT</pubDate>
            <atom:updated>2019-10-26T20:21:25.163Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial you will learn how to make external API callouts from Watson Assistant. We will use Webhooks, Cloud Function, and Twitter API, to retrieve the last tweets of any account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9M9J19JDHmCYr0PSJlPfg.png" /><figcaption>Photo by <a href="https://www.pexels.com/@tdcat">Torsten Dettlaff</a> from Pexels</figcaption></figure><h4>What you will learn:</h4><ol><li>How to leverage your virtual assistant to retrieve information from <strong>Twitter</strong></li><li>How to use <strong>Webhooks</strong> in Watson Assistant</li><li>How to use and write <strong>Cloud Functions</strong> (in Python)</li></ol><h4>Prerequisite:</h4><ol><li><a href="https://cloud.ibm.com/registration">IBM Cloud account</a></li><li><a href="https://cloud.ibm.com/docs/services/assistant?topic=assistant-getting-started"><strong>Watson Assistant</strong> instance</a></li><li><a href="https://developer.twitter.com/en/apply-for-access.html"><strong>Twitter Developer Account</strong></a> : Consumer key (API key), Consumer Secret (API Secret), Access Token, and Access Token Secret.</li></ol><h3>Introduction</h3><p>How can you personalise your assistant and improve it by adding new functionality? How easy it is to make external API calls from Watson Assistant? With Webhooks is really easy.</p><p>In this tutorial, we will use the new webhooks feature from Watson Assistant, and cloud functions (FaaS) to achieve this goal and you will be able to <em>ask</em> your virtual assistant to retrieve the last tweets from any Twitter account.</p><p><a href="https://github.com/IBM-DSE/Watson-Assistant-Webhooks-Tutorial">Code for this tutorial is available on Github</a></p><h3>Cloud Function</h3><p>Let’s focus on the Cloud Function, first. Go to your IBM Cloud account click on “create resource” (top right) and search for “functions” and select the result. Then, click on the “Actions” tab in the left banner, and create e new action (Create → Create Action). Note: On the top right, be sure to pick a <strong>CF-based namespace</strong> and not a new IAM-based namespace, since currently (last update oct-2019) you can make a call to an action that is managed by Cloud Foundry, <strong>but not</strong> to an action that uses token-based Identity and Access Management (IAM) authentication. Moreover, you should select the same region where your Watson Assistant instance sits.</p><blockquote>Be sure to work on a <strong>CF-Based namespace</strong> and the Cloud Function and Watson Assistant instance need to be in the<strong> same region</strong>.</blockquote><p>Pick a name for your function (e.g. “last_tweets”) and runtime (in this case I have picked Python 3) then click on “Create”. You can find the code to copy &amp; paste here but make sure to add your <strong>Twitter Dev Account credentials</strong> in the appropriate fields (client_key , client_secret) and hit Save:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f143175adc62f3d2ec3f0b6632f3c9c/href">https://medium.com/media/7f143175adc62f3d2ec3f0b6632f3c9c/href</a></iframe><p>Now, click on “Parameters” (left banner) and add a variable called “account”. This parameter will receive information from your Assistant when the user explicitly asks for tweets of a specific account. Here, I’m leaving a default value (@taylorswift13) so that I can test my function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqp8-NFxvkRB8RBtEDHIkw.png" /><figcaption>add a default value to be able to test your function by using “Invoke”</figcaption></figure><p>Let’s check if everything is working fine: go back to the “Code” tab (on the left) and <strong>invoke</strong> your function. You should be able to get the last tweets from Miss Swift (Default Value for now).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5rolSzQBh0lGJjVp7Am-g.png" /><figcaption>Successfully tested the Action that returns correct values (on the right)</figcaption></figure><p>Everything working? If yes, next step:</p><p>Since you have completed your cloud function, click on “Endpoints” and take notes of:</p><ol><li>the <strong>URL</strong> of your action</li><li>then click on “<strong>API-KEY</strong>” and the first part of the string (before the colon “:”) is your <strong>username</strong> and the second part is your <strong>password</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCSVgiHTyHEXgl7CKKbZuA.png" /><figcaption>API Key — get username and password to access the</figcaption></figure><h3>Webhooks and Watson Assistant</h3><p>Now, you are ready to move to Watson Assistant (WA). <a href="https://github.com/IBM-DSE/Watson-Assistant-Webhooks-Tutorial/blob/master/skill-WA_Webhooks_twitter.json">Download the skill</a> in json format and upload it into your Watson Assistant instance (<a href="https://cloud.ibm.com/docs/services/assistant?topic=assistant-skill-dialog-add#skill-dialog-add-to-assistant">how to upload a skill</a>). Again, be sure that your instance is in the <strong>same region</strong> as the cloud function.</p><blockquote>A <strong>Webhook</strong> sends a POST request callout to an external application that performs a <strong>programmatic function</strong>. When used in a dialog skill, a webhook is <strong>triggered</strong> when the assistant processes a node that has a webhook enabled.</blockquote><p>How to use a webhook:</p><ol><li><strong>Webhook setup</strong>: specify the request URL for an external API you want to invoke</li><li><strong>Enable a dialog node</strong>: a webhook enabled node will trigger the action and sends specific parameters to the API.</li></ol><h4>Webhook Setup</h4><p>Click on “Option” tab -&gt; “Webhooks”:</p><ul><li>In Request URL, specify the URL of your action and it’s <strong>important</strong> to append <em>?blocking=true</em> parameter to the action URL to force a synchronous call to be made. <em>You cannot make an asynchronous call to a cloud functions action with a webhook. When you send an asynchronous request, only an activation ID is returned.</em></li></ul><pre>https://us-south.functions.cloud.ibm.com/api/v1/namespaces/&lt;your-email&gt;/actions/last_tweets<strong>?blocking=true</strong></pre><ul><li>In Headers: Click <strong>Add authorization</strong>, add your credentials to the <strong>User name</strong> and <strong>Password</strong> fields, and then click <strong>Save</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IT62biXdUVByv_0H6TOHhg.png" /><figcaption>How to set up a Webhook in Watson Assistant — super easy</figcaption></figure><h4>Enable a dialog node</h4><p>Go to the “Dialog” tab: click on “Twitter — Last tweets” node and see its children nodes. If the user specifies a twitter account then the first child node will be triggered (“Account Specified”) and in that node, Webhook functionality has been indeed activated. How to do it? It’s really simple: you need to click on the “customise” button, scroll down to the Webhooks section, and switch the toggle to On, and then click Apply (<a href="https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-webhooks#dialog-webhooks-dialog-node-callout">how to add a webhook in a node</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*fI4aOttibVEfBtc2x3AmDw.png" /><figcaption>How to activate the webhooks option in the node</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*aSJ_eGVlZ08E4M26f2prVw.png" /><figcaption>Inside the “Account Specified” node</figcaption></figure><p>In “Account Specified” node (where Webhook option is active) you can see several new fields.</p><ol><li><strong>Parameters</strong>: data that you want to pass to the external application as key and value pairs</li><li><strong>Return variable</strong>: response made by the callout is saved to the return variable</li><li><strong>Response condition</strong> <strong>if $webhook_result_1 is recognised</strong>: response to show when the webhook callout is successful and a return variable is sent back. Here, I would suggest playing with $webhook_result_1 variable to understand the content of the response and to decide what and in which format you want to show the results to the end-user. (i.e. last tweet:&lt;br&gt;-&lt;? $webhook_result_1.response.result.result[0] ?&gt;)</li><li><strong>Response condition if <em>anything_else</em> is recognised</strong>: response to show when the callout fails</li></ol><h3>Try it out!</h3><p>Once you have created your cloud function, and correctly set up the webhook in the <em>Options</em> tab, the Watson Assistant <a href="https://github.com/IBM-DSE/Watson-Assistant-Webhooks-Tutorial/blob/master/skill-WA_Webhooks_twitter.json">Skill in the git repo</a> already contains all the intent, entity and dialogue structure that allows you to play directly in the <em>Try it out</em> panel (top right). Try typing: “tweets from @blackmirror” (note the @ symbol) you should see displayed text and some images (if tweeted by the account).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bvb9uxxeND7IIZMt-0Vag.png" /><figcaption>“Try it out” — type a phrase specifying any twitter account (use the “@” symbol) and test your function!</figcaption></figure><h3>Conclusion</h3><p>Now you should be able to create your own cloud function, use webhooks in Watson Assistant and ask your virtual agent to show the latest tweets of your favourite artist, event or TV show etc!</p><p><a href="https://github.com/IBM-DSE/Watson-Assistant-Webhooks-Tutorial">Code for this tutorial is available on Github</a></p><h3>References</h3><h4>Webhooks</h4><ul><li>Documentation: <a href="https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-webhooks">https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-webhooks</a></li><li>Demo: <a href="https://www.youtube.com/watch?v=j8TBqD2rx2o">https://www.youtube.com/watch?v=j8TBqD2rx2o</a></li><li>Blog — It’s Now Way Easier to Personalize Your Assistant!: <a href="https://medium.com/ibm-watson/its-now-way-easier-to-personalize-your-assistant-9a23a9cadd4">https://medium.com/ibm-watson/its-now-way-easier-to-personalize-your-assistant-9a23a9cadd4</a></li></ul><h4>Cloud Functions</h4><ul><li>IBM Cloud Function &amp; Webhooks: <a href="https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-webhooks#dialog-webhooks-cf">https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-webhooks#dialog-webhooks-cf</a></li><li>Blog — Weather as Function of Clouds: <a href="https://www.ibm.com/developerworks/community/blogs/hickmat/entry/Weather_as_a_Function_of_Clouds?lang=en">https://www.ibm.com/developerworks/community/blogs/hickmat/entry/Weather_as_a_Function_of_Clouds?lang=en</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf0fac67d604" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ibm-watson/chatting-with-watson-to-hook-any-tweets-webhook-tutorial-bf0fac67d604">Chatting with Watson to Hook any Tweets: Webhook Tutorial</a> was originally published in <a href="https://medium.com/ibm-watson">IBM watsonx Assistant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>