positus-api-csharp-client 1.0.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package positus-api-csharp-client --version 1.0.7                
NuGet\Install-Package positus-api-csharp-client -Version 1.0.7                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="positus-api-csharp-client" Version="1.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add positus-api-csharp-client --version 1.0.7                
#r "nuget: positus-api-csharp-client, 1.0.7"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install positus-api-csharp-client as a Cake Addin
#addin nuget:?package=positus-api-csharp-client&version=1.0.7

// Install positus-api-csharp-client as a Cake Tool
#tool nuget:?package=positus-api-csharp-client&version=1.0.7                

Compatibility

.Net Core
.Net Framework
Mono
Xamarin.IOS
Xamarion.Android
Universal Windows Plataform
Windows
Windows Phone
Windows Phone Silverlight
Language C#, C++, F#,  Visual Basic and other language.

Instantiating

using positus_api_csharp_client;
using positus_api_csharp_client.Models.Requests;
using positus_api_csharp_client.Models.Responses;

Authentication

If you don't have an authentication token, click here to generate one.

Production
Client client = new Client(@"your-api-token", false);

Sandbox
Client client = new Client(@"your-api-token", true);

Sending Messages

The first step to be able to send messages is to specify the ID number of origin:

client.numberId = "chave";

Then send the message and wait for a response.

If you want to send a message using data on your own, you can use:

@Message message = client.sendData(Object);

To check all the data that can be sent in each type of message, check the WhatsApp Business documentation.

If you prefer, we provide ready methods for each type of message.

Text

@Message message = client.sendMessage(new Text()
    {
        text = new TextDetail() { body = "Olá Mundo" }
                          ,
        to = "+999999999"
                          ,
        type = "text"
    });

Location

    @Message message = client.sendLocation(new Location()
    {
        location = new LocationDetail()
        {
            name = "Robbu brazil",
            address = "Av. Angélica, 2530 - Bela Vista, São Paulo - SP, 01228-200",
            longitude = -46.662787,
            latitude = -23.553610
        },
        to = "+999999999",
        type = "location"
    });

Image

    @Message message = client.sendImage(new Image()
    {
        image = new ImageDetail()
        {
            link = "https://picsum.photos/200"
        },
         to = "+999999999",
        type = "image"
    });

Document

    @Message message = client.sendDocument(new Document()
    {
        document = new DocumentDetail()
        {
            filename = "original.zip",
            caption = "Original",
            link = "https://loremipsum.de/downloads/original.zip"

        },
        to = "+999999999",
        type = "image"
    });

Video

    @Message message = client.sendVideo(new Video()
    {
        video = new VideoDetail()
        {
            caption = "Original",
            link = "http://techslides.com/demos/sample-videos/small.mp4"
        },
        to = "+999999999",
        type = "video"
    });

Audio

    @Message message = client.sendAudio(new Audio()
    {
        audio = new AudioDetail()
        {
            link = "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"
        },
        to = "+999999999",
        type = "video"
    });

Contact

    List<ContactDetail> contactDetails = new List<ContactDetail>();

    List<Phone> phones = new List<Phone>();
    phones.Add(new Phone() { phone = "+55 11 2626-4234", type= "CELL", wa_id = "551126264234" });

    contactDetails.Add(new ContactDetail()
    {
        name = new Name() { first_name = "Positus Provider", formatted_name = "Positus Provider" },
        phones = phones
    });


    @Message message = client.sendContacts(new Contact()
    {
        contacts = contactDetails,
        to = "+999999999",
        type = "contacts"
    });

HSM

            @Message message = client.sendHsm(new Hsm()
            {

                hsm = new HsmDetail()
                {
                    element_name = "xxxxxxx"
                ,
                    @namespace = "xxxxxxx"
                ,
                    language = new Language()
                    {
                        code = "pt_BR"
                ,
                        policy = "deterministic"
                    }
                ,
                    localizable_params = list
                }
                      ,
                to = "+999999999999"
                      ,
                type = "hsm"
            });

Template


   List<Component> lstComponent = new List<Component>();
            Component itemComponent ;
            Parameter parameter ;

            List<Parameter> lstParameterHeader= new List<Parameter>();

            parameter = new Parameter();
            parameter.type = "image";
            parameter.image = new ImageLink() { link = "https://picsum.photos/200" };
            lstParameterHeader.Add(parameter);



            List<Parameter> lstParameterBody = new List<Parameter>();
            parameter = new Parameter();
            parameter.type = "text";
            parameter.text = "Helber";
            lstParameterBody .Add(parameter);

            parameter.type = "text";
            parameter.text = "Empresa X";
            lstParameterBody .Add(parameter);

            itemComponent = new Component();
            itemComponent.type = "body";
            itemComponent.parameters = lstParameterBody ;
            lstComponent .Add(itemComponent);


            itemComponent = new Component();
            itemComponent.type = "header";
            itemComponent.parameters = lstParameterHeader;
            lstComponent .Add(itemComponent);



            @Message message = client.sendTemplate(new Template()
            {

                template = new TemplateDetails()
                {
                    name = "your_template_name"
                ,
                    @namespace = "your_namespace"
                ,
                    language = new Language()
                    {
                        code = "pt_BR"
                ,
                        policy = "deterministic"
                    }
                ,
                    components = lstComponent 
                }
                      ,
                to = "+55999999999"
                      ,
                type = "template"
            });

Webhook

    [HttpPost]
    public ActionResult post([FromBody] Webhook obj)
    {
        foreach (var item in obj.messages)
        {
            var mensagem = item.text.body;
        }
        return Ok();
    }

Documentation

In case you have difficulties, we provide an example video of integration.

Documentation PT

Documentation ES

Documentation EN

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 2,992 9/27/2022
1.0.7 542 6/21/2022
1.0.5 2,432 7/22/2020
1.0.4 416 7/20/2020
1.0.3 438 7/17/2020