Skip to main content

Twilio WhatsApp Adapter (beta)

The Twilio WhatsApp adapter for the Microsoft Bot Framework allows you to add an additional endpoint to your bot for use with Twilio WhatsApp. The goal of this adapter is to support WhatsApp via Twilio as seamlessly as possible. All supported features on WhatsApp are mapped to the default Bot Framework SDK.

To send messages with WhatsApp in production, you have to wait for WhatsApp to formally approve your account. But, that doesn't mean you have to wait to start building. Twilio Sandbox for WhatsApp lets you test your app in a developer environment.

This adapter supports the limited capabilities of Twilio WhatsApp, including;

  • Send and receive text messages
  • Send and receive text messages with attachments (image, audio, video, document, location)
  • Send proactive notifications
  • Track message deliveries (sent, delivered and read receipts)

Status

Currently the Twilio WhatsApp channel is in beta.

Products in Beta may occasionally fall short of speed or performance benchmarks, have gaps in functionality, and contain bugs.

APIs are stable and unlikely to change as the product moves from Beta to Generally Available (GA). We will do our best to minimize any changes and their impact on your applications. Products in Beta are not covered by Twilio's SLA's and are not recommended for production applications.

Installing

pip install botbuilder-sangam-twilio-whatsapp-adapter

Usage

  1. Use your existing Twilio account or create a new Twilio account.
  2. Go to the Twilio Sandbox for WhatsApp and follow the first steps.
  3. At the Configure your Sandbox step, add your endpoint URLs. Those URLs will be defined by the snippet below, by default the URL will be [your-bot-url]/api/whatsapp/messages. The status callback url is optional and should only be used if you want to track deliveries of your messages.
  4. Go to your Dashboard and click on Show API Credentials.
  5. Implement the snippet below and add your Account SID, Auth Token, your phone number and the endpoint URL you configured in the sandbox.
  6. Give it a try! Your existing bot should be able to operate on the WhatsApp channel via Twilio.

```
from botbuilder.sangam.twilio.whatsapp.adapter.twilio_adapter import TwilioAdapter
from botbuilder.sangam.twilio.whatsapp.adapter.twilio_whatsapp_adapter_settings import TwilioWhatsAppAdapterSettings

#Settings
twilio_settings = TwilioWhatsAppAdapterSettings(
account_sid="",
auth_token="",
endpoint_url="",
phone_number=""
)

#Create a adapter
twilio_adapter = TwilioAdapter(twilio_settings)

#Add adapter
APP.router.add_post("/api/whatsapp/messages",whatsapp)
 
async def whatsapp(req: Request) -> Response:
try:
    response = await twilio_adapter.process_activity(req,Response,BOT.on_turn)
    if response:
        return json_response(data=response.body, status=response.status)
    return Response(status=201)
except Exception as exception:        
    raise exception

 
``` 

Metadata

Release files for botbuilder-sangam-twilio-whatsapp-adapter 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for botbuilder-sangam-twilio-whatsapp-adapter 0.4.0
File Size Uploaded Provenance Actions
botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz 8.9 kB Without provenance Details for botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz

Release files / botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz

Download URL botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
072b80646c8ad51098ebe9b02e9b783bea23c83a04e66366005c56a0f306eebd
BLAKE2b-256 checksum
How to use checksums
b22ce0e2af16c546295c4591d2d09f953f2ccac79c407aabdad221175ca55cc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Security for botbuilder-sangam-twilio-whatsapp-adapter 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page