Use this method to send a contact to a chat (user, group, or channel). The contact information includes the name, and phone number.
Field | Type | Required | Description |
method | String | Yes | "sendMessage" |
app_id | String | Yes | App Id to which the message belongs. |
chat_id | String | Yes | Unique identifier for the target Chat or User_id. |
to_user_id | String | Optional | Unique identifier of the target user. If the user replies or sends a message to the target user, it will be displayed within a Group or Channel. |
phone_number | String | Yes | The phone number of the contact (including country code). |
name | String | Yes | The full name of the contact. |
reference | Long | Yes | Unique local identifier for the message. |
reply_to_message_id | String | Optional | Unique identifier for the original parent message. Use it when the message is a reply. |
echo | Integer | Optional | If set to 1 , returns a copy of the message to the sender. Default is 0 . |
disable_web_page_preview | Boolean | Optional | Disables link previews for links in this message. |
disable_notification | Boolean | Optional | Sends the message silently; users will receive a notification with no sound. |
menu_ref | String | Optional | Menu reference for an existing predefined menu: The menu will be displayed as an inline menu associated with the message. |
inline_menu | Array of Menu | Optional | Inline menu object to hold menus. If both inline_menu and menu_ref are defined, the priority goes to inline_menu. |
chat_settings | Integer | Optional | Administrators can chat with the bot privately, unlike normal users. In settings, the Bot Manager section allows admins to send commands. Setting chat_settings=1 reroutes messages to the Bot Manager for administrative communication. |
Preconditions for API Functionality
The following tables outline the preconditions that must be met for the API to function correctly. Failure to meet these conditions may result in errors or unexpected behavior.
- Preconditions for API permissions
Before sending or replying to a message, ensure the following conditions are met:
Action | Required Permission | Description |
Sending a message | "Send Message" | The API must have the "Send Message" permission to send messages in a chat (user, group, or channel). |
Replying to a specific message | "Reply to Message" | The user must have the "Reply to Message" permission to respond to a specific message within a chat. |
- Preconditions for API Role in the Chat
Before sending messages, the API must meet the following status requirements based on the type of chat:
Chat Type | Required API Role | Description |
User Chat | User Pre-Joined | The user must have pre-joined (started) the API (bot) before receiving messages. |
Group Chat | Member | The API must be a member of the group to send messages. |
Channel | Admin | The API must be an admin in the channel to send messages. |
Response
â
The
messageAck
method is always returned on success.- If
echo = 1
, â An additional response is returned with themessage
method, containing a copy of the sent message object.
Example:
Requests
json{ "method": "sendContact", "chat_id": "90090684438172188", "reference": 111111147, "name": "Adam Harley", "phone_number": "16134567890", "app_id": "90090684293000559", "echo": 1 }
javaif (incomingMsg.getText().toLowerCase().equals("contact")) { ContactOutMessage contactMsg = new ContactOutMessage(); contactMsg.setChatId(incomingMsg.getChat().getId()); contactMsg.setReference(Utils.getUniqueId()); contactMsg.setName("Adam Harley"); contactMsg.setPhoneNumber("16134567890"); api.send(contactMsg); }
javascriptlet contactOutMsg = new ContactOutMessage(); contactOutMsg.chat_id = incomingMsg.chat.id; contactOutMsg.reference = Id; contactOutMsg.name = "Adam Harley"; contactOutMsg.phoneNumber = "16134567890"; api.sendContact( incomingMsg.chat.id, contactOutMsg.phoneNumber, contactOutMsg.name );
pythonnapi.send_contact("chatId","phoneNum","Name",Utils.get_unique_id())
Responses
json{ "method": "messageAck", "ack": { "reference": 111111147, "date": 1741983544156, "gmid": 25, "message_id": "d1_Y55weZ5M126268" } }
json{ "method": "message", "message": { "date": 1741983544156, "reference": 111111147, "gmid": "25", "chat": { "id": "90090684438172188", "title": "New Chat", "type": "Group" }, "contact": { "name": "Adam Harley", "phone_number": "16134567890" }, "message_id": "d1_Y55weZ5M126268", "style": 0, "from": { "name": "My First API", "id": "90091783822039252", "terminal": "API", "type": "Bot", "version": "('0w78')" }, "type": "contact" }, "app_id": 90090684293000559 }