Tanzeem
Tanzeem

Reputation: 109

how to use RCS messages to send text messages

I want to send Google RCS Messages to phones using Google RCS Messaging. I have setup an RCS agent.Now I want to send automated text messages from my PHP code to specified phonenumbers. I have the following code from the documentation: https://developers.google.com/business-communications/rcs-business-messaging/guides/build/messages/send#curl

curl -X POST "https://REGION

-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER

/agentMessages?messageId=MESSAGE_ID

" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY

 rcsbusinessmessaging`" \
-d "{
  'contentMessage': {
    'text': 'Hello, world!

'
  }
}"

What should i replace in REGION? . I am from India. Should i create locations before doing so? What should i use in place of MESSAGE_ID and PATH_TO_SERVICE_ACCOUNT_KEY ?

After referring further more i came up with this custom curl command:

curl -X POST "https://EUROPE-rcsbusinessmessaging.googleapis.com/v1/phones/+919746489490/agentMessages?messageId=NULL" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json ~/Downloads/gbc-cdit-qi3yp3y-330c0a84b4ff.json rcsbusinessmessaging`" \
-d "{ 'contentMessage': { 'text': 'Hello, world! ' } }"

after downloading the service account key from settings as json file. But I get the following error

{
  "error": {
    "code": 403,
    "message": "RCS Business Messaging API has not been used in project 259974077053 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/rcsbusinessmessaging.googleapis.com/overview?project=259974077053 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/rcsbusinessmessaging.googleapis.com/overview?project=259974077053"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "rcsbusinessmessaging.googleapis.com",
          "consumer": "projects/259974077053"
        }
      }
    ]
  }
}

I enabled rcs business messaging as specified. But still get the same error.

Upvotes: 1

Views: 2132

Answers (1)

Alexandru R
Alexandru R

Reputation: 8833

you need to activate the API in the cloud console.

Upvotes: 0

Related Questions