Skip to main content

Microsoft Bot Builder sangam twilio whatsapp adapter

Project description

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

 
``` 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

File details

Details for the file botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz.

File metadata

  • Download URL: botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for botbuilder-sangam-twilio-whatsapp-adapter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 072b80646c8ad51098ebe9b02e9b783bea23c83a04e66366005c56a0f306eebd
MD5 9c78382feda4ece2e1eef528a228fdc2
BLAKE2b-256 b22ce0e2af16c546295c4591d2d09f953f2ccac79c407aabdad221175ca55cc8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page