Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Latest commit

 

History

History
74 lines (60 loc) · 3.85 KB

File metadata and controls

74 lines (60 loc) · 3.85 KB

Creating the group.

Implementation note
If the host is an iPhone, then the presence of all in the contact list is mandatory.
The group will be added to the queue for sending and created sooner or later, even if the phone is disconnected from the Internet or authorization is not passed.
Update from October 2, 2018: In the response, the chatId parameter will be filled in if it was possible to create a group on your phone within 20 seconds.
This method is available in both synchronous and asynchronous implementations.

Request

Parameter Description The data type of the parameter Required parameter
Avatar Group avatar 640x640px.
Base64-encoded file with mime data
String
Phones Collection of phone numbers of the members of the created group PhonesCollection
  • Only Phones is specified
  • Only ChatIds is specified
ChatIds Collection of unique IDs of the members of the created group ChatIdsCollection
  • Only ChatIds is specified
  • Only Phones is specified
Preview Group preview 96x96px.
Base64-encoded file with mime data
String
GroupName Name of the group being created String
MessageText The text of the message that will be sent to the group when it is created.
If you do not set a parameter, the message will not be sent.
String

Response

Parameter Description The data type of the parameter
Created Flag for creating the group Boolean
Message Group creation status String
ChatId Unique ID of the created group String
GroupInviteLink Link invitation to the group String

Example

using System;

using ChatApi.Core.Connect;
using ChatApi.Core.Connect.Interfaces;
using ChatApi.Core.Response.Interfaces;

using ChatApi.WA.Dialogs;
using ChatApi.WA.Dialogs.Helpers.Collections;
using ChatApi.WA.Dialogs.Operations.Interfaces;

using ChatApi.WA.Dialogs.Requests;
using ChatApi.WA.Dialogs.Requests.Interfaces;
using ChatApi.WA.Dialogs.Responses.Interfaces;

using ChatApiClient.Properties;
namespace ChatApiClient
{
    internal class Program
    {
        internal static IWhatsAppConnect Connect { get; set; }

        internal static void Main()
        {
            // put your chat-api's data
            Connect = new WhatsAppConnect(WhatsApp_Server, WhatsApp_Instance, WhatsApp_Token); 
            IDialogOperations operation = new DialogOperations(Connect);
            IGroupOperations groupOperations = operation.GroupOperations.Value;
       
            ICreateGroupRequest request = new CreateGroupRequest 
            {
                Phones = new PhonesCollection { "7(999) 111-11-11" }, // or ChatIds = new ChatIdsCollection{ "79991111111@c.us" },
                GroupName = "TestBotGroup",
                MessageText = "Test group was created",
            };
            
            IChatApiResponse<ICreateGroupResponse?> chatApiResponse = groupOperations.CreateGroup(request);
            if(!chatApiResponse.IsSuccess) throw chatApiResponse.Exception!;
            
            var response = chatApiResponse.GetResult();
            Console.WriteLine(response?.PrintMembers());
        }
    }
}