rohit-chouhan sponsor

WhatsApp API package for flutter, to send message and product information.

WhatsApp Business Configuration

You must have WhatsApp apps in facebook developer, to use this package, please follow this Guidelines.

WhatsApp whatsapp = WhatsApp();

Configure accessToken and fromNumberId.

whatsapp.setup(
	accessToken: "your_access_token_here",
	fromNumberId: 10000000000000
);

Generate the short link of the WhatsApp.

  • to - the phone number with country code but without the plus (+) sign.
  • message - the message to be sent.
  • compress - pass true to compress the link.
whatsapp.short(
	to: 910000000000,
	message: "Hey",
	compress: true
);
//return : https://wa.me/910000000000?text=Hy

💬 Send template

Send the template to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • templateName - the template name.
whatsapp.messagesTemplate(
	to: 910000000000,
	templateName: "hello_world"
);

💬 Send text message

Send the text message to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • message - the message to be sent.
  • previewUrl - is used to preview the URL in the chat window.
whatsapp.messagesTemplate(
	to: 910000000000,
	message: "Hey, Flutter, follow me on https://example.com",
	previewUrl: true
);

💬 Send media files

Send the media files to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • mediaType - the type of media such as image, document, audio, image, or video
  • mediaId - Use this edge to retrieve and delete media.
whatsapp.messagesMedia(
	to: 910000000000,
	mediaType: "image",
	mediaId: "f043afd0-f0ae-4b9c-ab3d-696fb4c8cd68"
);

💬 Send location details

Send the location to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • longitude - the longitude of the location.
  • latitude - the latitude of the location.
  • name - the name of the location.
  • address - the full address of the location.
whatsapp.messagesLocation(
	to: 910000000000,
	longitude: "26.4866491",
	latitude: "74.5288578",
	name: "Pushkar",
	address: "Rajasthan, India"
);

Send the location to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • mediaType - the type of media such as image, document, audio, image, or video
  • mediaLink - the media to be sent.
  • caption - the caption of media
whatsapp.messagesMediaByLink(
	to: 910000000000,
	mediaType:"video",
	mediaLink: "https://example.com/flutter.mp4",
	caption:"My Flutter Video"
);

💬 Send reaction on message

Send the location to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • messageId - the message id.
  • emoji - the emoji to be sent.
whatsapp.messagesReaction(
	to: 910000000000,
	messageId: "wamid.xxxxxxxxxxxxxxxxxx==",
	emoji: "👍"
);

💬 Send reply on message

Send the location to the client.

  • to - the phone number with country code but without the plus (+) sign.
  • messageId - the message id.
  • message - the message to be sent.
  • previewUrl - used to preview the URL in the chat window.
whatsapp.messagesReply(
	to: 910000000000,
	messageId: "wamid.xxxxxxxxxxxxxxxxxx==",
	message: "Hey, Flutter!",
	previewUrl: true
);

💬 Send reply with media

Reply to a media by ID

  • to - the phone number with country code but without the plus (+) sign.
  • messageId - the message id.
  • mediaType - type of media such as image, document, audio or video
  • mediaId - id of media to be replay.
whatsapp.messagesReplyMedia(
	to: 910000000000,
	messageId: "wamid.xxxxxxxxxxxxxxxxxx==",
	mediaType: "image",
	mediaId: "1000000000000000"
);

💬 Send reply with media url

Reply to a media by URL

  • to - the phone number with country code but without the plus (+) sign.
  • messageId - the message id.
  • mediaType - type of media such as image, document, audio or video
  • mediaLink - link of media to be replay.
  • caption - caption of media to be replay.
whatsapp.messagesReplyMediaUrl(
	to: 910000000000,
	messageId: "wamid.xxxxxxxxxxxxxxxxxx==",
	mediaType: "video",
	mediaLink: "http://example.com/video.mp4",
	caption: "My Flutter Video"
);

📞 Register a number

Register a phone number

  • pin is 6-digit pin for Register number.
whatsapp.registerNumber(
	pin:"123456"
);

📞 Deregister a number

Deregister a phone number

  • pin is 6-digit pin for deregister number.
whatsapp.deregisterNumber(
	pin:"123456"
);

🆔 Get Shared WhatsApp Business Account Id

Get Shared WhatsApp Business Account Id

  • inputToken - token generated after embedding the signup flow
whatsapp.getWhatsAppBusinessAccounts(
	inputToken:"EAAFl...."
);

🆔 Get Shared WhatsApp Business Account List

Get Shared WhatsApp Business Account List

  • accountId - Business manager account Id
whatsapp.getWhatsAppBusinessAccountsList(
	accountId: 805021500648488
);

Contributors

chouhan-rahul

Report bugs or issues

You are welcome to open a ticket on github if any problems arise. New ideas are always welcome.

Copyright and License

Copyright © 2022 Rohit Chouhan. Licensed under the MIT LICENSE.

Libraries

whatsapp