Rasa integration with twilio to whatsapp

Hi, I tried Rasa integration with twilio to whatsapp. I am able to connect it with whatsapp but I get the following error:

ERROR rasa_core.channels.twilio - Something went wrong “Unable to create record: The ‘From’ number +14155238886 is not a valid phone number, shortcode, or alphanumeric sender ID.”

I am able to get the response in terminal after sending message from whatsapp, but not back in whatsapp.

INFO twilio.http_client - PAYLOAD: {‘Body’: u’Hey there! Tell me your name.’, ‘To’: ‘whatsapp:+9195274*****’, ‘From’: u’+14155238886’} 2019-01-17 11:19:14 INFO twilio.http_client - POST Response: 400 {“code”: 21212, “message”: “The ‘From’ number +14155238886 is not a valid phone number, shortcode, or alphanumeric sender ID.”, “more_info”: “https://www.twilio.com/docs/errors/21212”, “status”: 400} 2019-01-17 11:19:14 ERROR rasa_core.channels.twilio - Something went wrong “Unable to create record: The ‘From’ number +14155238886 is not a valid phone number, shortcode, or alphanumeric sender ID.”

please help to solve this issue.

1 Like

I have the exact same problem. From what I can understand it seems that the chatbot needs to have a specific phone number in the credentials.yaml file. But I’m not able to find where this number needs to be “activated/set”.

Any help would be appreciated!

I’ve actually made a step forward: you have to fix the credentials file to be like:

twilio: account_sid: “xxxxxxxx” auth_token: “xxxxxxxx” twilio_number: "whatsapp:+(your sandbox number) "

You can find the sandbox number in the sandbox section under whatsapp on your Twilio account.

Anyway the problem with whatsapp remains. Rasa core server is generating the answer to the received message but the answer is not reaching the destination whatsapp number.

Any help would be appreciated!

1 Like

I had the same issue but now it’s resolved. It should be using your account credentials, not the test-credentials. For me, it’s working fine. Initially, I had an issue with getting credentials in ‘twilio.py’ file. I get into that file via root (sudo su) and passed those credentials hardcoded there itself.

@classmethod
def from_credentials(cls, credentials):
    if not credentials:
        cls.raise_missing_credentials_exception()

    return cls(
        credentials.get("account_sid"),
        credentials.get("auth_token"),
        credentials.get("twilio_number"),
    )

changed above code to ->

@classmethod
def from_credentials(cls, credentials):
    if not credentials:
        cls.raise_missing_credentials_exception()

    return cls(
        '<account_id>',
        '<auth_token>',
        'whatsapp:+14155238886'
    )

Hello, I managed to connect rasa with a website using a websocket, and now I want to connect rasa bot with Twilio, but I’m not sure where to start. I ahve my Twilio credentials, but I’m not sure if I should use the websocket to conenct with twilio, or how exactly to start.

Before I had a simpler sample bot between twilio and whatsapp, no rasa, that used flask or ngrok, should I be using the same or something similar?

Thanks