twilio-conversations-demo-react: Cannot create a new conversation

I was trying to test the demo out, after having done the initial steps and setting up the serverless functions. I can log in and build the app successfully. However, I cannot create a new conversation.

Error: Cannot read properties of undefined (reading 'then')

  "react": "17.0.2",
  "@twilio/conversations": "2.4.1",

It’s this function

  async createConversation(options) {    
        await this._ensureReady;
        options = options || {};
        return this._conversationsPromise.then((conversationsEntity) => conversationsEntity.addConversation(options));
    }

Note: I am using the serverless functions for the backend.

Node: v18

Use the steps here to set up the service.

Screenshot 2023-12-06 at 10 51 07 AM

I have gone through the other issues, not that helpful. Anyone who’s been able to get throught this, I’d appreciate the support.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

@GomezFabio gave a right answer. Thank you. My problem was in the existing API key which is actually not an API key at all.

https://console.twilio.com/us1/account/keys-credentials/api-keys This page has two sections.

  1. API keys
  2. Auth Tokens

There was a live auth token which I already used before this demo application and this auth token didn’t work.

Now I’ve created a new API key. I’ve updated my env variables in the cloud function and everything works now. The status is set to “online” after the initial sign in.

@Fabryz FYI

Could you please tell me what I’d need to do in particular?

You need to deploy a function as descibed in the README that will generate and provide you with access tokens. When deploying to vercel it shall ask you about the token generator url - you need to provide that function’s url there.

@GomezFabio Thanks.

I already did this. I am able to use auth but cannot create room/channel for testing the whole thing out.

And I was not able to find anything in the demo, example or the docs on how to trace my steps for the setup.

Currently putting twilio on hold, exploring other options.

I had the same problem and this is how I have solved it. I was using wrong credentials for TWILIO_API_KEY_SID and TWILIO_API_KEY_SECRET variables. You must create a new API Key and get the right variables from it. Check it at https://console.twilio.com/us1/account/keys-credentials/api-keys and use [Create API key] button.

@berkus maybe we can change Error: Cannot read properties of undefined (reading 'then') to a different message so it doesn’t confuse anyone.

Since you’re still offline, this means the connection did not finalize yet, you cannot create conversations while offline in the current implementation.