contacts.addContact
Add an existing telegram user as contact. Use contacts.importContacts to add contacts by phone number, without knowing their Telegram ID.
func (c *Client) ContactsAddContact(ctx context.Context, request *ContactsAddContactRequest) (UpdatesClass, error)
Calling this method
client.Run(ctx, func(ctx context.Context) error {
api := client.API()
res, err := api.ContactsAddContact(ctx, &tg.ContactsAddContactRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // UpdatesClass
return nil
})
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
AddPhonePrivacyException | bool | — | Allow the other user to see our phone number? |
ID | InputUserClass | yes | Telegram ID of the other user |
FirstName | string | yes | First name |
LastName | string | yes | Last name |
Phone | string | yes | User's phone number, may be omitted to simply add the user to the contact list, without a phone number. |
Note | TextWithEntities | — | A private note for this contact, only visible to us; see here » for more info on contact notes. |
Returns
Possible errors
| Code | Type | Description |
|---|---|---|
| 400 | CHANNEL_PRIVATE | You haven't joined this channel/supergroup. |
| 400 | CONTACT_ID_INVALID | The provided contact ID is invalid. |
| 400 | CONTACT_NAME_EMPTY | Contact name empty. |
| 400 | MSG_ID_INVALID | Invalid message ID provided. |
References
- Official documentation
- Generated Go reference
- TL definition:
contacts.addContact#d9ba2e54