2

I am trying to build a custom connector for the Rasa chatbot framework and MessageBird messaging service, specifically for Whatsapp Business channel. I have taken a look into Python SDK for MessageBird, and I don't see WhatsApp template messages (or Highly Structured Messages in MessageBird's definition) supported anywhere in it.

Am I mistaken? Or the current version of the MessageBird's SDK really supports only non-structured messages, regular SMS-es?

Thanks in advance for your help.

Hassan Hosseini
  • 410
  • 1
  • 4
  • 20
dromo
  • 21
  • 2
  • If the SDK doesn't provide what you need from it, maybe it is possible to use the API directly? I think if you want to connect Rasa to Whatsapp, you should be able to do so via the Twilio connector. You'd need to enable Whatsapp for the twilio number (more info https://www.twilio.com/docs/sms/whatsapp/api) and change the format of the “twilio_number” in the connector (https://rasa.com/docs/rasa/user-guide/connectors/twilio/) to twilio_number: 'whatsapp:+44xxxxxxxxxxx' – Ella Rohm-Ensing Feb 12 '20 at 14:24
  • Thanks, but MessageBird is an analog of Twilio, and what I need to do is to write a connector itself. I don't just need to connect Rasa to Whatsapp, I need to do it through MessageBird. Meanwhile, MB's tech support told me that their Python SDK do support HSMs, so I think I am going to figure it out. Will keep you posted. – dromo Feb 14 '20 at 22:40
  • I am hoping to attempt a similar approach (i.e. use messagebird) instead of Twilio - based on costs as the former is cheaper. Did you ever find a solution to this? Is there any information that you would be willing to share? I do have my conversational agent working well with Twilio all I am looking for is to switch to message bird. – user8291021 Jul 15 '20 at 01:04

1 Answers1

0

There is a MESSAGE_TYPE_HSM = "hsm" as a selectable type for a conversation message (defined here) and you will have to adapt the content to refer the appropriate HSM template id (see documentation):

"content":{
  "hsm": {
    "namespace": "5ba2d0b7_f2c6_433b_a66e_57b009ceb6ff",
    "templateName": "order_update",
    "language": {
    "policy": "deterministic",
    "code": "en"
    },
    "params": [
    {"default": "Bob"},
    {"default": "tomorrow!"}
    ]
  }

Putting it all together, based on the example, it should look something like this:

msg = client.conversation_create_message(args['conversationId'],
                                             {'channelId': args['channelId'], 'type': MESSAGE_TYPE_HSM,                                             
                                              "content":{"hsm": { "namespace": "5ba2d0b7_f2c6_433b_a66e_57b009ceb6ff","templateName": "order_update","language": {"policy": "deterministic","code": "en"},"params": [{"default": "Bob"},{"default": "tomorrow!"}]}}})

Where of course you will have to customize the content to your exact setup.

Ando
  • 11,199
  • 2
  • 30
  • 46