#Save a contact

51 messages · Page 1 of 1 (latest)

limber bloom
#

Hi, is there a way to save a contact? or associate it with an app that saves contacts? (📜 The idea would be to use an example message, you put them to say "name and age" and with that message you save the contact)
Thanks for reading and if anyone knows of any tutorial or wants to explain it to me, I would greatly appreciate it, sorry for the inconvenience and my English!🤙

#

Save a contact

#

Save a contact

fringe oriole
#

not possible

red glacier
#

I did it with google contacts (Google people API)

#

I save them with their id in my case that are unique

limber bloom
# fringe oriole not possible

Hello, I could do it before... Before I got involved with programming, I paid for a service, from some people who I don't know how their configuration was going, but they associated their bot with peoplesync, a very old app but it worked... and if it could be replicated that would be great, because with a message auto saved to contacts

limber bloom
limber bloom
fringe oriole
#

google contacts API

#

but I think it good deprecated

fringe oriole
#

I didn't know it got renamed to google people

#

I was going to make a guide about it once

limber bloom
#

"Coding
After you get all the initialization ready, let's start coding!

so, install the googleapis package: yarn install googleapis or npm install googleapis

and import it in code:........."

#

for it to work you have to put something in the .env file, right? That's what I can't do :/

red glacier
#

This is people documentation page :
https://developers.google.com/people

You need to create a google cloud platform account :
https://cloud.google.com/

Get your subscription done for free, then you'll get a token in a json file that create a link between the api and your google contact account.

Make a folder where you put a file that is named token.json in it.

In your .env file, GOOGLE_TOKEN_PATH is the path to your folder with token.json file ($path/token.json)
In your .env file, GOOGLE_CREDENTIALS_PATH is the paths to the credentials.json file that is created by the code ($path/credentials.json)

Google Developers

View and manage contacts and domain profiles.

Google Cloud

Meet your business challenges head on with cloud computing services from Google, including data management, hybrid & multi-cloud, and AI & ML.

limber bloom
red glacier
#

Sorry, it is the opposite (token.json creates itself, credentials.json you put your credentials given by google)

#

it looks like this

limber bloom
#

Did I replace this or did I do something wrong? xd
"redirect_uris":["http://localhost"]
and I don't see the "access_type" and "prompt"

#

error :/ :

#

Error 400: redirect_uri_mismatch

fringe oriole
#

thanks

fringe oriole
#

if you have multiple clients then it is not going to be easy

brave lion
limber bloom
#

I already solved that, I had to create one with "web" and change the "web" to "installed", now I have another conflict, in my app.js I put: js {new Contact("hello", "+33642589456", "blablabla@gmail.com")}
Simulating what happened to me, but I took everything out and just left it with "" and it throws me this error:
GaxiosError: Must specify a non-metadata contact field on the person. I used the example code you passed from "contact.js" @red glacier I managed to connect but I can't add new contacts, please help!!

#

but if I put the code as you put it, that is: js {new Contact("hello", "+33642589456", "blablabla@gmail.com")} returns me: GOOGLE CONTACT => Contact created, status code: 200 (means that I save well the contact? how long does it take to update on my phone?)

limber bloom
#

And according to what I see, it adds "that contact" with the given name between example: "hello" with the number between "", example "+65498476345984" and with the given mail too, example "sdfwsf@gmail.com", like Can I make it take the number that sends that message and schedule it with a name X or with a message that I choose?

red glacier
#

I'm not sure I understand everything of what you're saying.

However if you have Contact created status code 200, you should see your new contact on your Google contact account, it doesn't take time to update, it's instantly. Try to console.log the res at the end (instead of res.status) to see what happens.

For the reste you do whatever you want, I did this like this because it was easier for me to have name:Id, emailaddress:email, phonenumber:phone but you don't have to do same.

You juste need a phonenumber and a name and the name you choose with your code what it is

limber bloom
fringe oriole
#

or await message.getContact()

limber bloom
limber bloom
fringe oriole
#

use it to refresh the access token

limber bloom
#

how do i get the refresh?

limber bloom
#

?

red glacier
#

For real i don't remember bro, i've done this 7-8 months ago and I remember that i took maybe one month to make something working.
Since this i have not touch this once and it still works.

But i remember that refresh token was not given by Google and maybe there was something with "bearer token". I think i've changed credentials that google gave me so it can be refreshed but i'm not sure so far ...

#

But yeah, this google api stuff is incomprehensible ^^ Their documentation isn't clear

limber bloom
red glacier
#

I'll check and if i got something i'll tell you. Have a nice day too !

#

Try to have the same json i have but replace black lines by your stuff

limber bloom
#

I have it as it is, and it worked fine for me, but this throws me:

0|bot | 'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
0|bot | 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate',
0|bot | connection: 'close',
0|bot | 'content encoding': 'gzip',
0|bot | 'content-type': 'application/json; charset=utf-8',
0|bot | date: 'Monday, November 14, 2022 19:42:02 GMT',
0|bot | expires: 'Monday, Jan 01, 1990 00:00:00 GMT',
0|bot | pragma: 'no cache',
0|bot | server: 'scaffolding on HTTPServer2',
0|bot | 'encoding transfer': 'chunked',
0|bot | vary: 'Source, Source X, Reference',
0|bot | 'x-content-type-options': 'nosniff',
0|bot | 'x-frame-options': 'SAME ORIGIN',
0|bot | 'x-xss-protection': '0'
0|bot | },
0|bot | status: 400,
0|bot | statusText: 'Bad request',
0|bot | request: { response URL: 'https://oauth2.googleapis.com/token' }
0|bot | },```