How to fetch third-party data within Twilio interactive voice system? - node.js

Twilio provides some documentation that explains how to create interactive voice experiences, for example, how to prompt for key-press from the caller and offer different menus or perform actions based on it.
However I cannot find any information on how I might be able to fetch data from a third-party service based on user input.
For example, suppose a user enters his zipcode into the keypad, I would like to fetch the weather from a weather API and return it to the user in speech form.
Is this possible? And if yes, how?

Very possible. You can take a look at the documentation below but the key widget is the HTTP Request Widget.
Studio Widget Library
https://www.twilio.com/docs/studio/widget-library#http-request
The relevant line is:
"JSON: If your HTTP Widget returns valid JSON, you should be able to access it via widgets.MY_WIDGET_NAME.parsed" variable.
Studio User Guide - Working with Variables
https://www.twilio.com/docs/studio/user-guide#working-with-variables

Related

Stored Value Sets that are accessed throughout a Bixby Voice Experience

I am completely new to Bixby development so I apologize in advance if this is a newby question that doesn't make sense. I'm trying to understand the best way to store value sets returned from external APIs to use throughout Bixby Voice experiences. An example might be an API that gets all the menu items at a restaurant or an API that gets all the clothing catalog items from a store. When users interact with the data to search or transact I don't want to have to go back to the external API to get the value set again. For example: Find Vegan Menu options followed by Okay how about pescatarian options. Or: Find dress pants followed by okay how about dress shirts. I'd like to come back to a menu object in the first case or a catalog object in the second without having to re-load the value sets from the API.
In the sample code I've seen all of the value sets appear to be read in each time an action/endpoint/java call is made
There is no local storage in the current version of Bixby.
The easiest solution is to request through API calls. However, http.getUrl() itself is cached by default, and Bixby runs on Samsung server, so no actual API calls in practice when requesting same url in short sessions.
You can read more about http API options and how to disable cache feature by reading more here

How To Change "Action and parameters", later on in your Google Action?

So I was using Gmail Google Action on my Assistant device and One thing that I found particularly intriguing was that when a user has given its message and email, after that assistant gives options for change or adding the message. That means on selecting those options, assistant will change the value of message entity or edit it as per user command, without re-enabling the whole intent.
My question is how can I implement this functionality in my Google Action. Is there any particular function made by Google that I can use or do I have to create one from scratch ?
Gmail's integration is a bit different than the way a third-party developer would do it, but you can save user input from the current session and modify it later on in your conversation. In your Action, this wouldn't be just one intent, but a few that would handle the work of modifying some session data and finally using that data to complete the user's original action.

Connecting Alexa to my own NodeJS back-end

I'm back again with a question about NLP. I made my own back-end, which on one side can connect to websites, the Google Assistant and Facebook Messenger, and on the other end to Dialogflow. On the side, is logs interactions and does some other database stuff.
Now, I'm trying to connect this back-end to Alexa. I made a project which calls my endpoint. This project has one intent, which has a paramater which should get the raw user input, send it to my back-end, process it, parse and send the response to get back. I feel like there is not a real way to collect and send the raw user input, so I can process it myself (on Dialogflow) instead of using the Amazon way of mapping intents and such.
I know Dialogflow can export to Alexa, but this is not an option for me. I really hope one of you can point me in the right direction.
I just need a way to collect the raw user input, and respond in an Alexa accepted response format.
For Actions on Google for example, I'm using a Custom Project Action Package.
Thanks a lot in advace!
To accept or get any user input, you can use sys.any in google assistant and AMAZON.SearchQuery in AMAZON ALEXA.
In Alexa, You have to add the carrier phrase to use AMAZON.SearchQuery. You can't combine any other slot with AMAZON.SearchQuery.
So there are also some limitations. I hope this answer will help you.

Server-side query using events or/and context?

I’m coding a bot using PHP-BotMan for complexity reasons and using Dialogflow query api to extract and manipulate the informations from the response. I saw examples and hints from people here and on dialogflow forum suggesting using context or events, some of them mixing both. What is the better way to handle this?
The flow of the application is:
user messages bot
bot queries (text or/and #event?) dialogflow
internally process a reply or return dialogflow slotfilling* request
text response bot reply user with last reply or asking to fill slot
Also, how can I be sure that a slotfilling process is finished with “actionIncomplete” only having two values, NULL or TRUE? The dialogflow query response doesn’t show wich slotfilling parameters are required or not…
Thanks for the help!!
slotfilling is when dialogflow sends a text response requesting required parameters to finish an intent, adding those replied values to the context
I was trying something similar to your scenario, here are few points i found helpful:
When Slotfitting with webhook, i can't use the "Required" params field since i have to control the input parameters via webhook (query database to provide options). Which means actionIncomplete field is not useful anymore.
I personally prefer to use context as it can add/remove params which gives you more control.
Hence the dialog was designed to use webhook to check all required params before move on to next conversation flow. and pop quick replies menu to ease and restrict possible input from users.
HTH.

Enable user to send text to specific Gmail contacts

In our website, we need to achieve a seemingly simple task: Enable the user to send a specific text to all or some of his/her Gmail contacts (including contact selection).
We don't actually need the contact data itself. We prefer some kind of "Gmail Plugin" (if there is one) that asks the user to login and does all the work. Alas, we couldn't find any.
We did find several different Google APIs related to this task. Some of them seem to give us contacts data. Others seem to handle sending email:
There is "Contacts API" under
https://developers.google.com/google-apps/contacts/v3/...
There is "Contacts Service" under
https://developers.google.com/apps-script/reference/contacts/...
There is "Gmail Service" under
https://developers.google.com/apps-script/reference/gmail/...
There is "Gmail Platform Integration" under
https://developers.google.com/gmail/...
Each of the above looks different and there seems to be much overlapping between them.
So what is the recommended method to achieve our original task? Is there a plugin that does it all? If not - should we use separate APIs for getting the contacts data and sending the emails, or are there Google APIs that combine both sub-tasks? In case those are separate tasks - is it possible to email via Gmail, or are there other recommended services for the email sending part?
To directly answer your question: you must use the first API you pointed, Contacts API under https://developers.google.com/google-apps/contacts/v3/.
Basically, you want to use the Google Contacts API with OAuth2 authentication in your website: user will be prompted by Google to allow your website to read user contacts.
First, read a bit about OAuth2 authentication flows here: http://alexbilbie.com/2013/02/a-guide-to-oauth-2-grants/
Second step: register your app on Google Console and get your key/pass for the Contacts API (you'll need contacts.readonly permission): https://console.developers.google.com
Then, as you'll use the OAuth2 for Web Servers, check this Google documentation: https://developers.google.com/accounts/docs/OAuth2WebServer
Alternatively, you can use third part libraries to easily import contacts to your website. There are free libraries, like PHP OpenInviter.org, Ruby OmniAuth gem, and paid alternatives, like CloudSponge.com (multi-language).
Disclaimer: I work for CloudSponge.com.
You could achieve this as you say with Google APIs and a Chrome Extension for example.
The user can add a Chrome Extension from the Chrome Webstore. The Extension will provide the user with a user interface to allow them to compose their message and send to the selected contacts.
The users contacts can be retrieved with the Google Contacts API.
The message can be sent to the selected contacts with the Gmail API.
There is a lot of documentation and examples for all of the above which together will give you what you want.
Depending on how much use this is going to get, you could use a contextual gadget which is browser agnostic - but visible in all emails in Gmail.
This is wrong the idea is to post the text to buffer a and submit pointer to array on buffet a and copy it to class b pointer a 0 than release the array and buffer so new allocation can be done

Resources