Persist to google assistant data to a Database ( The data fetched from google assistant dialog )? - actions-on-google

I am able to get data using google actions but need your help in store this data into the database so that the user does not have to provide information every time he interacts with my action . Any help on this please
I am developing a stock app , collects names and quantity of various company names the user has invested in. , post that user should be able to ask various questions about his portfolio on a day to day basis ?

The easiest way to persist user data is to use the built-in user storage feature. This will allow you to save data for a user across conversations.
Here's an example of how it works:
function simpleResponse(conv) {
conv.user.storage.count = 1;
conv.ask(new SimpleResponse({
speech: 'Howdy! I can tell you fun facts about ' +
'almost any number, like 42. What do you have in mind?',
text: 'Howdy! I can tell you fun facts about almost any ' +
'number. What do you have in mind?',
}));
}

Related

React Native game, MongoDB or Firestore

I am working on a multiplayer react native game for android, it's just a text game.
For now, I've been working only on the client side but I'm slowly getting to the point where I need to choose a way to manage data. Since I'm always trying to learn something new - first time using RN too -, I came across Firestore and I'm curious if it's a viable choice from my project.
For example, in this game you can buy/open companies. If I were to handle this action in nodejs + MongoDB I'd send a JWT token to server/api/newcompany.
Assuming I'd have 2 MongoDB models, Users with all the user info and Company a list of all Companies in game. First I'd check if the User had enough money to open the company and then return some message based on that, my code would be something like this:
// routes.js
...
router.post('/api/newcompany',AuthCheck, Company.new)
// controllers/company.js
...
new: async function (req, res, next) {
if (!req.body.companyType || !validCompanyType) {
return res.status(200).send('invalid/missing message and other failed checks')
}
//assuming token data would be passed from auth middleware and would have company prices somewhere
const user = await Users.find({id:token.userId})
if (user.money < companyPrice) {
res.status(200).send('no money')
} else {
const newCompany = new Company()
newCompany.name = req.body.name
...
new.Companny.save(function(){
res.status(200).send('all good')
})
}
}
Looking at Firestore I'd have the same 2 documents as above. Users with a list of sub-documents(the users) identified by their IDs and a document Companies.
Would I be able to do the same users checks as above?
How would I handle that? Would I use the Firestore Rules to check the user has enough money or would I use my server with admin SDK as an intermediary to handle more complex ops and use the direct Firestore connection just for retrieving data?
Thanks for your time.

How to make transactions on multiple data tables in Firebase?

I've an application, which uses Firebase. I have a new post adding. And when I make it, I do a number of operations in database, like:
Add new post info to Posts node
Add Id of the new post to Users node
Upload media to storage
etc.
So, for example, user can close application on step 2. How can I reset data on start of adding new post?
If I've understood correctly, Firebase transactions work on only one data table.
Main question is: how to make transactions on multiple data tables and storage in Firebase?
I believe you're looking for something like this: https://firebase.google.com/docs/database/web/read-and-write#update_specific_fields. It allows you to run multiple updates all at once to wherever you need. Here is a snapshot of the code:
var updates = {};
updates['/posts/' + newPostKey] = ...;
updates['/user-posts/' + uid + '/' + newPostKey] = ...;
return firebase.database().ref().update(updates);

Access: the way the form is opened populates the combo box differently

Not sure if this can be done:
Basically I have created a database which logs interventions for a client (i.e phone calls, appointments, documents etc etc) the current project workers log these interventions as they happen from their live caseload. appointments have their own form, phone calls have their own form etc.
Now I have been asked to do the same for admin so they can log historical data for the last year or so, the thing is the selection data of the combo box is different (ie. old staff, services we do not work with anymore)
Is it possible to have a form populate differently depending on how you open it, ie the admin way will populate all the historic selections, and the project worker (live way) will populate all today's relevant information? I don't want to have to duplicate loads of forms that basically do the same thing.
Easy,
just change the source data for the combo box depending on who opens the form
use a variable or a checkbox or a UserID or something to tell who the user is then:
if varUser = 'boss' then
combobox.datasource = 'Select * from services where historical = 1'
else
combobox.datasource = 'Select * from services where historical = 0'
end

how to create auto atttendance system using filemaker

Hi i am new to filemaker, i am interested to learn and create an attendance system using filemaker. the way i like to do it is using the solution provided in filemaker ( Time Cards ). i would like my code to capture the timestamp of the user when ever the user enter his/her id and filemaker will automatically store the timestamp of that particular event. also the solution should be able to detect if it is already capture any previous time already entered by the same user. Sorry for my explaination. i hope its clear and understandable by you guys. Thanks in advance.
If the users are logging into the system (username and password), you can accomplish this by running a script on open (login).
That would work like:
go to tracking table (table made of timestamp and accountName field)
set error capture on
perform find - accountName = get(accountName)
if get(lastError) = 401 [this shows there are no records from this user], create new record, set field timestamp = get(currentTimestamp), set field accountName = get(accountName)
else [you can exit application, show dialog, or skip adding a new record if they entered previous data]
endif, then script whatever else you need to do onOpen.
If your users are entering in a temp field to log in against a user table, it's a similar step, you just need to grab $accountName as a variable to use in the find.

Satchmo: Specify delivery date/shipping date for an order

I working on e-commerce website using Satchmo. However, there are few customization required for my store.
While ordering a product I should be able to specify a delivery date (shipping date).
There can be only 20 (max_num_delievries) deliveries possible per day for a product. If number of deliveries for a particular date for a particular product exceeds 'max_num_delievries', user should not be able to select that date while ordering the product.
Can someone please help in this and guide me how to achieve this using Satchmo?
Thanks in advance..
I would try something like this:
1) create a local app (eg. delivery_date) with a model like "DeliveryDate" or so. For example localsite/delivery_date/models.py:
class DeliveryDate(models.Model):
product = models.ForeignKey(Product)
date = models.DateField()
order = models.ManyToManyField(Order)
class Meta:
unique_together = ("product", "date")
2) the validation of the max 20 existing orders... mhh, good question, maybe the best would be, to do it on the form? Override the clean method and check if this delivery date is associated with 20 orders already... maybe something like localsite/delivery_date/forms.py
class DeliveryDateForm(forms.ModelForm):
class Meta:
model = DeliveryDate
def clean(self):
super(DeliveryDateForm, self).clean()
... check here the order_set count
... but maybe the form isn't the best place to do this.
You also probably want to hide and auto-set the initial values for product and order yourself, and the user only being supposed to select a date.
3) Regarding satchmo... I would use signals to react after a product has been added to the cart (there is a signal just for this case), and add a listener which redirects the user to a view where he can select the date for this product. Look at the example here with the signal "cart_add_view": http://www.facebook.com/note.php?note_id=101466134049
Maybe ajax would be a good option here. With a hidden container in your page... which shows up after adding a product to the cart (only if the product hasn't already a DeliveryDate associated to this order/product), and asking the user to select a date.
This whole stuff would be on the listener: check if the product needs a delivery date, and if yes, send an ajax response to pop-up the window, and put in the repsonse-context the form, with the initial product and order hidden fields.
And to save the delivery-date you will need another ajax-view.
Well it's merely an idea how I would try to do it ;-) It will probably need adjustments here and there, of course. But hopefully it helps you further.
Regards,
Andrea